From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 From: Vladislav Ivanishin To: Alexey Gladkov References: <87v9xcugq3.fsf@ispras.ru> Date: Thu, 11 Jul 2019 21:03:49 +0300 In-Reply-To: <87v9xcugq3.fsf@ispras.ru> (Vladislav Ivanishin's message of "Tue, 11 Jun 2019 21:20:04 +0300") Message-ID: <87ef2wxxbu.fsf@ispras.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Thu, 11 Jul 2019 21:44:16 +0300 Cc: kbd@lists.altlinux.org Subject: Re: [kbd] [Lint][Bug report] src/openvt.c:386: 'pid' may be used uninitialized X-BeenThere: kbd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Linux console tools development discussion List-Id: Linux console tools development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2019 18:03:51 -0000 Archived-At: List-Archive: Sorry, I didn't get your reply (not sure what the actual reason is, but it seems as if you've only replied to the list, and I am not subscribed) so I've just read it today in the archives. > On Tue, Jun 11, 2019 at 09:20:04PM +0300, Vladislav Ivanishin wrote: > > Hi, > >=20 > > I've found this bug using a static analyzer (slightly improved GCC). > >=20 > > Consider variable `pid` in function main from src/openvt.c: > >=20 > > src/openvt.c:166: int opt, pid, i; > > src/openvt.c:303: if (direct_exec || ((pid =3D fork()) =3D=3D 0))= { > > src/openvt.c:386: if (pid < 0) > > src/openvt.c:393: waitpid(pid, &retval, 0); > >=20 > > If direct_exec is TRUE, then pid doesn't get initialized, but it is used > > outside the conditional regardless of that. >=20 > This is not a bug. If direct_exec is TRUE we will never be on line 386. Oh, I didn't realize that; my bad, thanks for pointing this out. The real issue preventing the analyzer (i.e. the compiler) from seeing this as well is kbd_error lacking the noreturn attribute. > To make linter happy, I=E2=80=99ll make pid =3D 0. So a more proper fix would be adding the attribute in the header file. It would also make other compiler analyses/optimizations more effective. --=20 Vlad > Thanks! > --=20 > Rgrds, legion