Fix jsonb_from_cstring parameter type for length - Mailing list pgsql-hackers

From Chao Li
Subject Fix jsonb_from_cstring parameter type for length
Date
Msg-id CAEoWx2n-OWFAWhbVXHiBqHxTOKz71LCoX6EtuJ=z=5pkHFe-Ag@mail.gmail.com
Whole thread Raw
List pgsql-hackers
Hi Hackers,

While reading the code of jsonb_from_ctring(char *json, int len, bool ...), I found that:

1. len should be type of size_t. Because len is only used when calling makeJsonLexContextCstring(&lex, json, len, ...), where makeJsonLexContextCstring() is defined with size_t for len. jsonb_from_cstring() is a local static function, it is called 3 times, 2 of callers pass size_t len to it, and only one caller passes int len to it.

2. The first parameter "json" can be a const string, as this function passes "json" to  makeJsonLexContextCstring() and it defines "json" as const char *.

So I corrected the function interface. Build passed without warning and "make check" passed as well.

Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachment

pgsql-hackers by date:

Previous
From: Florents Tselai
Date:
Subject: Re: encode/decode support for base64url
Next
From: Chao Li
Date:
Subject: Re: encode/decode support for base64url