From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 4F0813858C83 for ; Mon, 28 Feb 2022 17:54:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F0813858C83 Received: by mail-il1-x12d.google.com with SMTP id q4so10660836ilt.0 for ; Mon, 28 Feb 2022 09:54:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MM7EqEYoxeWnZZcb96qQl3jCHTNvy+SK5y6gTyX07LU=; b=q/JTRAIWrylJHEh/b4+wd3VBdj/ZSAHXtYX4E8G8201v5RI1KofpKkvec7Ys1CO6Z4 W05rYgsvqjBlgVYEGrxjgupRUvsV+78/MnwVByfSsrMJ7g8sopSDBSGz5HvWvzFEoC+2 yrVPopI2jLGp4C0dFn0BVQ2MidWm2qIxqkOU9vFRHgDeYcTwWAgOk6S1jeL1s1PGiLkm lRkE3WxNZ9RsxpvTeqkSjkAzGXhp2tx2ldqwWmkkNCRcZX5B8ysSaI9I0jpsChIqfb2G QM+VRn+nelzp+q7OGNqRve65/Pp3/pmPPiXRfXC3evacFRkSb/+FOT7R4agXTUCyyapC qpaQ== X-Gm-Message-State: AOAM532SFTVllYJzTyMEOduAKP5eLBsfJnOWlQJBdIoH4rRS328f5Vp+ ismod9VjrgD9fsKQKLsmbrPjsr53PSXPkA== X-Google-Smtp-Source: ABdhPJwZy1FC5BUMI5Yat3h/NQPBBg+ar7O7hu3JyvL9p5QtLEwRiZ+D5eE4i4ycbRwV6rkEbNRa1A== X-Received: by 2002:a92:cb44:0:b0:2be:33b0:2a52 with SMTP id f4-20020a92cb44000000b002be33b02a52mr18404382ilq.142.1646070880756; Mon, 28 Feb 2022 09:54:40 -0800 (PST) Received: from murgatroyd.Home (75-166-141-253.hlrn.qwest.net. [75.166.141.253]) by smtp.gmail.com with ESMTPSA id k3-20020a92b703000000b002c1fb5e9c3asm6449132ili.33.2022.02.28.09.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 09:54:40 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Fix maybe-uninitialized warning in py-infthread.c Date: Mon, 28 Feb 2022 10:54:38 -0700 Message-Id: <20220228175438.289669-1-tromey@adacore.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Feb 2022 17:54:42 -0000 I got this warning from py-infthread.c using the Fedora 34 system GCC: ../../binutils-gdb/gdb/python/py-infthread.c:102:30: warning: ‘extra_info’ may be used uninitialized in this function [-Wmaybe-uninitialized] I think this happens because GDB_PY_HANDLE_EXCEPTION expands to an 'if' whose condition is always true -- but GCC can't know this. This patch avoids the warning by adding a harmless initialization. --- gdb/python/py-infthread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 66c3efdf6cc..c94d5b0ddab 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -87,7 +87,9 @@ thpy_get_details (PyObject *self, void *ignore) THPY_REQUIRE_VALID (thread_obj); - const char *extra_info; + /* GCC can't tell that extra_info will always be assigned after the + 'catch', so initialize it. */ + const char *extra_info = nullptr; try { extra_info = target_extra_thread_info (thread_obj->thread); -- 2.31.1