* [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t
@ 2016-02-18 13:32 Thierry Reding
2016-02-18 13:32 ` [PATCH 2/2] spi: Prevent a type mismatch warning using min_t() Thierry Reding
2016-02-18 13:36 ` [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Thierry Reding @ 2016-02-18 13:32 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
When printing unsigned int it is more idiomatic to use %u, for size_t
the correct specifier is %zu (see Documentation/printk-formats.txt).
GCC only warns about the latter, but fixing up the former while at it
for consistency.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f6c76be39e96..f123f9f4d779 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2276,7 +2276,7 @@ static int __spi_split_transfer_maxsize(struct spi_master *master,
/* warn once about this fact that we are splitting a transfer */
dev_warn_once(&msg->spi->dev,
- "spi_transfer of length %i exceed max length of %i - needed to split transfers\n",
+ "spi_transfer of length %u exceed max length of %zu - needed to split transfers\n",
xfer->len, maxsize);
/* calculate how many we have to replace */
--
2.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] spi: Prevent a type mismatch warning using min_t()
2016-02-18 13:32 [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Thierry Reding
@ 2016-02-18 13:32 ` Thierry Reding
2016-02-18 13:36 ` [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2016-02-18 13:32 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-spi, linux-kernel
From: Thierry Reding <treding@nvidia.com>
The min_t() variant of the min() macro uses an explicit cast to the type
given in the first argument and can be used to avoid a compiler warning
if both types differ (f.e. in signedness).
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/spi/spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f123f9f4d779..fe001ec4471e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2301,7 +2301,7 @@ static int __spi_split_transfer_maxsize(struct spi_master *master,
/* the first transfer just needs the length modified, so we
* run it outside the loop
*/
- xfers[0].len = min(maxsize, xfer[0].len);
+ xfers[0].len = min_t(size_t, maxsize, xfer[0].len);
/* all the others need rx_buf/tx_buf also set */
for (i = 1, offset = maxsize; i < count; offset += maxsize, i++) {
--
2.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t
2016-02-18 13:32 [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Thierry Reding
2016-02-18 13:32 ` [PATCH 2/2] spi: Prevent a type mismatch warning using min_t() Thierry Reding
@ 2016-02-18 13:36 ` Mark Brown
[not found] ` <20160218133619.GB7129-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2016-02-18 13:36 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-spi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
On Thu, Feb 18, 2016 at 02:32:57PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> When printing unsigned int it is more idiomatic to use %u, for size_t
> the correct specifier is %zu (see Documentation/printk-formats.txt).
These don't apply against current code, please check and resend. Fabio
sent some similar patches the other day.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t
[not found] ` <20160218133619.GB7129-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2016-02-18 13:58 ` Thierry Reding
0 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2016-02-18 13:58 UTC (permalink / raw)
To: Mark Brown
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 943 bytes --]
On Thu, Feb 18, 2016 at 01:36:19PM +0000, Mark Brown wrote:
> On Thu, Feb 18, 2016 at 02:32:57PM +0100, Thierry Reding wrote:
> > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> >
> > When printing unsigned int it is more idiomatic to use %u, for size_t
> > the correct specifier is %zu (see Documentation/printk-formats.txt).
>
> These don't apply against current code, please check and resend. Fabio
> sent some similar patches the other day.
I started seeing this two days ago and didn't submit because I assumed
somebody else already had. When it didn't filter out on top of today's
-next I decided to send out.
I do see that Fabio's fixes went into your tree yesterday, possibly not
quite in time to make today's -next. Both his patches fix the same
warnings that mine did. The only thing missing seems to be the %i -> %u
conversion, but I don't think I'll respin just for that.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-18 13:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-18 13:32 [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Thierry Reding
2016-02-18 13:32 ` [PATCH 2/2] spi: Prevent a type mismatch warning using min_t() Thierry Reding
2016-02-18 13:36 ` [PATCH 1/2] spi: Use %u for unsigned int, %zu for size_t Mark Brown
[not found] ` <20160218133619.GB7129-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-02-18 13:58 ` Thierry Reding
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).