On Wed, Oct 09, 2024 at 03:30:14PM +0200, Rasmus Villemoes wrote: ... > Rather than the struct assignments, I think it's easier to read if you > just do > > struct range r; > > r.start = 0xc0ffee00ba5eba11; > r.end = r.start; > ... > > r.start = 0xc0ffee; > r.end = 0xba5eba11; > ... > > which saves two lines per test and for the first one makes it more > obvious that the start and end values are identical. With DEFINE_RANGE() it will save even more lines! .. > > + if (buf < end) > > + *buf++ = '-'; > > No. Either all your callers pass a (probably stack-allocated) buffer > which is guaranteed to be big enough, in which case you don't need the > "if (buf < end)", or if some callers may "print" directly to the buffer > passed to vsnprintf(), the buf++ must still be done unconditionally in > order that vsnprintf(NULL, 0, ...) [used by fx kasprintf] can accurately > determine how large the output string would be. Ah, good catch, I would add... > So, either > > *buf++ = '-' > > or > > if (buf < end) > *buf = '-'; > buf++; ...that we use rather ++buf in such cases, but it doesn't really matter. > Please don't mix the two. -- With Best Regards, Andy Shevchenko