While compiling on a 32-bit platform, I saw some GCC warnings about printf arguments not matching the corresponding format specifiers. This patch fixes all of the warnings I saw on that platform.
In file included from ../src/spvw.d:161:0:
../src/spvw_debug.d: In function ‘nobject_out1’:
../src/spvw_debug.d:123:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintWL’ [-Wformat]
../src/spvw_debug.d:124:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:284:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 7 has type ‘long unsigned int’ [-Wformat]
../src/spvw_debug.d: In function ‘bt_out’:
../src/spvw_debug.d:362:11: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:371:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat]
In file included from ../src/spvw.d:3996:0:
../src/spvw_memfile.d: In function ‘loadmem_from_handle’:
../src/spvw_memfile.d:1820:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
In file included from ../src/error.d:502:0:
../src/errunix.d: In function ‘errno_out_low’:
../src/errunix.d:97:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uintL’ [-Wformat]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have attached a second version of the patch. With this version, I see no format specifier warnings on either 32-bit or 64-bit x86. On the other hand, this patch is uglier than my first attempt. :-(
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And this has indeed been done for most of the code that patch touched. However, there are still two instances that I think should be fixed. I will attach a new version of the patch to fix those last two. In src/spvw_fault.d, there is a case where the casting you describe has not been done. In src/spvw_language.d, NULL is passed in a position where a %s format specifier is in use; I suggest passing the string "NULL" in that case.
Format specifier patch
this patch results in these warnings on amd64:
In file included from ../src/spvw.d:161:0:
../src/spvw_debug.d: In function ‘nobject_out1’:
../src/spvw_debug.d:123:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintWL’ [-Wformat]
../src/spvw_debug.d:124:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:188:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:284:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘int’ [-Wformat]
../src/spvw_debug.d:289:13: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 7 has type ‘long unsigned int’ [-Wformat]
../src/spvw_debug.d: In function ‘bt_out’:
../src/spvw_debug.d:362:11: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
../src/spvw_debug.d:371:13: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat]
In file included from ../src/spvw.d:3996:0:
../src/spvw_memfile.d: In function ‘loadmem_from_handle’:
../src/spvw_memfile.d:1820:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uintL’ [-Wformat]
In file included from ../src/error.d:502:0:
../src/errunix.d: In function ‘errno_out_low’:
../src/errunix.d:97:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uintL’ [-Wformat]
Format specifier patch v2
I have attached a second version of the patch. With this version, I see no format specifier warnings on either 32-bit or 64-bit x86. On the other hand, this patch is uglier than my first attempt. :-(
we prefer to solve this problem differently.
basically, we use the longest necessary format and cast the argument to that type.
thanks!
And this has indeed been done for most of the code that patch touched. However, there are still two instances that I think should be fixed. I will attach a new version of the patch to fix those last two. In src/spvw_fault.d, there is a case where the casting you describe has not been done. In src/spvw_language.d, NULL is passed in a position where a %s format specifier is in use; I suggest passing the string "NULL" in that case.