{"thread":{"id":"21108","subject":"Re: [PATCH] Fix some printf format warnings","startedAt":"2009-09-30T18:49:24Z","lastAt":"2009-10-01T17:29:34Z","messageCount":2,"participants":["Nicolas Pitre","Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"124094","messageId":"4AC3A834.6070208@ramsay1.demon.co.uk","threadId":"21108","inReplyTo":null,"subject":"[PATCH] Fix some printf format warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2009-09-30T18:49:24Z","receivedAt":"2009-09-30T18:49:24Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\ncommit 51ea551 (\"make sure byte swapping is optimal for git\"\n2009-08-18) introduced a \"sane definition for ntohl()/htonl()\"\nfor use on some GNU C platforms. Unfortunately, for some of\nthese platforms, this results in the introduction of a problem\nwhich is essentially the reverse of a problem that commit 6e1c234\n(\"Fix some warnings (on cygwin) to allow -Werror\" 2008-07-3) was\nintended to fix.\n\nIn particular, on platforms where the uint32_t type is defined\nto be unsigned long, the return type of the new ntohl()/htonl()\nis causing gcc to issue printf format warnings, such as:\n\n    warning: long unsigned int format, unsigned int arg (arg 3)\n\n(nine such warnings, covering six different files). The earlier\ncommit (6e1c234) needed to suppress these same warnings, except\nthat the types were in the opposite direction; namely the format\nspecifier (\"%u\") was 'unsigned int' and the argument type (ie the\nreturn type of ntohl()) was 'long unsigned int' (aka uint32_t).\n\nIn order to suppress these warnings, the earlier commit used the\n(C99) PRIu32 format specifier, since the definition of this macro\nis suitable for use with the uint32_t type on that platform.\nThis worked because the return type of the (original) platform\nntohl()/htonl() functions was uint32_t.\n\nIn order to suppress these warnings, we change the return type of\nthe new byte swapping functions in the compat/bswap.h header file\nfrom 'unsigned int' to uint32_t.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n compat/bswap.h |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/bswap.h b/compat/bswap.h\nindex 7246a12..5cc4acb 100644\n--- a/compat/bswap.h\n+++ b/compat/bswap.h\n@@ -9,7 +9,7 @@\n  * Default version that the compiler ought to optimize properly with\n  * constant values.\n  */\n-static inline unsigned int default_swab32(unsigned int val)\n+static inline uint32_t default_swab32(uint32_t val)\n {\n \treturn (((val & 0xff000000) >> 24) |\n \t\t((val & 0x00ff0000) >>  8) |\n@@ -20,7 +20,7 @@ static inline unsigned int default_swab32(unsigned int val)\n #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))\n \n #define bswap32(x) ({ \\\n-\tunsigned int __res; \\\n+\tuint32_t __res; \\\n \tif (__builtin_constant_p(x)) { \\\n \t\t__res = default_swab32(x); \\\n \t} else { \\\n-- \n1.6.4\n"},{"id":"124093","messageId":"alpine.LFD.2.00.0910011329060.4997@xanadu.home","threadId":"21108","inReplyTo":"4AC3A834.6070208@ramsay1.demon.co.uk","subject":"Re: [PATCH] Fix some printf format warnings","fromName":"Nicolas Pitre","fromEmail":"nico@fluxnic.net","sentAt":"2009-10-01T17:29:34Z","receivedAt":"2009-10-01T17:29:34Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Wed, 30 Sep 2009, Ramsay Jones wrote:\n\n> \n> commit 51ea551 (\"make sure byte swapping is optimal for git\"\n> 2009-08-18) introduced a \"sane definition for ntohl()/htonl()\"\n> for use on some GNU C platforms. Unfortunately, for some of\n> these platforms, this results in the introduction of a problem\n> which is essentially the reverse of a problem that commit 6e1c234\n> (\"Fix some warnings (on cygwin) to allow -Werror\" 2008-07-3) was\n> intended to fix.\n> \n> In particular, on platforms where the uint32_t type is defined\n> to be unsigned long, the return type of the new ntohl()/htonl()\n> is causing gcc to issue printf format warnings, such as:\n> \n>     warning: long unsigned int format, unsigned int arg (arg 3)\n> \n> (nine such warnings, covering six different files). The earlier\n> commit (6e1c234) needed to suppress these same warnings, except\n> that the types were in the opposite direction; namely the format\n> specifier (\"%u\") was 'unsigned int' and the argument type (ie the\n> return type of ntohl()) was 'long unsigned int' (aka uint32_t).\n> \n> In order to suppress these warnings, the earlier commit used the\n> (C99) PRIu32 format specifier, since the definition of this macro\n> is suitable for use with the uint32_t type on that platform.\n> This worked because the return type of the (original) platform\n> ntohl()/htonl() functions was uint32_t.\n> \n> In order to suppress these warnings, we change the return type of\n> the new byte swapping functions in the compat/bswap.h header file\n> from 'unsigned int' to uint32_t.\n> \n> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n\nAcked-by: Nicolas Pitre <nico@fluxnic.net>\n\n\n> ---\n>  compat/bswap.h |    4 ++--\n>  1 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/compat/bswap.h b/compat/bswap.h\n> index 7246a12..5cc4acb 100644\n> --- a/compat/bswap.h\n> +++ b/compat/bswap.h\n> @@ -9,7 +9,7 @@\n>   * Default version that the compiler ought to optimize properly with\n>   * constant values.\n>   */\n> -static inline unsigned int default_swab32(unsigned int val)\n> +static inline uint32_t default_swab32(uint32_t val)\n>  {\n>  \treturn (((val & 0xff000000) >> 24) |\n>  \t\t((val & 0x00ff0000) >>  8) |\n> @@ -20,7 +20,7 @@ static inline unsigned int default_swab32(unsigned int val)\n>  #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))\n>  \n>  #define bswap32(x) ({ \\\n> -\tunsigned int __res; \\\n> +\tuint32_t __res; \\\n>  \tif (__builtin_constant_p(x)) { \\\n>  \t\t__res = default_swab32(x); \\\n>  \t} else { \\\n> -- \n> 1.6.4\n> \n> \n"}]}