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 1r47nb-007Rva-WA for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Nov 2023 22:58:56 +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 1r47nZ-00GjaM-Ge for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Nov 2023 22:58:53 +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 1r47nZ-00GjaD-6s for pgsql-hackers@lists.postgresql.org; Fri, 17 Nov 2023 22:58:53 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r47nW-0065EK-Pj for pgsql-hackers@postgresql.org; Fri, 17 Nov 2023 22:58:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 3AHMwmBG810815; Fri, 17 Nov 2023 17:58:48 -0500 From: Tom Lane To: Thomas Munro cc: Tristan Partin , pgsql-hackers Subject: Re: On non-Windows, hard depend on uselocale(3) In-reply-to: <664255.1700245108@sss.pgh.pa.us> References: <2689177.1700070346@sss.pgh.pa.us> <2946058.1700081498@sss.pgh.pa.us> <12842.1700083028@sss.pgh.pa.us> <98824.1700089582@sss.pgh.pa.us> <664255.1700245108@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 17 Nov 2023 13:18:28 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <810813.1700261928.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 17 Nov 2023 17:58:48 -0500 Message-ID: <810814.1700261928@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > I've not reviewed this closely, but I did try it on mamba's host. > It compiles and passes regression testing, but I see two warnings: > common.c: In function 'PGTYPESsprintf': > common.c:120:2: warning: function 'PGTYPESsprintf' might be a candidate = for 'gnu_printf' format attribute [-Wsuggest-attribute=3Dformat] > 120 | return vsprintf_l(str, PGTYPESclocale, format, args); > | ^~~~~~ > common.c: In function 'PGTYPESsnprintf': > common.c:136:2: warning: function 'PGTYPESsnprintf' might be a candidate= for 'gnu_printf' format attribute [-Wsuggest-attribute=3Dformat] > 136 | return vsnprintf_l(str, size, PGTYPESclocale, format, args); > | ^~~~~~ > I think this is telling us about an actual problem: these new > functions are based on libc's printf not what we have in snprintf.c, > and therefore we really shouldn't be assuming that they will support > any format specs beyond what POSIX requires for printf. Wait, I just realized that there's more to this. ecpglib *does* rely on our snprintf.c functions: $ nm --ext --undef src/interfaces/ecpg/ecpglib/*.o | grep printf = U pg_snprintf U pg_fprintf U pg_snprintf U pg_printf U pg_snprintf U pg_sprintf U pg_fprintf U pg_snprintf U pg_vfprintf U pg_snprintf U pg_sprintf U pg_sprintf We are getting these warnings because vsprintf_l and vsnprintf_l don't have snprintf.c implementations, so the compiler sees the attributes attached to them by stdio.h. This raises the question of whether changing snprintf.c could be part of the solution. I'm not sure that we want to try to emulate vs[n]printf_l directly, but perhaps there's another way? In any case, my concern about ecpg_log() is misplaced. That is really using pg_vfprintf, so it's correctly marked. regards, tom lane