public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* bug in roundup(3) from <sys/param.h>
@ 2023-01-17 19:16 Wilco Dijkstra
  2023-01-17 19:50 ` Alejandro Colomar
  2023-01-17 20:11 ` Paul Eggert
  0 siblings, 2 replies; 7+ messages in thread
From: Wilco Dijkstra @ 2023-01-17 19:16 UTC (permalink / raw)
  To: Adhemerval Zanella, Alejandro Colomar (man-pages); +Cc: 'GNU C Library'

Hi,

> I really won't bother with this interface, since potentially changing it
> might generate more potentially breakage than improvements.

The typical use-case is rounding up a pointer to align it or increasing a buffer
to be allocated. There is no chance of overflow in these cases since you will
never have pointers that close to SIZE_MAX or get buffers close to the maximum
memory size. And adding saturation would mean we didn't do what was requested
either...

So it seems best to state it only works on unsigned values (with y > 0 since division
by zero is undefined behaviour of course) and it's implementation defined whether
overflow wraps or saturates.

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-17 22:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 19:16 bug in roundup(3) from <sys/param.h> Wilco Dijkstra
2023-01-17 19:50 ` Alejandro Colomar
2023-01-17 20:11 ` Paul Eggert
2023-01-17 20:13   ` Alejandro Colomar
2023-01-17 20:24     ` [RFC] roundup.3: New page documenting roundup(3) (was: bug in roundup(3) from <sys/param.h>) Alejandro Colomar
2023-01-17 21:53       ` Paul Eggert
2023-01-17 22:29         ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).