Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1236800

Re: [PATCH v2] coccinelle: assign signed result to unsigned variable

From Julia Lawall <julia.lawall@lip6.fr>
Newsgroups linux.kernel
Subject Re: [PATCH v2] coccinelle: assign signed result to unsigned variable
Date 2015-10-01 00:00 +0200
Message-ID <qexzQ-LW-1@gated-at.bofh.it> (permalink)
References <qcTEu-3SO-11@gated-at.bofh.it> <qdEk2-3tU-15@gated-at.bofh.it> <qdEWK-4se-15@gated-at.bofh.it> <qdFpL-5fT-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] coccinelle: assign signed result to unsigned variable Andrzej Hajda <a.hajda@samsung.com> - 2015-09-24 15:00 +0200
  Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-24 18:00 +0200
    Re: [PATCH] coccinelle: assign signed result to unsigned variable Andrzej Hajda <a.hajda@samsung.com> - 2015-09-25 12:10 +0200
      Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-25 18:00 +0200
      Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 09:50 +0200
        Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 11:10 +0200
          Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 11:50 +0200
            Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 11:50 +0200
              Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 12:00 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 12:00 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 13:50 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 16:00 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 17:30 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 17:40 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 18:00 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-26 18:00 +0200
                Re: [PATCH] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-26 18:10 +0200
          [PATCH v2] coccinelle: assign signed result to unsigned variable Andrzej Hajda <a.hajda@samsung.com> - 2015-09-28 13:00 +0200
            Re: [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-28 13:40 +0200
              Re: [PATCH v2] coccinelle: assign signed result to unsigned variable Andrzej Hajda <a.hajda@samsung.com> - 2015-09-28 14:10 +0200
                Re: [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-10-01 00:00 +0200
            Re: [PATCH v2] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-28 14:10 +0200
              Re: [PATCH v2] coccinelle: assign signed result to unsigned variable Andrzej Hajda <a.hajda@samsung.com> - 2015-09-28 14:20 +0200
                Re: [PATCH v2] coccinelle: assign signed result to unsigned variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-28 14:30 +0200
                Re: [Cocci] [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-28 14:50 +0200
                Re: [Cocci] [PATCH v2] coccinelle: assign signed result to unsigned  variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-28 15:00 +0200
                Re: [Cocci] [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-28 15:20 +0200
                Re: [Cocci] [PATCH v2] coccinelle: assign signed result to unsigned  variable SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-28 16:00 +0200
                Re: [Cocci] [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-09-28 17:10 +0200
            Re: [PATCH v2] coccinelle: assign signed result to unsigned  variable Julia Lawall <julia.lawall@lip6.fr> - 2015-10-03 09:10 +0200

csiph-web