git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2c56b3a)
In jsonb_plpython.c, suppress warning message from gcc 10.
2020年1月30日 23:25:56 +0000 (18:25 -0500)
2020年1月30日 23:26:15 +0000 (18:26 -0500)
Very recent gcc complains that PLyObject_ToJsonbValue could return
a pointer to a local variable. I think it's wrong; but the coding
is fragile enough, and the savings of one palloc() minimal enough,
that it seems better to just do a palloc() all the time. (My other
idea of tweaking the if-condition doesn't suppress the warning.)

Back-patch to v11 where this code was introduced.

Discussion: https://postgr.es/m/21547.1580170366@sss.pgh.pa.us


diff --git a/contrib/jsonb_plpython/jsonb_plpython.c b/contrib/jsonb_plpython/jsonb_plpython.c
index 1bc984d5c4d9dbaacaa3675c2da2d7d0e8f4b657..67565042c6396cf1c13165ad9e430ab77ec7ab2a 100644 (file)
--- a/contrib/jsonb_plpython/jsonb_plpython.c
+++ b/contrib/jsonb_plpython/jsonb_plpython.c
@@ -367,7 +367,6 @@ PLyNumber_ToJsonbValue(PyObject *obj, JsonbValue *jbvNum)
static JsonbValue *
PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_elem)
{
- JsonbValue buf;
JsonbValue *out;
if (!(PyString_Check(obj) || PyUnicode_Check(obj)))
@@ -378,11 +377,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele
return PLyMapping_ToJsonbValue(obj, jsonb_state);
}
- /* Allocate JsonbValue in heap only if it is raw scalar value. */
- if (*jsonb_state)
- out = &buf;
- else
- out = palloc(sizeof(JsonbValue));
+ out = palloc(sizeof(JsonbValue));
if (obj == Py_None)
out->type = jbvNull;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /