Re: [kbd] [Lint][Bug report] src/openvt.c:386: 'pid' may be used uninitialized
Alexey Gladkov <[email protected]> Thu, 20 Jun 2019 10:59:40 +0200
| Newsgroups | dev.linux.lists.kbd |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jun 11, 2019 at 09:20:04PM +0300, Vladislav Ivanishin wrote:
> Hi,
>
> I've found this bug using a static analyzer (slightly improved GCC).
>
> Consider variable `pid` in function main from src/openvt.c:
>
> src/openvt.c:166: int opt, pid, i;
> src/openvt.c:303: if (direct_exec || ((pid = fork()) == 0)) {
> src/openvt.c:386: if (pid < 0)
> src/openvt.c:393: waitpid(pid, &retval, 0);
>
> If direct_exec is TRUE, then pid doesn't get initialized, but it is used
> outside the conditional regardless of that.
This is not a bug. If direct_exec is TRUE we will never be on line 386.
To make linter happy, I’ll make pid = 0.
Thanks!
--
Rgrds, legion