Re: [PATCH] Btrfs-progs: satisfy compiler and change printf modifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 14.11.2011 16:30, schrieb Christian Parpart:
> On Mon, Nov 14, 2011 at 4:24 PM, Arnd Hannemann <arnd@xxxxxxxxxx <mailto:arnd@xxxxxxxxxx>> wrote:
> 
>     One-liner which fixes the gcc warning:
>     warning: format '%u' expects argument of type 'unsigned int',
>     but argument 3 has type 'long unsigned int' [-Wformat]
> 
> 
> [snip] 
> 
>     -               printf("Size is %u, needs to be %u, slot %d\n", item_size,
>     +               printf("Size is %u, needs to be %zu, slot %d\n", item_size,
>                           sizeof(*ei), path->slots[0]);
> 
> 
> shouldn't it be %lu then (instead of %zu) ? 

No, the return type of sizeof() is size_t which is of different size on different
architectures (eg. amd64 versus i386)

If %lu would be used, there would be a warning when compiled on an architecture where
long is 32 bit.

Best regards,
Arnd

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux