All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Nicholas Mc Guire <hofrat@osadl.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rcu: change function declaration to bool
Date: Mon, 11 May 2015 17:19:01 +0200	[thread overview]
Message-ID: <20150511151901.GA17629@opentech.at> (raw)
In-Reply-To: <20150511144022.GB6130@x>

On Mon, 11 May 2015, Josh Triplett wrote:

> On Mon, May 11, 2015 at 10:51:55AM +0200, Nicholas Mc Guire wrote:
> > rcu_cpu_has_callbacks() is declared int but is actually returning bool and
> > all call-sites currently use it as bool so the declaration should be bool 
> > as well.
> > 
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> 
> The patch seems reasonable to me.  However...
> 
> > ---
> > 
> > ./kernel/rcu/tree.c:3538 WARNING: return of wrong type
> >                     int != bool, 
> > 
> > as the description of rcu_cpu_has_callbacks() states:
> > " * Return true if the specified CPU has any callback...."
> > this probably should be a bool 
> > All (3) call sites are conditions and are treating it as boolean.
> > 
> > Patch was compile tested with x86_64_defconfig (implies CONFIG_TREE_RCU=y)
> 
> ...some of this information should be in the commit message, as well as
> a description of what tool produced this warning.
>

The tool is coccinelle - type checking scripts that Im working on and that
produced (with Julia Lawal fixing up my .cocci scripts) a few 1000s of 
type missmatches in the overall kernel a few hundred in the ./kernel/* - 
so starting to clean up....
 
> With that changed,
> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
>

thanks - just resend with description moved. and a note that coccinelle was
used.

The full script is though in its current form not yet usable as it is not 
classifying type errors - had to do that manually - for the kernel (and 
glibc for comparison) this is currently:

component  Nr funcs  != type    %
kernel   :  374600    10727    2.85
glibc    :    9184      268    2.92

finding                  kernel  glibc 
wrong ?                :     8     4   
sign missmatch         :  2279    30   
down sized             :   435    49   
up sized               :   910    20   
declaration missmatch  :  7095   165   

as noted - sorting/filtering needed some manual work so nubers
are not that precise. wrong here simply means I could not figure
it out like an int foo() returning a float.

Once this is cleaned up I'll post the type-checking scripts along with
the depressing results...

// Find functions where return type and signature do not match
// V2: with the suggestions/improvements from Julia Lawal added this
// now finds about 10 times as many bad cases ...                               
//
// Comments:
// Options: --no-includes --include-headers

virtual context
virtual org
virtual report

@match exists@
type T1,T2;
idexpression T1 ok;
idexpression T2 ret;
identifier f;
constant C;
position p;
@@

T1 f(...) {
<+...
(
return ok;
|
return C;
|
return@p ret;
)
...+>
}

@script:python@
p << match.p;
fn << match.f;
T1 << match.T1;
T2 << match.T2;
@@

print "%s:%s WARNING: return of wrong type \n\t %s != %s" % (p[0].file,p[0].line,T1,T2)
 

      reply	other threads:[~2015-05-11 15:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11  8:51 [PATCH] rcu: change function declaration to bool Nicholas Mc Guire
2015-05-11 14:40 ` Josh Triplett
2015-05-11 15:19   ` Nicholas Mc Guire [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=20150511151901.GA17629@opentech.at \
    --to=der.herr@hofr.at \
    --cc=hofrat@osadl.org \
    --cc=josh@joshtriplett.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    /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.