From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43952 invoked by alias); 27 Aug 2019 18:42:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 43944 invoked by uid 89); 27 Aug 2019 18:42:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Aug 2019 18:42:01 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 511243082B1F; Tue, 27 Aug 2019 18:42:00 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2314460C05; Tue, 27 Aug 2019 18:42:00 +0000 (UTC) From: Sergio Durigan Junior To: "Christian Biesinger via gdb-patches" Cc: Christian Biesinger Subject: Re: [PATCH] Fix compiler warning in linux-namespaces.c References: <20190827182508.138503-1-cbiesinger@google.com> Date: Tue, 27 Aug 2019 18:42:00 -0000 In-Reply-To: <20190827182508.138503-1-cbiesinger@google.com> (Christian Biesinger via gdb-patches's message of "Tue, 27 Aug 2019 13:25:08 -0500") Message-ID: <87ftlmfo20.fsf@redhat.com> 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-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00614.txt.bz2 On Tuesday, August 27 2019, Christian Biesinger via gdb-patches wrote: > ../../gdb/nat/linux-namespaces.c: In function =E2=80=98void mnsh_main(int= )=E2=80=99: > ../../gdb/nat/linux-namespaces.c:604:8: warning: =E2=80=98fd=E2=80=99 may= be used uninitialized in this function [-Wmaybe-uninitialized] > close (fd); > ~~~~~~^~~~ > > And the warning is correct -- mnsh_recv_message can return -1 and leave fd > uninitialized, and mnsh_main will still call close (fd) if that happens. > > Initialize fd to -1 to avoid that. Thanks. IMO this patch could be treated as obvious. > gdb/ChangeLog: > > 2019-08-27 Christian Biesinger > > * nat/linux-namespaces.c (mnsh_main): Initialize fd (to -1). > --- > gdb/nat/linux-namespaces.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c > index 503f755903..57843cda36 100644 > --- a/gdb/nat/linux-namespaces.c > +++ b/gdb/nat/linux-namespaces.c > @@ -562,14 +562,14 @@ mnsh_main (int sock) > while (1) > { > enum mnsh_msg_type type; > - int fd, int1, int2; > + int fd =3D -1, int1, int2; > char buf[PATH_MAX]; > ssize_t size, response =3D -1; >=20=20 > size =3D mnsh_recv_message (sock, &type, > &fd, &int1, &int2, > buf, sizeof (buf)); > - > +` This seems like a typo. > if (size >=3D 0 && size < sizeof (buf)) > { > switch (type) > --=20 > 2.23.0.187.g17f5b7556c-goog Cheers, --=20 Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/