mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kieran Bingham <kbingham@kernel.org>
To: Vincent Bernat <vincent@bernat.ch>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Stephen Boyd <swboyd@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/gdb: replace "is 0" by "== 0"
Date: Fri, 20 Mar 2020 16:47:19 +0000	[thread overview]
Message-ID: <55dae299-a5a0-6e11-c966-1d8dcb46c452@kernel.org> (raw)
In-Reply-To: <20200320163820.3634106-1-vincent@bernat.ch>

Hi Vincent,

On 20/03/2020 16:38, Vincent Bernat wrote:
> While for small numbers, using "node is 0" works with CPython, it is
> more portable to use "node == 0". Moreover, with Python 3, this
> triggers a syntax warning:

Oh, I thought python encouraged the 'is' style.

> 
>     SyntaxWarning: "is" with a literal. Did you mean "=="?

Of course that means it clearly doesn't in this case...


> Signed-off-by: Vincent Bernat <vincent@bernat.ch>

Change looks acceptable to me given the report, though a potential
alternative below, otherwise

Reviewed-by: Kieran Bingham <kbingham@kernel.org>

> ---
>  scripts/gdb/linux/rbtree.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/gdb/linux/rbtree.py b/scripts/gdb/linux/rbtree.py
> index 39db889b874c..87d4738984d2 100644
> --- a/scripts/gdb/linux/rbtree.py
> +++ b/scripts/gdb/linux/rbtree.py
> @@ -17,7 +17,7 @@ def rb_first(root):
>          raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
>  
>      node = root['rb_node']
> -    if node is 0:
> +    if node == 0:

Given the nature of the statement, would

if not node:
    return None

be any more appropriate ?

>          return None
>  
>      while node['rb_left']:
> @@ -33,7 +33,7 @@ def rb_last(root):
>          raise gdb.GdbError("Must be struct rb_root not {}".format(root.type))
>  
>      node = root['rb_node']
> -    if node is 0:
> +    if node == 0:
>          return None
>  
>      while node['rb_right']:
> 


-- 
--
Kieran

  reply	other threads:[~2020-03-20 16:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 16:38 Vincent Bernat
2020-03-20 16:47 ` Kieran Bingham [this message]
2020-03-20 17:05   ` Vincent Bernat
2020-03-20 16:48 ` Stephen Boyd

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=55dae299-a5a0-6e11-c966-1d8dcb46c452@kernel.org \
    --to=kbingham@kernel.org \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swboyd@chromium.org \
    --cc=vincent@bernat.ch \
    /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

all inboxes | Powered by JetHome®