public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] Fix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379)
Date: Sat, 25 Aug 2018 15:56:00 -0000	[thread overview]
Message-ID: <50e8c465-415e-0f00-562a-1508b4fad5cb@simark.ca> (raw)
In-Reply-To: <874lfi1osj.fsf@tromey.com>

On 2018-08-25 10:52 a.m., Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> 	* python/py-threadevent.c (get_event_thread): Rename to ...
> Pedro> 	(py_get_event_thread): ... this, make extern, add 'ptid' parameter
> 
> I get this warning now:
> 
> ../../binutils-gdb/gdb/python/py-threadevent.c: In function ‘PyObject* py_get_event_thread(ptid_t)’:
> ../../binutils-gdb/gdb/python/py-threadevent.c:39:3: warning: ‘pythread’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> ... which seems legitimate to me:
> 
>   PyObject *pythread;
> 
>   if (non_stop)
>     {
>       thread_info *thread = find_thread_ptid (ptid);
>       if (thread != nullptr)
> 	pythread = (PyObject *) thread_to_thread_object (thread);
> // ... else pythread is uninitialized ...
>     }
> 
> pythread should be set to nullptr where I stuck the comment (or
> initialized to nullptr).
> 
> Tom
> 

Huh indeed, thanks for pointing it out.  I wonder why I don't get the warning with my gcc 8.2.0...

I pushed this patch to master and the 8.2 branch.

From bbbbbceebc342d583057a11d88bae85f451cd904 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Sat, 25 Aug 2018 11:52:24 -0400
Subject: [PATCH] Initialize variable in py_get_event_thread

The pythread variable could be used without being initialized, fix it by
initializing it to nullptr.

gdb/ChangeLog:

	* python/py-threadevent.c (py_get_event_thread): Initialize
	pythread.
---
 gdb/ChangeLog               | 5 +++++
 gdb/python/py-threadevent.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 12dda6c541d9..9e3d6bc27acd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-25  Simon Marchi  <simon.marchi@polymtl.ca>
+
+	* python/py-threadevent.c (py_get_event_thread): Initialize
+	pythread.
+
 2018-08-24  Pedro Alves  <palves@redhat.com>

 	* python/py-bpevent.c (create_breakpoint_event_object): Use
diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c
index a78f0a38310c..4f822b4ae09c 100644
--- a/gdb/python/py-threadevent.c
+++ b/gdb/python/py-threadevent.c
@@ -25,7 +25,7 @@
 PyObject *
 py_get_event_thread (ptid_t ptid)
 {
-  PyObject *pythread;
+  PyObject *pythread = nullptr;

   if (non_stop)
     {
@@ -36,7 +36,7 @@ py_get_event_thread (ptid_t ptid)
   else
     pythread = Py_None;

-  if (!pythread)
+  if (pythread == nullptr)
     {
       PyErr_SetString (PyExc_RuntimeError, "Could not find event thread");
       return NULL;
-- 
2.18.0

      reply	other threads:[~2018-08-25 15:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24 17:46 [PATCH] " Pedro Alves
2018-08-24 18:53 ` Simon Marchi
2018-08-24 19:44   ` [PATCH v2] " Pedro Alves
2018-08-24 19:47     ` Pedro Alves
2018-08-24 20:06       ` Simon Marchi
2018-08-24 22:13         ` [pushed] gdb/python: Use copy-initialization more when possible Pedro Alves
2018-08-24 20:02     ` [PATCH v2] Fix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379) Simon Marchi
2018-08-25 14:52     ` Tom Tromey
2018-08-25 15:56       ` Simon Marchi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50e8c465-415e-0f00-562a-1508b4fad5cb@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=simon.marchi@ericsson.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).