All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: jing yangyang <cgel.zte@gmail.com>,
	Jason Wessel <jason.wessel@windriver.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Douglas Anderson <dianders@chromium.org>,
	Sumit Garg <sumit.garg@linaro.org>, Will Deacon <will@kernel.org>,
	Stephen Zhang <stephenzhangzsd@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	kgdb-bugreport@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Cc: jing yangyang <jing.yangyang@zte.com.cn>, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] debug:kdb: fix unsigned int win compared to less than zero
Date: Sat, 21 Aug 2021 07:40:51 +0200	[thread overview]
Message-ID: <473095f9-d04e-1f49-ea5b-f12329fbb435@wanadoo.fr> (raw)
In-Reply-To: <20210820022442.11107-1-jing.yangyang@zte.com.cn>

Hi,

Le 20/08/2021 à 04:24, jing yangyang a écrit :
> Fix coccicheck warning:
> ./kernel/debug/kdb/kdb_support.c:575:3-10:
> WARNING:Unsigned expression compared with zero  p_state < 0
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: jing yangyang <jing.yangyang@zte.com.cn>
> ---
>   kernel/debug/kdb/kdb_support.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c
> index c605b17..fb30801 100644
> --- a/kernel/debug/kdb/kdb_support.c
> +++ b/kernel/debug/kdb/kdb_support.c
> @@ -560,7 +560,7 @@ unsigned long kdb_task_state_string(const char *s)
>    */
>   char kdb_task_state_char (const struct task_struct *p)
>   {
> -	unsigned int p_state;
> +	int p_state;

When you make changes in variables which are written in the reverse 
Christmas tree style (i.e. long lines at the top, shorter ones below), 
you should keep this style. Many people prefer it that way.

Also, should your fix be correct, it is likely a bugfix, and a "Fixes:" 
would be needed to help backport.


However, I don't think that your patch is correct here.

Unless I missed something, 'p_state' really needs to be an 'unsigned 
int' because 'p->__state' is an 'unsigned int' since 2f064a59a11f 
("sched: Change task_struct::state")

My *guess* is that:
		(p_state < 0) ? 'U' :
should be turned in:
		(p_state & UNRUNNABLE) ? 'U' :

to match the code in 'kdb_task_state_string(()'.

The 'R' case looks also spurious to me, but I've not looked at it deeper.


Should I be right, comment at line 545 ("/* unrunnable is < 0 */") looks 
somewhat misleading or useless. I would drop it.


Finally, you have the same kind of code in 'show_task()' 
(arch/powerpc/xmon/xmon.c). I also guess that whatever the fix it, it 
should be updated the same way here.

CJ

>   	unsigned long tmp;
>   	char state;
>   	int cpu;
> 


      parent reply	other threads:[~2021-08-21  5:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20  2:24 [PATCH linux-next] debug:kdb: fix unsigned int win compared to less than zero jing yangyang
2021-08-20 16:46 ` Doug Anderson
2021-08-21  5:40 ` Christophe JAILLET [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=473095f9-d04e-1f49-ea5b-f12329fbb435@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=cgel.zte@gmail.com \
    --cc=daniel.thompson@linaro.org \
    --cc=dianders@chromium.org \
    --cc=gustavoars@kernel.org \
    --cc=jason.wessel@windriver.com \
    --cc=jing.yangyang@zte.com.cn \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=stephenzhangzsd@gmail.com \
    --cc=sumit.garg@linaro.org \
    --cc=will@kernel.org \
    --cc=zealci@zte.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.