Merged
Conversation
On 32bit arches where time_t is defined as long int and where
sizeof(long)==sizeof(int), PRI_TIME is PRIu32 which is "u" and gcc warns about
ignoring the long part of the integer type. There is no problem besides the
warning.
Use "lu" in the above conditions and PRIu32 in all other 32bit time_t cases.
udevadm-monitor.c: In function ‘print_device’:
udevadm-monitor.c:49:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t’ {aka ‘long int’} [-Wformat=]
49 | printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
| ^~~~~~~~
50 | source,
51 | ts.tv_sec, ts.tv_nsec/1000,
| ~~~~~~~~~
| |
| __time_t {aka long int}
In file included from ../../src/shared/macro.h:26,
from udev.h:26,
from udevadm-monitor.c:35:
/usr/include/inttypes.h:104:19: note: format string is defined here
104 | # define PRIu32 "u"
This reverts commit b1de2b7.
On 32bit arches where time_t is defined as long int and where
sizeof(long)==sizeof(int), PRI_TIME is PRIu32 which is "u" and gcc warns about
ignoring the long part of the integer type. There is no problem besides the
warning.
Upcast time_t to 64bit and get rid of PRI_TIME and configure checks
udevadm-monitor.c: In function ‘print_device’:
udevadm-monitor.c:49:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t’ {aka ‘long int’} [-Wformat=]
49 | printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
| ^~~~~~~~
50 | source,
51 | ts.tv_sec, ts.tv_nsec/1000,
| ~~~~~~~~~
| |
| __time_t {aka long int}
In file included from ../../src/shared/macro.h:26,
from udev.h:26,
from udevadm-monitor.c:35:
/usr/include/inttypes.h:104:19: note: format string is defined here
104 | # define PRIu32 "u"
ArsenArsen
approved these changes
Jun 11, 2022
Collaborator
ArsenArsen
left a comment
There was a problem hiding this comment.
what an ugly issue, the fix seems reasonable (AFAIK 64 bit arithmetic isn't a problem on any CPUs, so this cast shouldn't be that problematic, so unless someone knows more about non-amd64 cpus, this seems alright)
kaniini
approved these changes
Jun 12, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On 32bit arches where time_t is defined as long int and where
sizeof(long)==sizeof(int), PRI_TIME is PRIu32 which is "u" and gcc warns about
ignoring the long part of the integer type. There is no problem besides the
warning.
Use "lu" in the above conditions and PRIu32 in all other 32bit time_t cases.