bb|hcb | Heads up: 3.2.12-pre2 is there, thanks to Arsen for helping with that :) | 02:12 |
---|---|---|
bb|hcb | There 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|hcb | I just saw it. My expectation is that in old times time_t was 32bit while now it is 64bit even on i386/armel/etc | 02:21 |
bb|hcb | I see that there is autoconf check for the sizeof(time_t) and format is selected based on that, most probably the test is wrong | 02:21 |
sam_ | it depends on libc decisions, but yes, more or less | 02:22 |
sam_ | it's more that %u isn't right. Ithink | 02:23 |
sam_ | need to use one of the fancy LL ones | 02:23 |
bb|hcb | #if SIZEOF_TIME_T == 8 | 02:23 |
bb|hcb | # define PRI_TIME PRIi64 | 02:23 |
bb|hcb | #elif SIZEOF_TIME_T == 4 | 02:23 |
bb|hcb | # define PRI_TIME PRIu32 | 02:23 |
bb|hcb | #else | 02:24 |
bb|hcb | # error Unknown time_t size | 02:24 |
bb|hcb | #endif | 02:24 |
bb|hcb | ... and the above looks proper, i am now checking on 32bit vm | 02:24 |
sam_ | yes, that looks right -- just use PRI_TIME | 02:24 |
sam_ | but remember, it depends on glibc (2.35 or newer), and for musl, they had 64-bit time since 1.2 iirc | 02:24 |
sam_ | and for glibc, it's still optional (ew) | 02:24 |
sam_ | but yeah, that check looks fine, so jsut use PRI_TIME | 02:24 |
bb|hcb | checking size of time_t... 4 | 02: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|hcb | true - 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, really | 02:42 |
sam_ | that's exactly the right fix | 02:42 |
bb|hcb | it is PRI_TIME, but that is defined as PRIu32 which in turn is "u"; gcc wants "lu" | 02:44 |
bb|hcb | both int and long int are 32bit, but gcc warns that the format is ignoring the long part, thus loosing portability | 02:45 |
bb|hcb | on a different arch int and long int may have different size and it would be quite the guesswork to get it proper | 02:48 |
sam_ | oh right | 02:48 |
bb|hcb | i 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|hcb | https://github.com/eudev-project/eudev/pull/233 | 03:12 |
sam_ | https://github.com/glaubitz/systemd/blob/master/src/basic/format-util.h#L20 | 03:35 |
sam_ | sorry, https://github.com/systemd/systemd/blob/main/src/basic/format-util.h#L21 | 03:36 |
bb|hcb | exactly 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 see | 03:41 |
sam_ | I think we have two options | 03:44 |
sam_ | I think we can cast the input to int64_t | 03:44 |
sam_ | or we can use strftime | 03:45 |
bb|hcb | maybe the cast to int64_t seems most appropriate - udevadm monitor's performace wouldn't be affected in a measurable way because of that | 04:18 |
sam_ | that's my preference too | 04:48 |
Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!