From: Julia Lawall <julia.lawall@lip6.fr>
To: Andrzej Hajda <a.hajda@samsung.com>
Cc: Julia Lawall <julia.lawall@lip6.fr>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Gilles Muller <Gilles.Muller@lip6.fr>,
Michal Marek <mmarek@suse.com>,
Nicolas Palix <nicolas.palix@imag.fr>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
cocci@systeme.lip6.fr, elfring@users.sourceforge.net
Subject: Re: [PATCH v2] coccinelle: assign signed result to unsigned variable
Date: Wed, 30 Sep 2015 23:51:43 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1509302351250.1977@localhost6.localdomain6> (raw)
In-Reply-To: <56092BBB.2060006@samsung.com>
On Mon, 28 Sep 2015, Andrzej Hajda wrote:
> On 09/28/2015 01:32 PM, Julia Lawall wrote:
> >
> > On Mon, 28 Sep 2015, Andrzej Hajda wrote:
> >
> >> Assigning signed function result to unsigned variable can indicate error.
> >> To decrease number of false positives patch looks if after assignment
> >> there is also check for negative values of the result.
> >>
> >> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> >> ---
> >> Hi Julia,
> >>
> >> Thanks for the hint. Now it looks much better.
> >> Summarizing this patch has found 20 problems and has 22 false positives [1][2].
> > Do you have some examples of the false positives?
> ./drivers/acpi/acpica/nsarguments.c:130:1: WARNING: Assigning signed result to
> unsigned variable: required_param_count = METHOD_GET_ARG_COUNT(...)
> ./drivers/char/agp/intel-gtt.c:361:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = KB(...)
> ./drivers/char/agp/intel-gtt.c:364:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:367:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:382:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:385:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:388:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:391:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:394:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:397:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:400:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:403:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:406:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:409:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:412:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:415:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/char/agp/intel-gtt.c:418:3: WARNING: Assigning signed result to
> unsigned variable: stolen_size = MB(...)
> ./drivers/input/touchscreen/cyttsp4_core.c:967:1: WARNING: Assigning signed
> result to unsigned variable: num_cur_tch = GET_NUM_TOUCHES(...)
> ./drivers/pinctrl/freescale/pinctrl-imx.c:648:2: WARNING: Assigning signed
> result to unsigned variable: nfuncs = of_get_child_count(...)
> ./fs/btrfs/file.c:1572:2: WARNING: Assigning signed result to unsigned variable:
> copied = btrfs_copy_from_user(...)
> ./fs/xfs/libxfs/xfs_inode_fork.c:541:2: WARNING: Assigning signed result to
> unsigned variable: new_size = XFS_BMAP_BROOT_SPACE_CALC(...)
>
> As you see most of them are macros, of_get_child_count and btrfs_copy_from_user
> return int but always non-negative.
OK, perhaps we could just live with them...
julia
next prev parent reply other threads:[~2015-09-30 21:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 12:54 [PATCH] " Andrzej Hajda
2015-09-24 15:51 ` SF Markus Elfring
2015-09-25 10:08 ` Andrzej Hajda
2015-09-25 15:51 ` SF Markus Elfring
2015-09-26 7:45 ` SF Markus Elfring
2015-09-26 9:07 ` Julia Lawall
2015-09-26 9:41 ` SF Markus Elfring
2015-09-26 9:45 ` Julia Lawall
2015-09-26 9:52 ` SF Markus Elfring
2015-09-26 9:55 ` Julia Lawall
2015-09-26 11:43 ` SF Markus Elfring
2015-09-26 13:55 ` Julia Lawall
2015-09-26 15:22 ` SF Markus Elfring
2015-09-26 15:30 ` Julia Lawall
2015-09-26 15:50 ` SF Markus Elfring
2015-09-26 15:55 ` Julia Lawall
2015-09-26 16:01 ` SF Markus Elfring
2015-09-28 10:54 ` [PATCH v2] " Andrzej Hajda
2015-09-28 11:32 ` Julia Lawall
2015-09-28 11:59 ` Andrzej Hajda
2015-09-30 21:51 ` Julia Lawall [this message]
2015-09-28 12:07 ` SF Markus Elfring
2015-09-28 12:12 ` Andrzej Hajda
2015-09-28 12:20 ` SF Markus Elfring
2015-09-28 12:42 ` [Cocci] " Julia Lawall
2015-09-28 12:55 ` SF Markus Elfring
2015-09-28 13:13 ` Julia Lawall
2015-09-28 13:53 ` SF Markus Elfring
2015-09-28 15:07 ` Julia Lawall
2015-10-03 7:09 ` Julia Lawall
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=alpine.DEB.2.02.1509302351250.1977@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=Gilles.Muller@lip6.fr \
--cc=a.hajda@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=cocci@systeme.lip6.fr \
--cc=elfring@users.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mmarek@suse.com \
--cc=nicolas.palix@imag.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 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®