Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp90245pxk; Fri, 11 Sep 2020 00:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIZiCc42g+JsG2LjUfmP/sYu+FrMF5kwKR+Fbh0NLak3aIsr2vth5vQb7VjY/eP+gV10HL X-Received: by 2002:a17:906:f9d8:: with SMTP id lj24mr860840ejb.379.1599810976798; Fri, 11 Sep 2020 00:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599810976; cv=none; d=google.com; s=arc-20160816; b=QkwRVgH5BSMQffnBqAsDz6j5eW+thRupq3u7Ho65j3MSHQ6dawtCZmNymBTLvsu9AC 63FFCVhSO5eiPw7S+uoh2x51YNcOhvY0OUKRbHIZEgmjL/IPeYvAG9nSW3TnLZn6I4Gj n/StlEzvHkzEbTd/uwBW0o1Dd2mO7C2H83RX+c4CXYlXBU03W/7VKy8KsVAnmF8PMjV1 IEPG5YTxyq+LOurbriDFSYOj/xkOmUNp5olGsD0qjEze6bHhfBEbgrMWDVfQjt0zmeCm k3s2oShGmVTuwrD8qJHiJ0hKkcCHyZeUx16B85hegVuEIn7ZYNNUTyRDfu0CLKerzVW7 kQeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:dkim-signature; bh=yefDfyzMV3D0zYfLubpfnreXDIUekY8KZxUMEU76Oe4=; b=jU/mNkf96fRGrzw53lAJBhhNGudrizN76KjyozSkLfACCiRXCmsVwXzY3qdoEr2+An IdL580PX81QLLIHv1IP8tGM/WFg8L/MeDpZCJ3EKaPpLF1KuzFVrDsh67hF/kkNdpEfQ S2yOS/lSyy+6o+o1Us2Z1+/UHMINHe9OBXADsYc/IYqbQdM0+OQBE25M0VdtmQIGOpjD 2PAjvEzZQVmNTZn4OopQi1cafZB1BncISQJv/WrWjwU8UPUkEAHAiuCI8LpJrm6xrRZf g1+c1SGghFr2OCjQWdJ76jNTVJ7L/kJbEE4EsaTXz8GmdPPSMVb+siul8c4+QhQLIw1z YHIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nsgmUcQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si784110ejt.59.2020.09.11.00.55.52; Fri, 11 Sep 2020 00:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nsgmUcQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725784AbgIKHy6 (ORCPT + 99 others); Fri, 11 Sep 2020 03:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgIKHyt (ORCPT ); Fri, 11 Sep 2020 03:54:49 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1CAC061573; Fri, 11 Sep 2020 00:54:48 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id m6so10531825wrn.0; Fri, 11 Sep 2020 00:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yefDfyzMV3D0zYfLubpfnreXDIUekY8KZxUMEU76Oe4=; b=nsgmUcQTca2wsBY+8niyqzwafdlFRwS90MFzZ2EgeLZCHdr6dglWpoC23+BzH90cNl sypAd81PKLiT52nRhEe2HNu9EdlTl/3qxxFDJ8j4ZnNk51U/6zREhRy4DYeW251H7JIw +a3DygUFtUT09n+sTwiGuoTdIvLg4wE/vHW2NyfMdM4Zjl+95DbgTXz5+s3cNbqSfSM4 SVRCHYvzKHZ7UNmxMHgMIjesMdsSa1d6GDKm2ZNe2wcvRdoD4+NV4VmiHjRNS3A6PMxO Hdb1HvcaL4lclzgZkl1ntkSHVTp1d9UU2+k9f82gR7S197gHYWifoqfKbeA/3RO9H2fk KzoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yefDfyzMV3D0zYfLubpfnreXDIUekY8KZxUMEU76Oe4=; b=IWy1NnKZuyD6+nmuZllH/OcnCpWAoaKIYBTVW+LnVXp+jKqHZRlqhmWx/aKod+sLWE 0k5rYO+K8Rhn2nhU/BNfESydZoc3NkbdqnKhsjoO2efJsnQIgoI/z/TNjewBVzrFgd1W QhTLDBOHopRQfJ1PcNBh4bAmSn38TMek/hT9TqSbWDXIDQTw6QpSHGPFXQZxNz3M+gHH s+8DcjWXV+6sDL7xo2qqzYYoGEuHxbMaDQ0pq3jVyqq+reX6LEkNSzx3MixWmtS020Tv qytrI2Pe7FNq/XU06bMDf/WqeHi+9s4cQ+Uqxo2v9SofHODgDlHw8ZiLo/ColElALmw3 fu9g== X-Gm-Message-State: AOAM530GSEvfrLLo8eKd7Anf1uqAJvuVzjilseI7rJmFwyw6Gz/FQG7R o/6xIwydGIsajjsjEHwQCO4Ab+P6sVk= X-Received: by 2002:adf:cf01:: with SMTP id o1mr719399wrj.421.1599810886868; Fri, 11 Sep 2020 00:54:46 -0700 (PDT) Received: from ?IPv6:2001:a61:2479:6801:d8fe:4132:9f23:7e8f? ([2001:a61:2479:6801:d8fe:4132:9f23:7e8f]) by smtp.gmail.com with ESMTPSA id q4sm3024523wru.65.2020.09.11.00.54.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 00:54:46 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 23/24] select_tut.2: Use MAX(a, b) from To: Alejandro Colomar References: <20200910211344.3562-1-colomar.6.4.3@gmail.com> <20200910211344.3562-24-colomar.6.4.3@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: Date: Fri, 11 Sep 2020 09:54:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200910211344.3562-24-colomar.6.4.3@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On 9/10/20 11:13 PM, Alejandro Colomar wrote: > Signed-off-by: Alejandro Colomar 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 > #include > #include > +#include /* Definition of MAX(a, b) */ > #include > #include > #include > @@ -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/