Re: WIP Incremental JSON Parser

From: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Amit Langote <amitlangote09(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: WIP Incremental JSON Parser
Date: 2024-04-04 19:28:59
Message-ID: CAOYmi+nMw+cfOpGiwPBU3p4ykKGenL9andOaosPF8_CUidXYzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Apr 4, 2024 at 11:06 AM Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> ../postgresql/src/common/jsonapi.c: In function ‘IsValidJsonNumber’:
> ../postgresql/src/common/jsonapi.c:2016:30: error: ‘dummy_lex.inc_state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 2016 | if (lex->incremental && !lex->inc_state->is_last_chunk &&
> | ~~~^~~~~~~~~~~
> ../postgresql/src/common/jsonapi.c:2020:36: error: ‘dummy_lex.token_start’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 2020 | lex->token_start, s - lex->token_start);
> | ~~~^~~~~~~~~~~~~

Ah, it hasn't figured out that the incremental path is disabled.
Zero-initializing the dummy_lex would be good regardless.

> ../postgresql/src/common/jsonapi.c:302:26: error: ‘numeric_error’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 302 | return (!numeric_error) && (total_len == dummy_lex.input_length);
> | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For this case, though, I think it'd be good for API consistency if
*numeric_error were always set on return, instead of relying on the
caller to initialize.

--Jacob

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2024-04-04 19:31:12 Re: WIP Incremental JSON Parser
Previous Message David G. Johnston 2024-04-04 19:27:32 Re: Reports on obsolete Postgres versions