From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20654 invoked by alias); 27 Aug 2019 18:25:13 -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 20213 invoked by uid 89); 27 Aug 2019 18:25:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=fd, H*MI:google X-HELO: mail-qt1-f201.google.com Received: from mail-qt1-f201.google.com (HELO mail-qt1-f201.google.com) (209.85.160.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Aug 2019 18:25:11 +0000 Received: by mail-qt1-f201.google.com with SMTP id e22so21683268qtp.9 for ; Tue, 27 Aug 2019 11:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc :content-transfer-encoding; bh=mqrtuoSj+YhvJw5z3wpldy7+ppZVG4i9Q03NzO06cpU=; b=vUAT3ghpGzb+b0cNsMuIK+SZA/Ym6/U/J6mQhI60KN66eatkfS/gUrhJOGTYUWUtgy 8ABnajnh7vs6hM7ep0URoXdtjVe15Ckg5W+fC+5XB7+cT84qaENlF8mXbmfFvZ4gcd9E kzsYRthvpw2O0vVMAOyow5VfVtXqco3NgI3evNJRJwRjhOQBe1g3A9r3EyiK21VSvqO9 BUGa/hZL7p4GQjgaCLS0lz94Ufgz95Dxi2ajTsSNBAPLqxte5mTtWZdQZgnsyCAPfQFw ZTKpoflFnxtKdqCvX8fnCdfej9RKYXq6OmxwVp8GG9WpvPKcb0V9OypVi46i4nik6lOe bWNA== Date: Tue, 27 Aug 2019 18:25:00 -0000 Message-Id: <20190827182508.138503-1-cbiesinger@google.com> Mime-Version: 1.0 Subject: [PATCH] Fix compiler warning in linux-namespaces.c From: "Christian Biesinger via gdb-patches" Reply-To: Christian Biesinger To: gdb-patches@sourceware.org Cc: Christian Biesinger Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00613.txt.bz2 ../../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 b= e 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. 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 size =3D mnsh_recv_message (sock, &type, &fd, &int1, &int2, buf, sizeof (buf)); - +` if (size >=3D 0 && size < sizeof (buf)) { switch (type) --=20 2.23.0.187.g17f5b7556c-goog