Skip to content

Commit b84b007

Browse files
committed
Change the first iteration test so static analysis better understands the code
1 parent c3a126c commit b84b007

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/aulast/aulast-llist.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@ int list_update_logout(llist* l, time_t t, unsigned long serial)
140140
lnode *list_delete_cur(llist *l)
141141
{
142142
register lnode *cur, *prev;
143-
144-
prev = cur = l->head; /* start at the beginning */
143+
144+
if (l == NULL || l->head == NULL)
145+
return NULL;
146+
147+
prev = cur = l->head; /* start at the beginning */
145148
while (cur) {
146149
if (cur == l->cur) {
147-
if (cur == prev && cur == l->head) {
150+
// If the first iteration
151+
if (prev == l->head && cur == l->head) {
148152
l->head = cur->next;
149153
l->cur = cur->next;
150154
free((void *)cur->name);

0 commit comments

Comments
 (0)