Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZHQ8-0007b7-QL for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Oct 2013 09:41:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VZHQ8-0002lO-97 for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Oct 2013 09:41:36 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZHQ7-0002k4-2G for pgsql-bugs@postgresql.org; Thu, 24 Oct 2013 09:41:35 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZHQ3-00067G-IG for pgsql-bugs@postgresql.org; Thu, 24 Oct 2013 09:41:34 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VZHQ1-00040Y-DC for pgsql-bugs@postgresql.org; Thu, 24 Oct 2013 09:41:30 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VZHPv-0007u5-VU for pgsql-bugs@postgresql.org; Thu, 24 Oct 2013 09:41:24 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: BUG #8552: NEGATIVE_RETURNS in contrib/pageinspect/rawpage.c:83 To: pgsql-bugs@postgresql.org From: jmlich@redhat.com Message-Id: Date: Thu, 24 Oct 2013 09:41:23 +0000 X-Pg-Spam-Score: -0.4 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8552 Logged by: Jozef Mlich Email address: jmlich@redhat.com PostgreSQL version: 9.2.5 Operating system: any Description: NEGATIVE_RETURNS in contrib/pageinspect/rawpage.c:83 Dear postgresql mainainers, I was testing the postgresql using coverity scan tool. It reports following problem: 1. postgresql-9.2.5/contrib/pageinspect/rawpage.c:81:negative_return_fn – Function "forkname_to_number(text_to_cstring(forkname))" returns a negative number. 15. postgresql-9.2.5/src/backend/catalog/catalog.c:79:2:return_negative_constant – Explicitly returning negative value "InvalidForkNumber". 16. postgresql-9.2.5/contrib/pageinspect/rawpage.c:81:var_assign – Assigning: signed variable "forknum" = "forkname_to_number(char *)". 17. postgresql-9.2.5/contrib/pageinspect/rawpage.c:83:negative_returns – Passing variable "forknum" to a parameter that cannot be negative. 30. postgresql-9.2.5/contrib/pageinspect/rawpage.c:146:2:index – Function "ReadBufferExtended(Relation, ForkNumber, BlockNumber, ReadBufferMode, BufferAccessStrategy)" uses "forknum" as an array index. 36. postgresql-9.2.5/src/backend/storage/buffer/bufmgr.c:248:2:index – Function "ReadBuffer_common(SMgrRelation, char, ForkNumber, BlockNumber, ReadBufferMode, BufferAccessStrategy, bool *)" uses "forkNum" as an array index. 51. postgresql-9.2.5/src/backend/storage/buffer/bufmgr.c:377:4:index – Function "relpathbackend(RelFileNode, BackendId, ForkNumber)" uses "forkNum" as an array index. 54. postgresql-9.2.5/src/backend/catalog/catalog.c:131:4:index – Indexing "forkNames" with "forknum". In my opinion it worth to fix. I am not sure how to do it as I am not very familiar with postgresql source code. I suggest to add assert into relpathbackend in calalog.c or to add condition into rawpage.c. In case it is not a bug, I would appreciate short explanation. (1) $ diff postgresql-9.2.5/src/backend/catalog/catalog.c.orig postgresql-9.2.5/src/backend/catalog/catalog.c 122a123,124 > Assert(forknum == InvalidForkNumber); > (2) $ diff postgresql-9.2.5/contrib/pageinspect/rawpage.c.orig postgresql-9.2.5/contrib/pageinspect/rawpage.c 82a83,87 > if (forknum == InvalidForkNumber) > { > foo() // FIXME > } > -- regards, Jozef Mlich -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs