Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQthu-00007R-DZ for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 14:49:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kQtht-0002ZC-8F for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Oct 2020 14:49:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQths-0002Z5-1o for pgsql-hackers@lists.postgresql.org; Fri, 09 Oct 2020 14:49:17 +0000 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQthk-0001bw-OE for pgsql-hackers@postgresql.org; Fri, 09 Oct 2020 14:49:15 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id C0EA89BA; Fri, 9 Oct 2020 10:49:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 09 Oct 2020 10:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=7aJtbzkE3HXCQfCo+ wcir0Z0Gtq2Ir6hw9fHXYfZORE=; b=G2WTCxiIRlhq8Zkh1RAbZxCnl22l9RcYj o2iGV8j3CQTPpyr3hn6AlBafrdPUrr9yuuUumqgcHD/d9728iGhRl/edTWvu4Mks NuUQZusmiBSHf/FVOIj0l9nt8aEaM06I9geEkZd9nLmQ/SjhSUnBpCaFv/v9gq9L ENoY36YD4ZyBjsntIaujrQM1mcH9ejG8i0qg4xeK4RUuJt2hDd5LPRuRu3Zuw6af U0GAZ8sYuMq4zt7qE2fFQ7U8FYah+RSdCCdNbtRE/G3QHenfxTWgQCIXIKBl9nN5 UpUvRV28B6gAuohRaaRXoJ7C0FyXf4hl/hY3Sdl+wQwawG8HbIP8g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrhedugdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggujggfsehttdertd dtredvnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvges rghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeevgfelveegueejge fhgeetgefhgeehieefheehleetteeiudeiiefhgffgheffteenucfkphepudeltddrleeh rdduledrudegkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 26BC33064610; Fri, 9 Oct 2020 10:49:02 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 681FA2A0FAB; Fri, 9 Oct 2020 11:48:59 -0300 (-03) Date: Fri, 9 Oct 2020 11:48:59 -0300 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: iwata.aya@fujitsu.com, pgsql-hackers@postgresql.org, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, pchampion@pivotal.io, jdoty@pivotal.io, raam.soft@gmail.com, nagaura.ryohei@fujitsu.com, nagata@sraoss.co.jp, peter.eisentraut@2ndquadrant.com, horiguchi.kyotaro@lab.ntt.co.jp, k.jamison@fujitsu.com Subject: Re: libpq debug log Message-ID: <20201009144859.GA31144@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201009.173122.1700952870250126070.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Oct-09, Kyotaro Horiguchi wrote: > I saw that version and have some comments. > > +pqGetProtocolMsgType(unsigned char c, PGCommSource commsource) > +{ > + const char *message_type; > > Compiler complains that this is unused. > > +static const char * > +pqGetProtocolMsgType(unsigned char c, PGCommSource commsource) > +{ > ... > + else > + return "UnknownCommand"; > +} > > Compiler complains as "control reached end of non-void function" Yeah, those two warnings are caused by the same problem, namely that I was editing this function to make it simpler and apparently the patch version I sent does not include all such changes. The fix is to remove the message_type variable and have the two assignments be "return". > +pqLogMsgString(PGconn *conn, const char *v, int length, PGCommSource commsource) > +{ > + if (length < 0) > + length = strlen(v) + 1; > + > pqLogMsgString(conn, str, -1, FROM_*) means actual length may be > different from the caller thinks, but the pqLogLineBreak() subtracts > that value from the message length rememberd in in logging_message. > Anyway AFAICS the patch doesn't use the code path so we should remove > the first two lines. True, +1 for removing it. > By the way, appendBinaryPQExpBuffer() enlarges its buffer by the size > of the exact length of the given data, but appends '\0' at the end of > the copied data. Couldn't that leads to an memory overrun? Doesn't enlargePQExpBuffer() include room for the trailing zero? I think it does.