Re: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/12/21 1:43 PM, Alejandro Colomar via Libc-alpha wrote:

+If any of the arguments is of a floating-point type,

"any" -> "either"

+these macros shouldn't be used

That's too strong. It's often OK to use MAX and MIN on floating point arguments.

+The arguments may be evaluated more than once,
+and their types might be promoted to a common type
+if both arguments aren't of the same type.

This is muddy. It should state clearly that even if A and B are both integers, MAX (a, b) might not return their maximum. For example, on a typical C platform today, MAX (-1, 2147483648) returns 4294967295 and MIN (-1, 2147483648) returns 2147483648.

Also, the man page shouldn't require the arguments to be evaluated at least once. It's possible to implement MAX so that it sometimes doesn't evaluate one argument, and the documentation shouldn't preclude such an implementation.

The man page should more specifically mention that although MIN and MAX are defined <sys/param.h> on GNU platforms, other platforms define them elsewhere or not at all.

+These macros return the value of one of their arguments,

Unfortunately they don't necessarily do that, as shown in the MAX example above.

I suggest looking at the remarks about MAX and MIN that are made here, and incorporating the useful parts of these remarks into the man page:

https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/minmax.h








[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux