mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Silence invalid Coverity complaint in jsonReadPush().
Coverity complains that the output from THROW_FMT will be unpredictable since the order of operations in the call is not deterministic, but it fails to understand that subsequent calls to jsonReadTypeNextIgnoreComma() are noops until the value has been processed. Silence Coverity by assigning the actual type to a local variable so jsonReadTypeNextIgnoreComma() is only called once. Also fix an adjacent comment typo.
This commit is contained in:
parent
bb8988b551
commit
d32eb5bb54
@ -251,15 +251,19 @@ jsonReadPush(JsonRead *const this, const JsonType type, const bool key)
|
||||
if (this->complete)
|
||||
THROW(FormatError, "JSON read is complete");
|
||||
|
||||
// Check that the requested type matches the actual type
|
||||
if (jsonReadTypeNextIgnoreComma(this) != type)
|
||||
// Check that the requested type matches the actual type. The actual type needs to be assigned to a local variable or Coverity
|
||||
// will complain about parameter order when jsonReadTypeNextIgnoreComma() is called again in THROW_FMT() even though it is a
|
||||
// noop.
|
||||
const JsonType typeActual = jsonReadTypeNextIgnoreComma(this);
|
||||
|
||||
if (typeActual != type)
|
||||
{
|
||||
THROW_FMT(
|
||||
JsonFormatError, "expected '%s' but found '%s' at: %s", strZ(strIdToStr(type)),
|
||||
strZ(strIdToStr(jsonReadTypeNextIgnoreComma(this))), this->json);
|
||||
JsonFormatError, "expected '%s' but found '%s' at: %s", strZ(strIdToStr(type)), strZ(strIdToStr(typeActual)),
|
||||
this->json);
|
||||
}
|
||||
|
||||
// If the container stack jas not been created yet
|
||||
// If the container stack has not been created yet
|
||||
if (this->stack == NULL)
|
||||
{
|
||||
ASSERT(!key);
|
||||
|
Loading…
x
Reference in New Issue
Block a user