Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp95744pxk; Fri, 11 Sep 2020 01:07:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7VDJ0INZTmtc4nweJUJXWjZp5aV1rkeCdouxCjL7tVE7gezY7Qz9ZIY6YGi3ewnj80tkp X-Received: by 2002:a17:907:72c5:: with SMTP id du5mr912850ejc.469.1599811666435; Fri, 11 Sep 2020 01:07:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599811666; cv=none; d=google.com; s=arc-20160816; b=TWobejNPpoBnKzidtkRVnG4Z/9CA1sCRXF6UeNUq406xBeIMz7rqMJExEzUSIDrubB oHRTyVYV2+Am37hEKnAddZZnZBSPsu2cyZh8csLP0elLbtTRpwHYdst1Y1O90/0gvoT+ l6lEr4wqfXQaa2cW0bNN/5XAuGiOr+vO8DdL6rmmUu0bha/rVsZIPz4S8WWLByK+sS+V czgJD8YL8zXLjrhTgo5YWNjin7ArA+tUVhXnO2/uDF/zkLx2s0vrJE6NnMFy9xh/Cqk9 DYKgZeBNkb2J4+Kmj8yA935cJ5ljMQpxJybw6ju1dc+hc4b+FYzr4SSsZBirShkdJAeU 7bPw== 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=p7ZEqYEXNNDQfZTyyRtEq4ezyf6jRAc/A0d3cWdelG8=; b=LCg22kIa4g/S03rQgsiKqCYuA4PCsLJbTEZyOGHp+OtWmZNaKGHwtVl0wSgQIgSpi+ 9fL0+HSIaMrM3/agJqNQJcCHU7hDzO8PtJ0LQJOim/8iXwqgA3Ih5rEqjXW7Hyq3O4+r 9SQFCyA/F8Z5nXqVZaakcIxGrttYuq064FoJGvPzcN/41OjDM8QzUFccYIoU8WN9IXmA SGnzZodddjtpXn62g9h2qUdaf6ofIJ0GH5tPcaFSFFsCac9n/vYwmVEz6m4usJs4iutK tJ4OmP3OkdtPauu6J/Tr8r0gfXLAehGce+XtvP6jE9kvom61BvZwlYeK1J7Fbj1tday9 lnig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Rqyi/pPD"; 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 f4si796213ejt.278.2020.09.11.01.07.23; Fri, 11 Sep 2020 01:07:46 -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="Rqyi/pPD"; 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 S1725883AbgIKIF7 (ORCPT + 99 others); Fri, 11 Sep 2020 04:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgIKIFv (ORCPT ); Fri, 11 Sep 2020 04:05:51 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89AB9C061573; Fri, 11 Sep 2020 01:05:50 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id s13so3542427wmh.4; Fri, 11 Sep 2020 01:05:50 -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=p7ZEqYEXNNDQfZTyyRtEq4ezyf6jRAc/A0d3cWdelG8=; b=Rqyi/pPDFnO111d2wHVM9Tc2uqcMysHCnWXUvkE6Vmna5G8Ok7ekCImU0bFlpVZOXM uW/K98RdI7k26X1gg0pyDNU4luS1UmOvQpTN/1kv9w21xpqK9tgyg/RgF9C9yxwpZ+q4 Wgni6Qw1aUaNdEAcu+4grqxdZLZvJpKWZaZNqa0KMjAbFqm/Z7aKg0idCOrEyPnTKTWg 5H3kBiT5m+KCmQ0+N09280E1TRBrR2VhgkPZQbGtaKcxN6mi10Ap7XyA4gdNqv7oY7G+ 4yGt8qMGfM3/8LL+kYay2VDblqSu4o5BCwowidkOuH72ppxrDjvbftLvjtJwLHXZvlzD /1vA== 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=p7ZEqYEXNNDQfZTyyRtEq4ezyf6jRAc/A0d3cWdelG8=; b=rbl4liZmVHn0jWJJj9x8mfM3u2Bf/hIVz0GFV2YabobusPhXDt6pbn/+vppohUzUli Lx7GHx+LsIv8MrphAXQJxcVF2MwOEvk7qvsZYh76kcIECM/fuoRVG+jaBuaLEBD4h1iB IwKIHGWe1cu8G2fJgeDg3iO7cv08URkmy5v8AXtdCb6YrK/dqR0Ae3azsGVtkfIUnU8f KP1CWXSyu036W2CTfCcFLYOpPzEW2e6zk6v7o709+JERgXPjqxqEi0g7eX8tctzLE4Hd UrO7gjhQIhcViXFFgh2OHi7E/jZNtE+aHzja/uVqlVi4PpMS37sRKPurMIsdYL1LfG8n 0jYw== X-Gm-Message-State: AOAM530v3g2Ju7ll10isQGnlOOsbGDBHReWeZ95puRJZq7Z/j6zFLiI8 wvIcMa0ewNDzHQUtagW6e9xzDU9mKHs= X-Received: by 2002:a7b:cf30:: with SMTP id m16mr957729wmg.0.1599811549027; Fri, 11 Sep 2020 01:05:49 -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 d190sm2596254wmd.23.2020.09.11.01.05.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 01:05:48 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/24] unix.7: Use sizeof() to get buffer size (instead of hardcoding macro name) To: Alejandro Colomar References: <20200910211344.3562-1-colomar.6.4.3@gmail.com> <20200910211344.3562-16-colomar.6.4.3@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: <5629c8df-7ed7-d825-01d9-7b2ed7fbd042@gmail.com> Date: Fri, 11 Sep 2020 10:05:47 +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-16-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 On 9/10/20 11:13 PM, Alejandro Colomar wrote: > Signed-off-by: Alejandro Colomar Thanks, Alex. Patch Applied. Cheers, Michael > --- > man7/unix.7 | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/man7/unix.7 b/man7/unix.7 > index f61b51424..50828a5bc 100644 > --- a/man7/unix.7 > +++ b/man7/unix.7 > @@ -991,7 +991,7 @@ main(int argc, char *argv[]) > > /* Wait for next data packet. */ > > - ret = read(data_socket, buffer, BUFFER_SIZE); > + ret = read(data_socket, buffer, sizeof(buffer)); > if (ret == \-1) { > perror("read"); > exit(EXIT_FAILURE); > @@ -999,16 +999,16 @@ main(int argc, char *argv[]) > > /* Ensure buffer is 0\-terminated. */ > > - buffer[BUFFER_SIZE \- 1] = 0; > + buffer[sizeof(buffer) \- 1] = 0; > > /* Handle commands. */ > > - if (!strncmp(buffer, "DOWN", BUFFER_SIZE)) { > + if (!strncmp(buffer, "DOWN", sizeof(buffer))) { > down_flag = 1; > break; > } > > - if (!strncmp(buffer, "END", BUFFER_SIZE)) { > + if (!strncmp(buffer, "END", sizeof(buffer))) { > break; > } > > @@ -1020,7 +1020,7 @@ main(int argc, char *argv[]) > /* Send result. */ > > sprintf(buffer, "%d", result); > - ret = write(data_socket, buffer, BUFFER_SIZE); > + ret = write(data_socket, buffer, sizeof(buffer)); > if (ret == \-1) { > perror("write"); > exit(EXIT_FAILURE); > @@ -1116,7 +1116,7 @@ main(int argc, char *argv[]) > > /* Receive result. */ > > - ret = read(data_socket, buffer, BUFFER_SIZE); > + ret = read(data_socket, buffer, sizeof(buffer)); > if (ret == \-1) { > perror("read"); > exit(EXIT_FAILURE); > @@ -1124,7 +1124,7 @@ main(int argc, char *argv[]) > > /* Ensure buffer is 0\-terminated. */ > > - buffer[BUFFER_SIZE \- 1] = 0; > + buffer[sizeof(buffer) \- 1] = 0; > > printf("Result = %s\en", buffer); > > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/