linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] mtd: st_spi_fsm: correct type issues
Date: Wed, 16 Apr 2014 11:46:11 +0100	[thread overview]
Message-ID: <20140416104611.GP4754@lee--X1> (raw)
In-Reply-To: <1397637782-26843-1-git-send-email-computersforpeace@gmail.com>

> Compile-testing for a 64-bit arch uncovers several bad casts:
> 
>     In file included from include/linux/linkage.h:4:0,
>                      from include/linux/kernel.h:6,
>                      from drivers/mtd/devices/st_spi_fsm.c:15:
>     drivers/mtd/devices/st_spi_fsm.c: In function ‘stfsm_read_fifo’:
>     drivers/mtd/devices/st_spi_fsm.c:758:11: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>       BUG_ON((((uint32_t)buf) & 0x3) || (size & 0x3));
>     ...
> 
> Use uintptr_t instead of uint32_t, since it's guaranteed to be
> pointer-sized.
> 
> We also see this warning, if size_t is not 32 bits wide:
> 
>     In file included from drivers/mtd/devices/st_spi_fsm.c:15:0:
>     drivers/mtd/devices/st_spi_fsm.c: In function ‘stfsm_mtd_write’:
>     include/linux/kernel.h:712:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>       (void) (&_min1 == &_min2);  \
>                      ^
>     drivers/mtd/devices/st_spi_fsm.c:1704:11: note: in expansion of macro ‘min’
>        bytes = min(FLASH_PAGESIZE - page_offs, len);
>                ^
> 
> Just use min_t() to force the type conversion, since we don't really
> want to upgrade 'page_offs' and 'bytes' to size_t; they only should be
> handling <= 256 byte offsets.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mtd/devices/st_spi_fsm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Thanks for fixing Brian. Fixes look good.

Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  parent reply	other threads:[~2014-04-16 10:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-16  8:43 [PATCH 1/2] mtd: st_spi_fsm: correct type issues Brian Norris
2014-04-16  8:43 ` [PATCH 2/2] mtd: st_spi_fsm: only build for ARM Brian Norris
2014-04-16 10:46 ` Lee Jones [this message]
2014-04-17  5:01   ` [PATCH 1/2] mtd: st_spi_fsm: correct type issues Brian Norris

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=20140416104611.GP4754@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=computersforpeace@gmail.com \
    --cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).