lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ede06e4b-7217-1315-6035-9116df9b02c0@gmail.com>
Date:   Fri, 11 Sep 2020 09:54:45 +0200
From:   "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
To:     Alejandro Colomar <colomar.6.4.3@...il.com>
Cc:     mtk.manpages@...il.com, linux-man@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 23/24] select_tut.2: Use MAX(a, b) from <sys/param.h>

Hi Alex,

On 9/10/20 11:13 PM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@...il.com>

I'm reluctant to apply this, because MAX() is not a standard
macro. I suppose it may not be present on some other UNIX
systems. You thoughts?

Cheers,

Michael

> ---
>  man2/select_tut.2 | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/man2/select_tut.2 b/man2/select_tut.2
> index f683dd49d..d23683d75 100644
> --- a/man2/select_tut.2
> +++ b/man2/select_tut.2
> @@ -354,6 +354,7 @@ from one TCP port to another.
>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <unistd.h>
> +#include <sys/param.h>      /* Definition of MAX(a, b) */
>  #include <sys/select.h>
>  #include <string.h>
>  #include <signal.h>
> @@ -364,9 +365,6 @@ from one TCP port to another.
>  
>  static int forward_port;
>  
> -#undef max
> -#define max(x,y) ((x) > (y) ? (x) : (y))
> -
>  static int
>  listen_socket(int listen_port)
>  {
> @@ -483,7 +481,7 @@ main(int argc, char *argv[])
>          FD_ZERO(&writefds);
>          FD_ZERO(&exceptfds);
>          FD_SET(h, &readfds);
> -        nfds = max(nfds, h);
> +        nfds = MAX(nfds, h);
>  
>          if (fd1 > 0 && buf1_avail < BUF_SIZE)
>              FD_SET(fd1, &readfds);
> @@ -499,11 +497,11 @@ main(int argc, char *argv[])
>  
>          if (fd1 > 0) {
>              FD_SET(fd1, &exceptfds);
> -            nfds = max(nfds, fd1);
> +            nfds = MAX(nfds, fd1);
>          }
>          if (fd2 > 0) {
>              FD_SET(fd2, &exceptfds);
> -            nfds = max(nfds, fd2);
> +            nfds = MAX(nfds, fd2);
>          }
>  
>          ready = select(nfds + 1, &readfds, &writefds, &exceptfds, NULL);
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ