All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Alejandro Colomar <alx.manpages@gmail.com>, mtk.manpages@gmail.com
Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: Re: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN()
Date: Wed, 12 May 2021 14:17:54 -0700	[thread overview]
Message-ID: <ca33b912-2273-b1d0-57b8-b94a19822bfd@cs.ucla.edu> (raw)
In-Reply-To: <20210512204311.19399-1-alx.manpages@gmail.com>

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






  parent reply	other threads:[~2021-05-12 21:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 20:43 [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN() Alejandro Colomar
2021-05-12 20:56 ` [PATCH v2] " Alejandro Colomar
2021-05-12 20:59   ` Alejandro Colomar (man-pages)
2021-05-12 21:17 ` Paul Eggert [this message]
2021-05-12 22:32   ` [PATCH] " Alejandro Colomar (man-pages)
2021-05-12 22:39     ` Paul Eggert
2021-05-12 22:51       ` [PATCH v3] MAX.3, MIN.3: New pages " Alejandro Colomar
2021-06-12  8:35         ` Ping: " Alejandro Colomar (man-pages)
2021-06-20  2:39         ` Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca33b912-2273-b1d0-57b8-b94a19822bfd@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.