[systemd-devel] [systemd-commits] src/network

Lennart Poettering lennart at poettering.net
Mon Nov 25 17:30:20 PST 2013


On Mon, 25.11.13 19:12, Dave Reisner (d at falconindy.com) wrote:

> 
> On Tue, Nov 26, 2013 at 12:40:05AM +0100, Lennart Poettering wrote:
> > On Mon, 25.11.13 15:20, Dave Reisner (dreisner at kemper.freedesktop.org) wrote:
> > 
> > >     uint64_t can be formatted correctly with %ju, rather than casting to
> > >     unsigned and potentially losing accuracy.
> > 
> > Oh, shouldn't we be careful with that? %j is for intmax_t. Which might
> > or might not be int64_t. Given that int128_t is already on the horizon
> > (newer gcc already support __int128 on 64bit machines...), I wouldn't be
> > surprised if intmax_t is growing to 128bit eventually.
> 
> How do you change sizeof(uintmax_t) without breaking ABI?

Well, there's prior art for botching such type size changes up, they
could just take inspiration from that and fail awesomely there too:
off_t...

> > Format strings don't really have a nice way to print fixed-size
> > integers I fear... the only stuff that is correct is the "PRIu64" macro,
> > but that's fricking ugly...
> > 
> > I think PRIu64 is still a better, more future-proof option than %j though...
> 
> Assuming uintmax_t really does increase in size, no type promotion, and
> someone actually manages to conjure up a system with 4 billion
> interfaces...

Well, the latter only matters on LE machines. On BE you'd be immediately
broken...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list