Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fknLx-0003vM-WC for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 09:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fknLv-0003Ax-JM for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 09:23:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fknLv-0003Aq-8W for pgsql-hackers@lists.postgresql.org; Wed, 01 Aug 2018 09:23:31 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fknLn-0000JQ-0O for pgsql-hackers@postgresql.org; Wed, 01 Aug 2018 09:23:29 +0000 Received: by mail-wr1-x441.google.com with SMTP id v14-v6so19398562wro.5 for ; Wed, 01 Aug 2018 02:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zLGKZxbEyz5yDENz/SnAMfj6g9yEIkEHC7S0zJOrX/o=; b=L2V95tByZMZ3AOYhiShqUTdYrDfNfbJ2F2A8XrnUo53X2vIu0Jsm3GdmqmuOQzRghW gb34ERTguw+nUd9bRtmjHCnTA2E4GKu8O+n8kATtAditv5I38tQP4wa7sj1dZyuP3gjQ 2xt16a71eXOXOHUvxW33Svf53kwUzHY6F1wjaG5AKPTlhXrFwUmwd7K9EmWeZVvTcE9a pK3Lobq4tFadupL6BNB/4RoqGG60i6G81X0aFHIESoGSXcCvUkl7Gd4GpeUinTJqZ8d/ h+OCuBjOYYth9a8pdEQ5xMmmUIIHY5rXcJcISofdJfVdML5xX1Qv4kJ3eCDP6rGRLr/a Z2gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zLGKZxbEyz5yDENz/SnAMfj6g9yEIkEHC7S0zJOrX/o=; b=tdwSJb42PyDHT6YtP8Pbm/24FO3RGHYRfK4KvFDK+Od2QB2yl1nHhnb4rWh+WZQSqI VcDnR+2r20UzoxMIgaGPjPF1WuJOKUFSXXVRb6QWPeZwbUmFHZvkX8dB3HgMxMNwcABY Rv6mrcc9EVHOk+nvTDdHOs0FZoZlIUdjhiUf5ple/wcLcJ5VDlMlxGB4Qd6sOKOqxgzB RhUGuh8i79xBXmW2k7QluVMF0/tl3HUvweJSQh4WqNqy3xIdlRse7KrgN1zEzqS6S/X9 z/V6yVMvtRMq8oSSTxCYIAAfpE7HVgc1aTrwLdw/OjJz72t06RqZt/04TFUb+BlH7DhN RjAg== X-Gm-Message-State: AOUpUlHlMRJr6uSojlWWPmQTmxVhakfSC+g0LionqfnTb3Sp+oHm68fi k9nkoqn8TTb3qDgmu45Fgcftp7zdOHD7RTqgs3xKMtbl9AHvF1suucIe6GGU6CE1eabivxq/JIL GZttefX8qZgUGjLp8TSzoEae2LKNfiL0EGCPHRISE6YZOF44Blw5gcjPwV+e/d2oyO67v+rdhx/ A5aovNcjoxaBs= X-Google-Smtp-Source: AAOMgpd/sXjk125dLkMhsrexf2YgzP0LZS1JzNMd6VLv3u3cD0fvZ+LTvucu3oa3Xih0mnM9oL2AOQ== X-Received: by 2002:adf:b519:: with SMTP id a25-v6mr24507835wrd.273.1533115400444; Wed, 01 Aug 2018 02:23:20 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id p14-v6sm15802840wru.0.2018.08.01.02.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 02:23:19 -0700 (PDT) Subject: Re: New Defects reported by Coverity Scan for PostgreSQL To: Tom Lane , Ning Yu Cc: Alvaro Herrera , Emre Hasegeli , Pg Hackers References: <20180731172149.kdjl3xdjjtwxaj4s@alvherre.pgsql> <26769.1533090136@sss.pgh.pa.us> From: Tomas Vondra Message-ID: <9cc1e851-26b6-abfb-b62f-c788b14b9028@2ndquadrant.com> Date: Wed, 1 Aug 2018 11:23:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <26769.1533090136@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/01/2018 04:22 AM, Tom Lane wrote: > Ning Yu writes: >> 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. > > The header comment for lseg_closept_lseg() is pretty far from adequate > as well. After studying it for awhile I think I've puzzled out the > indeterminacies, but I shouldn't have had to. I think it probably > should have read > > * Closest point on line segment l2 to line segment l1 > * > * This returns the minimum distance from l1 to the closest point on l2. > * If result is not NULL, the closest point on l2 is stored at *result. > > Or perhaps I have it backwards and "l1" and "l2" need to be swapped in > that description. But the mere fact that there is any question about > that means that the function is poorly documented and perhaps poorly > named as well. For that matter, is there a good reason why l1/l2 > have those roles and not the reverse? > > While Coverity is surely operating from a shaky heuristic here, it's > got a point. The fact that it makes a difference which argument is > given first means that you've got to be really careful about which > is which, and this API spec is giving no help in that regard at all. > Yeah, I agree. The comments don't make it very clear what is the API semantics. Will fix. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services