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 1thXpQ-003kNL-0j for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Feb 2025 17:44:16 +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 1thXpN-003Fm6-18 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Feb 2025 17:44:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1thXpL-003Flo-MD for pgsql-hackers@lists.postgresql.org; Mon, 10 Feb 2025 17:44:12 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1thXpG-0004iV-09 for pgsql-hackers@postgresql.org; Mon, 10 Feb 2025 17:44:11 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2133D25400C8; Mon, 10 Feb 2025 12:44:05 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 10 Feb 2025 12:44:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :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=fm2; t=1739209444; x=1739295844; bh=uYWJrql2qr4CC4TQIaT5q3W8YGVLG9XBUwai1cmkWo8=; b= Ow+UZAMQAy+d6AGFssjRLgKJQJ1Xeku0I7gxkj5ghbzC2WMjXdl0ql/knNoxncVv hHZdiS9Rri/JbhaoGYsXVDpP00LtYCTYPQFsqKjgCx7CxIm9T29RzACQdPR01b4u bsSpWmkvmiNQdFWsyMR+L3I+sLhDAakCzs3yiOfoh+gpUbTa9okC6znKO1o6lRBq /0WZAwCsvMyL4TIZRbrK7+uVZgG87xJkhN+uY6dWhcMzjtPLJVse4/DSq2sUGrYb XACpApqqVvKEY9EdHL8HNF+n4w0yoxJGDZEU01FpK2PnRMzY6q+KF6y3aV7jL6/S jDnWYzqivgR0EChXtlnaYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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-sender:x-me-sender:x-sasl-enc; s=fm3; t=1739209444; x= 1739295844; bh=uYWJrql2qr4CC4TQIaT5q3W8YGVLG9XBUwai1cmkWo8=; b=s uw99U5sathjny3NCqrDmQAxzv+90NcSj8CNFpFTQFA+WJrJF6gvFJVzdbp/jESNW ICpp3HREg6GzRKZ432dLIW/nmzghczVz/808UoigqAVji+fTxvRxv12ICYgN/QvM GIJfRkcJKDEiz99Ez/MNoDvKMKy6lbsz4G0llgO+YXXF83nJNDE2Kjby1Zg/Obmx 2jOPGOxW/2cFF3FjbaDzeiykGvz5351g1A5qsJOBzEIuXHSZsnOzj5BscJCRc642 2p1Yrm6jd4zH9E+7wRQv3r/VX499dYfQ8uceJ9AHAehSOjLRHxwwh6qz+qyfuA6C zuPbM0KZgWQeuuzspsCuQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdefkeejtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufhfffgjkfgfgggtgfesthekredttder jeenucfhrhhomhepffgrghhfihhnnhcukfhlmhgrrhhiucforghnnhhsnohkvghruceoih hlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnheptdejveeujeeg jedvffeuudejtefhhfehgfdthfeijeffkeevkefgtdffjefhtdeinecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgrrhhisehilhhmrghr ihdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghp thhtohepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Feb 2025 12:44:04 -0500 (EST) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Peter Eisentraut Cc: pgsql-hackers Subject: Re: Remove useless casts to (char *) References: <87seor2t03.fsf@wibble.ilmari.org> Date: Mon, 10 Feb 2025 17:44:02 +0000 In-Reply-To: (Peter Eisentraut's message of "Sun, 9 Feb 2025 13:26:13 +0100") Message-ID: <87jz9x3db1.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 06.02.25 12:49, Dagfinn Ilmari Mannsåker wrote: >> I have only skimmed the patches, but one hunk jumped out at me: >> Peter Eisentraut writes: >> >>> diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c >>> index 1bf27d93cfa..937a2b02a4f 100644 >>> --- a/src/backend/libpq/pqcomm.c >>> +++ b/src/backend/libpq/pqcomm.c >>> @@ -1368,7 +1368,7 @@ internal_flush_buffer(const char *buf, size_t *start, size_t *end) >>> { >>> int r; >>> - r = secure_write(MyProcPort, (char *) bufptr, bufend - >>> bufptr); >>> + r = secure_write(MyProcPort, unconstify(char *, bufptr), bufend - bufptr); >>> if (r <= 0) >>> { >> Insted of unconstify here, could we not make secure_write() (and >> be_tls_write()) take the buffer pointer as const void *, like the >> attached? > > Yeah, that makes sense. I've committed that. Thanks, and thanks for catching be_gssapi_write(), which I had missed due to not having gssapi enabled in my test build. > Here is a new patch set rebased over that. I had a more thorough read-through this time (as well as applying and building it), and it does make the code a lot more readable. I noticed you in some places added extra parens around remaining casts with offset additions, e.g. - XLogRegisterData((char *) old_key_tuple->t_data + SizeofHeapTupleHeader, + XLogRegisterData(((char *) old_key_tuple->t_data) + SizeofHeapTupleHeader, old_key_tuple->t_len - SizeofHeapTupleHeader); But not in others: - memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, - (char *) data, - datalen); + memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, data, datalen); I don't have a particularly strong opinion either way (maybe -0.2 on the extra parens), but I mainly think we should keep it consistent, and not change it gratuitously. Greppig indicates to me that the paren-less version is more common: $ git grep -P '\(\w+\s*\**\) [\w>-]+ \+ \w+' | wc -l 283 $ git grep -P '\(\(\w+\s*\**\) [\w>-]+\) \+ \w+' | wc -l 96 So I think we should leave them as they are. - ilmari