pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Simplify jsonfuncs.c code by using strtoint() not strtol().
Date: Thu, 11 Feb 2021 17:49:47 +0000
Message-ID: <E1lAG67-0002Xk-UJ@gemulon.postgresql.org> (raw)

Simplify jsonfuncs.c code by using strtoint() not strtol().

Explicitly testing for INT_MIN and INT_MAX isn't particularly good
style; it's tedious and may draw useless compiler warnings on
machines where int and long are the same width.  We invented
strtoint() precisely for this usage, so use that instead.

While here, remove gratuitous variations in the way the tests for
did-strtoint-succeed were spelled.  Also, avoid attempting to
negate INT_MIN; that would probably work given that the result
is implicitly cast to uint32, but I think it's nominally undefined
behavior.

Per gripe from Ranier Vilela, though this isn't his proposed patch.

Discussion: https://postgr.es/m/CAEudQAqge3QfzoBRhe59QrB_5g+NmQUj2QpzqZ9Nc7QepXGAEw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/69036aafb9a8f425fb489125b5075ba7719d20d0

Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)



Message-ID: <E1lAG67-0002Xk-UJ@gemulon.postgresql.org>
Permalink:  ../E1lAG67-0002Xk-UJ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lAG67-0002Xk-UJ@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Simplify jsonfuncs.c code by using strtoint() not strtol().
  In-Reply-To: <E1lAG67-0002Xk-UJ@gemulon.postgresql.org>
  References: <E1lAG67-0002Xk-UJ@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox