From 1b634547e006df6e904be7b8a9106c27a8c17c77 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 22 Aug 2017 20:05:49 -0400 Subject: [PATCH 2/2] PL/Python: Fix remaining scan-build warnings Apparently, scan-build thinks that proc->is_setof can change during PLy_exec_function(). To make it clearer, save the value in a local variable. Also add an assertion to clear another warning. --- src/pl/plpython/plpy_exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pl/plpython/plpy_exec.c b/src/pl/plpython/plpy_exec.c index 26f61dd0f3..b10b1681f1 100644 --- a/src/pl/plpython/plpy_exec.c +++ b/src/pl/plpython/plpy_exec.c @@ -57,6 +57,7 @@ static void PLy_abort_open_subtransactions(int save_subxact_level); Datum PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) { + bool is_setof = proc->is_setof; Datum rv; PyObject *volatile plargs = NULL; PyObject *volatile plrv = NULL; @@ -73,7 +74,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) PG_TRY(); { - if (proc->is_setof) + if (is_setof) { /* First Call setup */ if (SRF_IS_FIRSTCALL()) @@ -93,6 +94,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) funcctx = SRF_PERCALL_SETUP(); Assert(funcctx != NULL); srfstate = (PLySRFState *) funcctx->user_fctx; + Assert(srfstate != NULL); } if (srfstate == NULL || srfstate->iter == NULL) @@ -125,7 +127,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) * We stay in the SPI context while doing this, because PyIter_Next() * calls back into Python code which might contain SPI calls. */ - if (proc->is_setof) + if (is_setof) { if (srfstate->iter == NULL) { -- 2.14.1