[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Warning in spawn-pipe.c (create_pipe)

From: Tim Rühsen
Subject: Warning in spawn-pipe.c (create_pipe)
Date: Wed, 13 Dec 2017 11:01:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

This seems to be a false positive from clang - but how does a compiler
know for sure that a function (posix_spawnp) always initializes a
pointer argument when returning 0 ? Ok, it's written in the docs and we
know it but there is no syntax to tell the compiler exactly that.

That's why I vote for initializing 'child' to 0 as suggested below. It
seems to be good programming practice.

clang's warning:

spawn-pipe.c:364:34: warning: variable 'child' may be uninitialized when
used here [-Wconditional-uninitialized]
      register_slave_subprocess (child);
spawn-pipe.c:257:14: note: initialize the variable 'child' to silence
this warning
  pid_t child;
              = 0

With Best Regards, Tim

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]