From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84882 invoked by alias); 27 Aug 2019 18:54:22 -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 84873 invoked by uid 89); 27 Aug 2019 18:54:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-30.5 required=5.0 tests=AWL,BAYES_00,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,USER_IN_DEF_SPF_WL autolearn=ham version=3.3.1 spammy= X-HELO: mail-ot1-f67.google.com Received: from mail-ot1-f67.google.com (HELO mail-ot1-f67.google.com) (209.85.210.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Aug 2019 18:54:21 +0000 Received: by mail-ot1-f67.google.com with SMTP id w4so160034ote.11 for ; Tue, 27 Aug 2019 11:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=t/GKyqEzTWt7UggbILEo6tUvOhEQCcyC12koQhh8g1w=; b=uzJGOfQ8xZQ/Y7EKC5R2c4Njhs5DT2xeJbUohdj9FBwayoEtTz4zp1SM8aOBe+IOd+ 4LcuG5aF6+kQgCUtwDVhZmfTQ/WEWhiiFpAHhHNDV26ff3vStIica5ucECzITAmz4fm2 A6BCCFh7Zun5v8HCSxl+B4SrXPolU7UUTRxooZOrSOihUTmbik8+5gNcHn0Fa/XZZAgs Q9VEEho/CcK8IYCPjp6X9OTD2fgEz7ITEBmVOQtnf9Lgq1/KVqqkaNBL9nJxRac15b04 1pjuTV167ciDwqzFHsKn5lxsIXI60wGhK7CmWYT5IPhSNpmjkoKY5e/ROolQsiZpLgYY sHyQ== MIME-Version: 1.0 References: <20190827182508.138503-1-cbiesinger@google.com> <87ftlmfo20.fsf@redhat.com> In-Reply-To: <87ftlmfo20.fsf@redhat.com> From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger Date: Tue, 27 Aug 2019 18:54:00 -0000 Message-ID: Subject: Re: [PATCH] Fix compiler warning in linux-namespaces.c To: Sergio Durigan Junior Cc: Christian Biesinger via gdb-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00615.txt.bz2 On Tue, Aug 27, 2019 at 1:42 PM Sergio Durigan Junior wrote: > > On Tuesday, August 27 2019, Christian Biesinger via gdb-patches wrote: > > > ../../gdb/nat/linux-namespaces.c: In function =E2=80=98void mnsh_main(i= nt)=E2=80=99: > > ../../gdb/nat/linux-namespaces.c:604:8: warning: =E2=80=98fd=E2=80=99 m= ay 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. Thanks, fixed the typo below and pushed 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; > > > > 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) > > -- > > 2.23.0.187.g17f5b7556c-goog > > Cheers, > > -- > Sergio > GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 > Please send encrypted e-mail if possible > http://sergiodj.net/