linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
@ 2007-10-19 17:43 Jon Loeliger
  2007-10-20  7:19 ` David Gibson
  0 siblings, 1 reply; 8+ messages in thread
From: Jon Loeliger @ 2007-10-19 17:43 UTC (permalink / raw)
  To: linuxppc-dev


Signed-off-by: Jon Loeliger <jdl@freescale.com>
---
 tests/get_name.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tests/get_name.c b/tests/get_name.c
index 2481741..a76bdf8 100644
--- a/tests/get_name.c
+++ b/tests/get_name.c
@@ -55,7 +55,7 @@ void check_name(void *fdt, const char *path)
 
 	if (len != strlen(getname))
 		FAIL("fdt_get_name(%s) returned length %d instead of %d",
-		     path, len, strlen(getname));
+		     path, len, (int) strlen(getname));
 
 	/* Now check that it doesn't break if we omit len */
 	getname2 = fdt_get_name(fdt, offset, NULL);
-- 
1.5.3.1.139.g9346b

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-19 17:43 [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type Jon Loeliger
@ 2007-10-20  7:19 ` David Gibson
  2007-10-20  8:51   ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: David Gibson @ 2007-10-20  7:19 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

On Fri, Oct 19, 2007 at 12:43:13PM -0500, Jon Loeliger wrote:
> 
> Signed-off-by: Jon Loeliger <jdl@freescale.com>

Hrm.... I'm very dubious about this.

What compiler/platform is this?  I can't off the top of my head think
of one where size_t shouldn't be promoted to int automatically.
Or there's the %z modifier, which explicitly specifies a size_t, but
I'm not sure if that's C99 or a glibc extension.


> ---
>  tests/get_name.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tests/get_name.c b/tests/get_name.c
> index 2481741..a76bdf8 100644
> --- a/tests/get_name.c
> +++ b/tests/get_name.c
> @@ -55,7 +55,7 @@ void check_name(void *fdt, const char *path)
>  
>  	if (len != strlen(getname))
>  		FAIL("fdt_get_name(%s) returned length %d instead of %d",
> -		     path, len, strlen(getname));
> +		     path, len, (int) strlen(getname));
>  
>  	/* Now check that it doesn't break if we omit len */
>  	getname2 = fdt_get_name(fdt, offset, NULL);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-20  7:19 ` David Gibson
@ 2007-10-20  8:51   ` Andreas Schwab
  2007-10-20  9:06     ` David Gibson
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2007-10-20  8:51 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

David Gibson <david@gibson.dropbear.id.au> writes:

> What compiler/platform is this?  I can't off the top of my head think
> of one where size_t shouldn't be promoted to int automatically.

Only types narrower than int are subject to integer promotion.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-20  8:51   ` Andreas Schwab
@ 2007-10-20  9:06     ` David Gibson
  2007-10-22 16:50       ` Jon Loeliger
  0 siblings, 1 reply; 8+ messages in thread
From: David Gibson @ 2007-10-20  9:06 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linuxppc-dev, Jon Loeliger

On Sat, Oct 20, 2007 at 10:51:29AM +0200, Andreas Schwab wrote:
> David Gibson <david@gibson.dropbear.id.au> writes:
> 
> > What compiler/platform is this?  I can't off the top of my head think
> > of one where size_t shouldn't be promoted to int automatically.
> 
> Only types narrower than int are subject to integer promotion.

Duh, yes.  Sorry.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-20  9:06     ` David Gibson
@ 2007-10-22 16:50       ` Jon Loeliger
  2007-10-22 16:55         ` Josh Boyer
  0 siblings, 1 reply; 8+ messages in thread
From: Jon Loeliger @ 2007-10-22 16:50 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

So, like, the other day David Gibson mumbled:
> On Sat, Oct 20, 2007 at 10:51:29AM +0200, Andreas Schwab wrote:
> > David Gibson <david@gibson.dropbear.id.au> writes:
> > 
> > > What compiler/platform is this?  I can't off the top of my head think
> > > of one where size_t shouldn't be promoted to int automatically.
> > 
> > Only types narrower than int are subject to integer promotion.
> 
> Duh, yes.  Sorry.

So, Hmm.  You want the patch as I wrote it applied?
Or do you want to use %z in the format instead?  It does
seem like there is precedent to do that (in the kernel):

    % grep -r '%z' arch/
    arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
    arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
    arch/m68k/ifpsp060/src/itest.S: mulu.l          (0x00.w,%a3,%za4.l*8),%d2:%d3
    arch/m68k/ifpsp060/src/itest.S: mulu.l          (-0x10.w,%za3,%a4.l*1),%d2:%d3
    arch/m68k/ifpsp060/src/itest.S: mulu.l          (ea_77_mem+0x00.w,%pc,%za4.l*8),%d2:%d3
    ...
    arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc,%zd4.l*1]),%d2:%d3
    arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%pc],%zd4.l*8,0x20.l),%d2:%d3
    arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc],%d4.l*8),%d2:%d3
    arch/um/drivers/cow_user.c:             /* Below, %zd is for a size_t value */
    arch/um/drivers/cow_user.c:                        "limited to %zd characters\n", backing_file,
    arch/x86/kernel/pci-nommu_64.c:                     "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",

Opinions?

Thanks,
jdl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-22 16:50       ` Jon Loeliger
@ 2007-10-22 16:55         ` Josh Boyer
  2007-10-23  0:26           ` David Gibson
  0 siblings, 1 reply; 8+ messages in thread
From: Josh Boyer @ 2007-10-22 16:55 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev, David Gibson

On Mon, 22 Oct 2007 11:50:52 -0500
Jon Loeliger <jdl@jdl.com> wrote:

> So, like, the other day David Gibson mumbled:
> > On Sat, Oct 20, 2007 at 10:51:29AM +0200, Andreas Schwab wrote:
> > > David Gibson <david@gibson.dropbear.id.au> writes:
> > > 
> > > > What compiler/platform is this?  I can't off the top of my head think
> > > > of one where size_t shouldn't be promoted to int automatically.
> > > 
> > > Only types narrower than int are subject to integer promotion.
> > 
> > Duh, yes.  Sorry.
> 
> So, Hmm.  You want the patch as I wrote it applied?
> Or do you want to use %z in the format instead?  It does
> seem like there is precedent to do that (in the kernel):
> 
>     % grep -r '%z' arch/
>     arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
>     arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          (0x00.w,%a3,%za4.l*8),%d2:%d3
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          (-0x10.w,%za3,%a4.l*1),%d2:%d3
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          (ea_77_mem+0x00.w,%pc,%za4.l*8),%d2:%d3
>     ...
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc,%zd4.l*1]),%d2:%d3
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%pc],%zd4.l*8,0x20.l),%d2:%d3
>     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc],%d4.l*8),%d2:%d3
>     arch/um/drivers/cow_user.c:             /* Below, %zd is for a size_t value */
>     arch/um/drivers/cow_user.c:                        "limited to %zd characters\n", backing_file,
>     arch/x86/kernel/pci-nommu_64.c:                     "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
> 
> Opinions?

%z is fairly common now-a-days.  The kernel janitors tend to LART
people for not using it rather quickly.

josh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-22 16:55         ` Josh Boyer
@ 2007-10-23  0:26           ` David Gibson
  2007-10-23  1:03             ` Segher Boessenkool
  0 siblings, 1 reply; 8+ messages in thread
From: David Gibson @ 2007-10-23  0:26 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Jon Loeliger

On Mon, Oct 22, 2007 at 11:55:11AM -0500, Josh Boyer wrote:
> On Mon, 22 Oct 2007 11:50:52 -0500
> Jon Loeliger <jdl@jdl.com> wrote:
> 
> > So, like, the other day David Gibson mumbled:
> > > On Sat, Oct 20, 2007 at 10:51:29AM +0200, Andreas Schwab wrote:
> > > > David Gibson <david@gibson.dropbear.id.au> writes:
> > > > 
> > > > > What compiler/platform is this?  I can't off the top of my head think
> > > > > of one where size_t shouldn't be promoted to int automatically.
> > > > 
> > > > Only types narrower than int are subject to integer promotion.
> > > 
> > > Duh, yes.  Sorry.
> > 
> > So, Hmm.  You want the patch as I wrote it applied?
> > Or do you want to use %z in the format instead?  It does
> > seem like there is precedent to do that (in the kernel):
> > 
> >     % grep -r '%z' arch/
> >     arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
> >     arch/alpha/boot/tools/mkbb.c:   fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          (0x00.w,%a3,%za4.l*8),%d2:%d3
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          (-0x10.w,%za3,%a4.l*1),%d2:%d3
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          (ea_77_mem+0x00.w,%pc,%za4.l*8),%d2:%d3
> >     ...
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc,%zd4.l*1]),%d2:%d3
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%pc],%zd4.l*8,0x20.l),%d2:%d3
> >     arch/m68k/ifpsp060/src/itest.S: mulu.l          ([EASTORE.l,%zpc],%d4.l*8),%d2:%d3
> >     arch/um/drivers/cow_user.c:             /* Below, %zd is for a size_t value */
> >     arch/um/drivers/cow_user.c:                        "limited to %zd characters\n", backing_file,
> >     arch/x86/kernel/pci-nommu_64.c:                     "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
> > 
> > Opinions?
> 
> %z is fairly common now-a-days.  The kernel janitors tend to LART
> people for not using it rather quickly.

Yes, I think %z is preferable.  It used to be a glibc (et al)
extension, but I think it's now specified in C99 (we should double
check that).

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
  2007-10-23  0:26           ` David Gibson
@ 2007-10-23  1:03             ` Segher Boessenkool
  0 siblings, 0 replies; 8+ messages in thread
From: Segher Boessenkool @ 2007-10-23  1:03 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev, Jon Loeliger

> Yes, I think %z is preferable.  It used to be a glibc (et al)
> extension, but I think it's now specified in C99 (we should double
> check that).

It is.


Segher

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-10-23  1:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-19 17:43 [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type Jon Loeliger
2007-10-20  7:19 ` David Gibson
2007-10-20  8:51   ` Andreas Schwab
2007-10-20  9:06     ` David Gibson
2007-10-22 16:50       ` Jon Loeliger
2007-10-22 16:55         ` Josh Boyer
2007-10-23  0:26           ` David Gibson
2007-10-23  1:03             ` Segher Boessenkool

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).