Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqpeq-00DDDD-5C for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Sep 2024 08:03:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sqpep-005mon-69 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Sep 2024 08:03:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqpeo-005moY-SQ for pgsql-hackers@lists.postgresql.org; Wed, 18 Sep 2024 08:03:26 +0000 Received: from fout1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqpem-001lte-2Q for pgsql-hackers@lists.postgresql.org; Wed, 18 Sep 2024 08:03:25 +0000 Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 3D94E138023D; Wed, 18 Sep 2024 04:03:23 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Wed, 18 Sep 2024 04:03:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1726646603; x=1726733003; bh=jt0Ly27jjuF7ZBTrE7jt9dB2J6K2Z0XSvMhGauyifwQ=; b= Guun7FibPWSTkUZVqKh2+yRejgKUB8OC5yiij/E8uwTiJkAtzdwjD1nUJoMrtCEm VQ8LoFSQUwSsVkOAY6ZaUalOc74yl+oVPKHPcunLieM1V+NNqGCq2rm11Mau37L9 liBPsP9SQG0Qq+VI8dAwaK5bcuyy1NEt2Si9WU+qiLbgKrqjjmbawUYbLwyGka7Y 32rouH/5xs0kl+hFSTi1WvI+Cw1Bk3cOj7bBMEetXuh1qzIXLwDOobIzVcUf+j4P ApGBVethojQpfKIQIpXC7xAED++lnCNHMVqB8I+M1WntAo+/tXY5CfBnl2RjL2Bf +mm7+zmu4VlRJC+e0Q4VEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1726646603; x= 1726733003; bh=jt0Ly27jjuF7ZBTrE7jt9dB2J6K2Z0XSvMhGauyifwQ=; b=B riMd37NQSPww9t3CIO1XfNDgzui/gZRpYqqhxwf8g4uja5HhkxKiFBR2nEoay6J7 ZPTBJJtRV5ta75drE2iEHf5wHugN7j7BktiEZdZi0g+uGk5FT351PPXWxPIEIdZ3 y6hkeqe2vFj3BfP0j59XXxy1/XMzzNJ0uxpjrEhEwa7ln26ZXBhDnMAN695Iruj6 16GqqMqRwLOht24emjdvIWfbqx7r3ON4OhLSWHh1rpm8cJX3ZNDspRbjj11sfj27 EUGw68ZwO/BahwbGFngNBtf2vgynlUqE8fJlVQ8AUTUmr4EW/JKHbEd/eAPj0AB8 PceantflZh2u2OfLQnxQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudekkedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgg gfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgvrhcugfhishgvnhht rhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenucggtffrrghtth gvrhhnpeehiedvhfeuhfeugefgfeehgeejtdevuefhtefhueefvddugfdtueehgfefudfh ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvg htvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepsggvrhhtrhgrnhguughrohhuvhhothdrphhgse hgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishht shdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 18 Sep 2024 04:03:22 -0400 (EDT) Message-ID: <3023d29e-0fe7-4bec-9028-7f3c0102e437@eisentraut.org> Date: Wed, 18 Sep 2024 10:03:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: define pg_structiszero(addr, s, r) To: Bertrand Drouvot , pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 18.09.24 06:16, Bertrand Drouvot wrote: > +#define pg_structiszero(addr, s, r) \ > + do { \ > + /* We assume this initializes to zeroes */ \ > + static const s all_zeroes; \ > + r = (memcmp(addr, &all_zeroes, sizeof(all_zeroes)) == 0); \ > + } while (0) This assumption is kind of the problem, isn't it? Because, you can't assume that. And the existing code is arguably kind of wrong. But moreover, this macro also assumes that the "addr" argument has no random padding bits. In the existing code, you can maybe make a local analysis that the code is working correctly, although I'm not actually sure. But if you are repackaging this as a general macro under a general-sounding name, then the requirements should be more stringent.