From: der.herr@hofr.at (Nicholas Mc Guire)
To: cocci@systeme.lip6.fr
Subject: [Cocci] [PATCH RFC] Coccinelle: Check for return not matching function signature
Date: Tue, 5 May 2015 15:04:05 +0200 [thread overview]
Message-ID: <20150505130405.GA1956@opentech.at> (raw)
In-Reply-To: <5548B87B.4060103@users.sourceforge.net>
On Tue, 05 May 2015, SF Markus Elfring wrote:
> > Check if the signature of a function and the return value type match.
>
> Is this a task that is usually performed by a compiler?
>
>
> > In many cases this mismatch will have no side-effects
> > but in some cases it may lead to hard to locate problems
>
> It is another software development challenge to find concrete
> open issues there.
>
>
> > - and for readability and code understanding it is also helpful
> > when types match.
>
> How would you like to check for compatible data types here?
>
coccinelle knows the type so all you need to do is comare them in
phython .
>
> > The output is a bit lengthy - not sure if that is too much
> > but it seemed useful to me to see the non-matching types explicitly
> > in the warning message.
>
> How do you think about to import the result list into a database table?
>
working on that "re-cycling" your parameter count example
top 10:
488 ssize_t != int
195 int != unsigned int
183 long != int
113 int != u32
55 int != unsigned long
48 int != u8
45 int != u16
44 unsigned int != int
37 int != s32
30 int != long
>
> > +if T1 != T2:
> > + print "%s:%s,%s WARNING: return of wrong type (%s != %s)" % (p[0].file,fn,p[0].line,T1,T2)
>
> Is such a check a bit too simple?
>
Nop - why ?
Cocci "knwow" C so the assignment of types is reliable -
flaging a s32 != int is fine with respect to readability
even if they are technically the same.
thx!
hofrat
WARNING: multiple messages have this Message-ID (diff)
From: Nicholas Mc Guire <der.herr@hofr.at>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: Nicholas Mc Guire <hofrat@osadl.org>,
cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] Coccinelle: Check for return not matching function signature
Date: Tue, 5 May 2015 15:04:05 +0200 [thread overview]
Message-ID: <20150505130405.GA1956@opentech.at> (raw)
In-Reply-To: <5548B87B.4060103@users.sourceforge.net>
On Tue, 05 May 2015, SF Markus Elfring wrote:
> > Check if the signature of a function and the return value type match.
>
> Is this a task that is usually performed by a compiler?
>
>
> > In many cases this mismatch will have no side-effects
> > but in some cases it may lead to hard to locate problems
>
> It is another software development challenge to find concrete
> open issues there.
>
>
> > - and for readability and code understanding it is also helpful
> > when types match.
>
> How would you like to check for compatible data types here?
>
coccinelle knows the type so all you need to do is comare them in
phython .
>
> > The output is a bit lengthy - not sure if that is too much
> > but it seemed useful to me to see the non-matching types explicitly
> > in the warning message.
>
> How do you think about to import the result list into a database table?
>
working on that "re-cycling" your parameter count example
top 10:
488 ssize_t != int
195 int != unsigned int
183 long != int
113 int != u32
55 int != unsigned long
48 int != u8
45 int != u16
44 unsigned int != int
37 int != s32
30 int != long
>
> > +if T1 != T2:
> > + print "%s:%s,%s WARNING: return of wrong type (%s != %s)" % (p[0].file,fn,p[0].line,T1,T2)
>
> Is such a check a bit too simple?
>
Nop - why ?
Cocci "knwow" C so the assignment of types is reliable -
flaging a s32 != int is fine with respect to readability
even if they are technically the same.
thx!
hofrat
next prev parent reply other threads:[~2015-05-05 13:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 10:12 [Cocci] [PATCH RFC] Coccinelle: Check for return not matching function signature Nicholas Mc Guire
2015-05-05 10:12 ` Nicholas Mc Guire
2015-05-05 12:32 ` [Cocci] " SF Markus Elfring
2015-05-05 12:32 ` SF Markus Elfring
2015-05-05 13:04 ` Nicholas Mc Guire [this message]
2015-05-05 13:04 ` Nicholas Mc Guire
2015-05-05 13:29 ` [Cocci] " Julia Lawall
2015-05-05 13:29 ` Julia Lawall
2015-05-05 13:45 ` SF Markus Elfring
2015-05-05 13:45 ` SF Markus Elfring
2015-05-05 14:40 ` [Cocci] " Julia Lawall
2015-05-05 14:40 ` Julia Lawall
2015-05-05 16:00 ` [Cocci] " Nicholas Mc Guire
2015-05-05 16:00 ` Nicholas Mc Guire
2015-05-05 21:24 ` [Cocci] " Julia Lawall
2015-05-05 21:24 ` Julia Lawall
2015-05-08 6:59 ` [Cocci] " Nicholas Mc Guire
2015-05-08 6:59 ` Nicholas Mc Guire
2015-05-05 16:25 ` [Cocci] " SF Markus Elfring
2015-05-05 16:25 ` SF Markus Elfring
2015-05-05 21:46 ` [Cocci] " Julia Lawall
2015-05-05 21:46 ` Julia Lawall
2015-05-06 7:15 ` [Cocci] " SF Markus Elfring
2015-05-06 7:15 ` SF Markus Elfring
2015-05-06 7:15 ` SF Markus Elfring
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=20150505130405.GA1956@opentech.at \
--to=der.herr@hofr.at \
--cc=cocci@systeme.lip6.fr \
/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.