Package: startpar
Version: 0.61-1
Severity: normal
X-Debbugs-Cc: Jesse Smith <[email protected]>

Dear Maintainer,

GCC complains about uninialized variable

        proc.c: In function ‘detect_consoles’:
        proc.c:180:16: warning: ‘tail’ may be used uninitialized in this 
function [-Wmaybe-uninitialized]
              tail->tty = name;

and it seems it is right:

        struct console *restrict tail;
        [...]
        if (posix_memalign((void*)&tail, sizeof(void*), alignof(typeof(struct 
console))) != 0)
                perror("memory allocation");
        tail->next = (struct console*)0;
        tail->tty = name;

According to posix_memalign(3), if posix_memalign functions fails, it
does not alter first argument "tail", which is not initialized otherwise, and
dereference "tail" anyway: perror() just prints error, it does not
affect control flow.

Also, second argument is "sizeof(void*)" which is no bigger then 8,
while malloc(3) guarantees alignment of 8.

So, this quite complicated-looking call to posix_memalign(3) can be
simplified to:

        tail = malloc(sizeof(*tail));
        if (!tail) {
                panic_and_run_in_circles();
        }
-- 
Note, that I send and fetch email in batch, once in a few days.
Please, mention in body of your reply when you add or remove recepients.

Attachment: pgpO2UVMKxwWK.pgp
Description: PGP signature

Reply via email to