libera/#eudev/ Friday, 2022-06-10

bb|hcbHeads up: 3.2.12-pre2 is there, thanks to Arsen for helping with that :)02:12
bb|hcbThere is one more problem with 32bit build only: src/udev/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=]02:15
sam_is there a bug for that?02:20
bb|hcbI just saw it. My expectation is that in old times time_t was 32bit while now it is 64bit even on i386/armel/etc02:21
bb|hcbI see that there is autoconf check for the sizeof(time_t) and format is selected based on that, most probably the test is wrong02:21
sam_it depends on libc decisions, but yes, more or less02:22
sam_it's more that %u isn't right. Ithink02:23
sam_need to use one of the fancy LL ones02:23
bb|hcb#if SIZEOF_TIME_T == 802:23
bb|hcb#  define PRI_TIME PRIi6402:23
bb|hcb#elif SIZEOF_TIME_T == 402:23
bb|hcb#  define PRI_TIME PRIu3202:23
bb|hcb#else02:24
bb|hcb#  error Unknown time_t size02:24
bb|hcb#endif02:24
bb|hcb... and the above looks proper, i am now checking on 32bit vm02:24
sam_yes, that looks right -- just use PRI_TIME02:24
sam_but remember, it depends on glibc (2.35 or newer), and for musl, they had 64-bit time since 1.2 iirc02:24
sam_and for glibc, it's still optional (ew)02:24
sam_but yeah, that check looks fine, so jsut use PRI_TIME02:24
bb|hcbchecking size of time_t... 402:25
sam_so you either have an older glibc (<2.35), or you're not building with -D_TIME_BITS=64 and friends (which is fine)02:26
bb|hcbtrue - old glibc 2.31, long int is 32bit on i386, time_t is also long int; gcc borks about %u vs %lu for long int...02:40
sam_:)02:42
sam_just do PRI_TIME, really02:42
sam_that's exactly the right fix02:42
bb|hcbit is PRI_TIME, but that is defined as PRIu32 which in turn is "u"; gcc wants "lu"02:44
bb|hcbboth int and long int are 32bit, but gcc warns that the format is ignoring the long part, thus loosing portability02:45
bb|hcbon a different arch int and long int may have different size and it would be quite the guesswork to get it proper02:48
sam_oh right02:48
bb|hcbi can't guess about a better way than checking sizeof(long) and using "lu" in case it is 4 bytes instead of PRIu32 and keeping PRIu32 if they are different...02:53
bb|hcbhttps://github.com/eudev-project/eudev/pull/23303:12
sam_https://github.com/glaubitz/systemd/blob/master/src/basic/format-util.h#L2003:35
sam_sorry, https://github.com/systemd/systemd/blob/main/src/basic/format-util.h#L2103:36
bb|hcbexactly what i do not like - this is based on knowledge that time_t is long, correct me if i am wrong but what guarantees that time_t is long?03:39
sam_let's see03:41
sam_I think we have two options03:44
sam_I think we can cast the input to int64_t03:44
sam_or we can use strftime03:45
bb|hcbmaybe the cast to int64_t seems most appropriate - udevadm monitor's performace wouldn't be affected in a measurable way because of that04:18
sam_that's my preference too04:48

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!