Fix some compiler warnings
authorMichael Paquier <[email protected]>
Fri, 5 Dec 2025 03:30:43 +0000 (12:30 +0900)
committerMichael Paquier <[email protected]>
Fri, 5 Dec 2025 03:30:43 +0000 (12:30 +0900)
Some of the buildfarm members with some old gcc versions have been
complaining about an always-true test for a NULL pointer caused by a
combination of SOFT_ERROR_OCCURRED() and a local ErrorSaveContext
variable.

These warnings are taken care of by removing SOFT_ERROR_OCCURRED(),
switching to a direct variable check, like 56b1e88c804b.

Oversights in e1405aa5e3ac and 44eba8f06e55.

Reported-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/1341064.1764895052@sss.pgh.pa.us

src/backend/utils/adt/pg_dependencies.c
src/backend/utils/adt/pg_ndistinct.c

index 56abb74417757f9e22c502a0eb630539c82a7ee5..236790b14399e219c3b484f1dcc8536114f34e6d 100644 (file)
@@ -494,7 +494,7 @@ dependencies_scalar(void *state, char *token, JsonTokenType tokentype)
                case DEPS_EXPECT_ATTNUM:
                        attnum = pg_strtoint16_safe(token, (Node *) &escontext);
 
-                       if (SOFT_ERROR_OCCURRED(&escontext))
+                       if (escontext.error_occurred)
                        {
                                errsave(parse->escontext,
                                                errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -539,7 +539,7 @@ dependencies_scalar(void *state, char *token, JsonTokenType tokentype)
                        parse->dependency = (AttrNumber)
                                pg_strtoint16_safe(token, (Node *) &escontext);
 
-                       if (SOFT_ERROR_OCCURRED(&escontext))
+                       if (escontext.error_occurred)
                        {
                                errsave(parse->escontext,
                                                errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -569,7 +569,7 @@ dependencies_scalar(void *state, char *token, JsonTokenType tokentype)
                        parse->degree = float8in_internal(token, NULL, "double",
                                                                                          token, (Node *) &escontext);
 
-                       if (SOFT_ERROR_OCCURRED(&escontext))
+                       if (escontext.error_occurred)
                        {
                                errsave(parse->escontext,
                                                errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
index 5292521b1695b9277682dfae272b66e97f3c4f26..a2bce48fda072c45d6a7aaa9c433234806af9b00 100644 (file)
@@ -435,7 +435,7 @@ ndistinct_scalar(void *state, char *token, JsonTokenType tokentype)
                case NDIST_EXPECT_ATTNUM:
                        attnum = pg_strtoint16_safe(token, (Node *) &escontext);
 
-                       if (SOFT_ERROR_OCCURRED(&escontext))
+                       if (escontext.error_occurred)
                        {
                                errsave(parse->escontext,
                                                errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -485,7 +485,7 @@ ndistinct_scalar(void *state, char *token, JsonTokenType tokentype)
                         */
                        parse->ndistinct = pg_strtoint32_safe(token, (Node *) &escontext);
 
-                       if (!SOFT_ERROR_OCCURRED(&escontext))
+                       if (!escontext.error_occurred)
                        {
                                parse->state = NDIST_EXPECT_KEY;
                                return JSON_SUCCESS;