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.96) (envelope-from ) id 1wIivi-008QDh-2V for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 08:08:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIivh-00AYBi-2K for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 08:08:57 +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.96) (envelope-from ) id 1wIivh-00AYAd-13 for pgsql-hackers@lists.postgresql.org; Fri, 01 May 2026 08:08:57 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wIivf-00000004EcF-0Hdm for pgsql-hackers@lists.postgresql.org; Fri, 01 May 2026 08:08:56 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id E204C5B73B4 for ; Fri, 01 May 2026 10:08:48 +0200 (CEST) Received: from s934.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id D3B6C5B8780; Fri, 01 May 2026 10:08:48 +0200 (CEST) Received: from localhost (unknown [172.22.191.6]) by s934.loopia.se (Postfix) with ESMTP id D1E3EA3D611; Fri, 01 May 2026 10:08:48 +0200 (CEST) X-Virus-Scanned: amavis at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s470.loopia.se (amavis); dkim=pass (2048-bit key) header.d=proxel.se Received: from s981.loopia.se ([172.22.191.5]) by localhost (s470.loopia.se [172.22.190.34]) (amavis, port 10024) with UTF8LMTP id 6khzC6UuFjeS; Fri, 1 May 2026 10:08:47 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: andreas@proxel.se X-Loopia-Originating-IP: 147.28.75.140 Received: from [192.168.0.186] (customer-147-28-75-140.stosn.net [147.28.75.140]) (Authenticated sender: andreas@proxel.se) by s981.loopia.se (Postfix) with ESMTPSA id E454522B1757; Fri, 01 May 2026 10:08:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxel.se; s=loopiadkim1707418970; t=1777622927; bh=xccdTdA5+QfJK52Sz1iKvKp2rYz58Z5C3BlBRLNHw74=; h=Date:Subject:To:References:From:In-Reply-To; b=qI/TMVpZ7HoZmuap+idwGvJNXYrKep3iM0B3AcQFkbL7gyigmMMpNivXX7CboekqB wv59eM2d1EHntd3GctgRjqLvikLyvQ7GNa/oa0ctb4W/WvdPdEj/kVo+LDqUaOhzSk bxm9ZOpTPktInO/VA+KKzXUlf1sr5GZnQn0peW6i5f1t5/C00DhGnYxysaWcBTxkE7 /PrguNMvJ1EAVYzaMpTJj7SSoVaTrfTiWXRA4nhpz5YCQGfFh+30R4rl6x8pHydk+p KrgBF4PD5VITv0ILM4LtgPKmr/Qxd22jBfqFt6lYZC+qBM20xVrNntugaYrydwuXqJ CaAEUSXdf591Q== Message-ID: <0929a125-10b5-4be9-a0a1-ced2cf983392@proxel.se> Date: Fri, 1 May 2026 10:08:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Cleanup: Replace sscanf with strtol/strtoul in snapmgr To: Amul Sul , PostgreSQL Hackers References: Content-Language: en-US From: Andreas Karlsson 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 4/20/26 07:06, Amul Sul wrote: > The attached patch replaces sscanf with strtol and strtoul in the > ImportSnapshot helpers (parseIntFromText, parseXidFromText, and > parseVxidFromText) to improve reliability and efficiency. By utilizing > the end pointer, we can locate the next line without re-scanning the > entire string. > > Additionally, this change aligns the snapshot code with the rest of > the Postgres backend, which already favors these functions for safer > parsing. I personally prefer this safer and easier to verify parsing so from me this is a +1. I also reviewed the patch and it is simple, looks like it handles errors correctly and matches code we have in other parts of our code so I am all for merging it in its current shape. It also preserves the old behavior of ignoring random stuff at the end of each line, for good and bad. Looks good to me! Andreas