Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3813385pxk; Tue, 29 Sep 2020 06:59:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlUEB4IqKNllj6sDcdFBPhHB7+yjG2ks7PeHw5AhaFp2mEvYWqYchY8gPY4SFTwC1T6pLU X-Received: by 2002:a17:906:f92:: with SMTP id q18mr3877829ejj.237.1601387956370; Tue, 29 Sep 2020 06:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601387956; cv=none; d=google.com; s=arc-20160816; b=wJ0yGBnnVHFj+BkmgBqZlpbBqJjX/KtgCbpTkfc8s8t5vFwewQDOdrjYejyKtYCCxj mSjp3FmSxP4j40fyqF1PAA8W0f51KSEnEGnSCR0pZBAkSoPhrEt/MaUtHZ5Py3YQZhIk zI0+K/iVGzTRALQ/AmlpGn6UW00ibkI2wncrC+Nb+4x4emv9OM9RAob6Z6buYUCOOCQ8 HCOjmGxQXHVHv0IQiLyvaxybxrwGHx5jzO6RqjtSJiAon88oZSvu4VOrd7VfYIzXOLu6 LCVsAr0y5BeuZPoeafmeSvqJRwYjFVXReDDT96usPpXJdF89qYLy50QJdcD9p8EoQ737 v+Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=m+GzUJ/cc3gOU8YTK7hhp/1AHmJaFJDTSpVKrvN9jyI=; b=X9EC+dwfzqnA+U+fC69bH4Ci/x1wcoC8Fkt3dtiZufDBWrqKqtesKWxATUIF5kF43p nCO1Z475WWmze+FGGA1sq+97zVl7TlNr4qVGT+sUyujTdxziEET6sd1PaRccB3MnCfQ7 9RjqmZGvVV2QZ1qYY551sbbiUlmNMVzE7xDcJ57t4V/p6+fIVVI2NvOyZSLLLDf0JYAK KsxDTkZLNd/MgHEAgcL67itrxroWkgd1rAWpDks0SIo4VymExPSZ4Wm4smOOO7eHKWxq 5IDa33n33NjcOK55hFbuRIkFmILRBQFe9nE51hjgt/4rl42U+882Ed5mt662lptV9uvz +tVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FcA34252; 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 do18si2561668ejc.13.2020.09.29.06.58.52; Tue, 29 Sep 2020 06:59: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=FcA34252; 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 S1729147AbgI2N50 (ORCPT + 99 others); Tue, 29 Sep 2020 09:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728461AbgI2N5Z (ORCPT ); Tue, 29 Sep 2020 09:57:25 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F258C061755; Tue, 29 Sep 2020 06:57:25 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id k10so5523652wru.6; Tue, 29 Sep 2020 06:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=m+GzUJ/cc3gOU8YTK7hhp/1AHmJaFJDTSpVKrvN9jyI=; b=FcA34252V91S22zkWLVguCgoC9Q0JgorvJMPcSkMBwPSX9dQP2sa2jJczIvlR8+zwo 6xsovhOrwDSD3IMzUqcXxeKiGhE7VZ4v+1oIL6+w16e8pyQGEuRMSD3dODzDoscChMcx lSfFSG3PsMAj9hc68+QAEUNJxPgaB4Tzxnk3y6/INHtyYGaxqOZ9RbOxrRbalM8Jl5ed aDUE0zxl4vc8JaeAWN+dPSjtCFmCACwXdqLjZCwzsVM1Dzv5/yxecFhqsa7GZmRIG4st DKWu4I6fg6cXvW2Z+olhX2cbKiidjWM5wbNpB0AUytithNuoQAS3AhD8UG8w/kGQoS7E knfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m+GzUJ/cc3gOU8YTK7hhp/1AHmJaFJDTSpVKrvN9jyI=; b=H9GrUSaD/j1MQde4f7CgOHRrj7mM088vLLVdloygKG4LvRDzmO86djnGVyXngOnJNc 4YEVOOPaR6KrFh6IN0z6NbpVXaslRw3AEgnkUi+g6TxGsObbj7CXpjfTVJvWcxLd7bs9 fb8VtR7Fc0rKNc43DxgcOKjONnXZZqpQNOm/6IAAmLW6exP99abQ4OErj+qcU7MArceY +R6q72FBSTeoWYOPSm1L+7E5Zj11u92rOxrJ6nUyF4GBV/DOkXIw2fGfoHbUhCsddcv4 Dmudu1d2hYC2WVNJtMV8hKZsupHp84Dv6U638uJXh8RBBU1D5Xq8V6YybPSSEfdpBAQi T8LQ== X-Gm-Message-State: AOAM533ZIBzpMWn4Xoz15I71iYnsjYb6FaZtaAirWWkw7B7jEA1P/Mq7 Bog8Pn9qrAHZV4tmgJMz/qRMH4o4tsY6Tw== X-Received: by 2002:adf:ffc3:: with SMTP id x3mr4425714wrs.290.1601387843782; Tue, 29 Sep 2020 06:57:23 -0700 (PDT) Received: from [192.168.1.143] ([170.253.60.68]) by smtp.gmail.com with ESMTPSA id l18sm6286194wrp.84.2020.09.29.06.57.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Sep 2020 06:57:23 -0700 (PDT) Subject: Re: [PATCH 12/24] getgrent_r.3: Use sizeof() to get buffer size (instead of hardcoding macro name) To: mtk.manpages@gmail.com Cc: Stefan Puiu , lnx-man , lkml References: <20200910211344.3562-1-colomar.6.4.3@gmail.com> <20200910211344.3562-13-colomar.6.4.3@gmail.com> <7dd2ab72-3ce7-1f50-229a-e663c3df2dcd@gmail.com> From: Alejandro Colomar Message-ID: <3a59be19-252e-0285-6d9f-5f9a9f0388b5@gmail.com> Date: Tue, 29 Sep 2020 15:57:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-09-29 15:38, Michael Kerrisk (man-pages) wrote: >> 2.- Use sizeof() everywhere, and the macro for the initializer. >> >> pros: >> - It is valid as long as the buffer is an array. >> cons: >> - If the code gets into a function, and the buffer is then a pointer, >> it will definitively produce a silent bug. > > Sigh! I just did exactly the last point in a test program I've been writing... > > M > Hmmm, maybe you would like to comment on this LKML thread I started yesterday: https://lore.kernel.org/lkml/71c25cb0-9fa2-4e97-c93c-44eadfd781fb@gmail.com Concretely, point 4 is about this. I'd push 'array_bytes()' to all "libc"s I can, so that it's then common enough to use it everywhere, even in the man. I'd also recommend reading this StackOverflow answer I wrote last year: https://stackoverflow.com/a/57537491/6872717 Cheers, Alex