Re: New Defects reported by Coverity Scan for PostgreSQL

From: Ning Yu <nyu(at)pivotal(dot)io>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Emre Hasegeli <emre(at)hasegeli(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New Defects reported by Coverity Scan for PostgreSQL
Date: 2018-08-01 00:08:13
Message-ID: CAKmaiL2o6584gLFP=6YX-MUqmvOiT==uny+LA8z3=uAnriuzXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

To make coverity happy we might be able to suppress this false alarm by
adding a line like below:

```
/* coverity[SWAPPED_ARGUMENTS] */
lseg_closept_lseg(result, l2, l1);
```

From my point of view it's better to also put some comments for humans to
understand why we are passing l1 and l2 in reverse order.

On Wed, Aug 1, 2018 at 1:21 AM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

> Hello guys. Coverity complained about this patch as below. What, if
> anything, should be done about it? One solution is to mark it as a
> false-positive in Coverity, of course.
>
> On 2018-Jul-29, scan-admin(at)coverity(dot)com wrote:
>
> > ** CID 1438146: API usage errors (SWAPPED_ARGUMENTS)
> >
> >
> > ____________________________________________________________
> ____________________________________________
> > *** CID 1438146: API usage errors (SWAPPED_ARGUMENTS)
> > /srv/coverity/git/pgsql-git/postgresql/src/backend/utils/adt/geo_ops.c:
> 2647 in close_lseg()
> > 2641 LSEG *l1 = PG_GETARG_LSEG_P(0);
> > 2642 LSEG *l2 = PG_GETARG_LSEG_P(1);
> > 2643 Point *result;
> > 2644
> > 2645 result = (Point *) palloc(sizeof(Point));
> > 2646
> > >>> CID 1438146: API usage errors (SWAPPED_ARGUMENTS)
> > >>> The positions of arguments in the call to "lseg_closept_lseg" do
> not match the ordering of the parameters:
> > * "l2" is passed to "l1"
> > * "l1" is passed to "l2"
> > 2647 lseg_closept_lseg(result, l2, l1);
> > 2648
> > 2649 PG_RETURN_POINT_P(result);
> > 2650 }
> > 2651
> > 2652
>
> --
> Álvaro Herrera https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
>

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-08-01 02:22:16 Re: New Defects reported by Coverity Scan for PostgreSQL
Previous Message Bruce Momjian 2018-07-31 23:06:44 pgsql: pg_upgrade: Add SYSTEMQUOTE for Windows paths with spaces

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2018-08-01 01:52:21 Re: [HACKERS] Restricting maximum keep segments by repslots
Previous Message Andrew Dunstan 2018-08-01 00:05:06 Re: pg_upgrade from 9.4 to 10.4