]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove still more useless assignments.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Sep 2020 22:17:47 +0000 (18:17 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 5 Sep 2020 00:33:36 +0000 (20:33 -0400)
Fix some more things scan-build pointed to as dead stores.  In some of
these cases, rearranging the code a little leads to more readable
code IMO.  It's all cosmetic, though.

Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com

src/backend/replication/slotfuncs.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/jsonfuncs.c
src/bin/scripts/vacuumdb.c

index f88694672fba9a2b3849a0c0b8148fe9a0a3af36..1725ad0736fd5ac3b537d8260cf4f5190f0a4f61 100644 (file)
@@ -518,9 +518,6 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto)
                 */
                XLogBeginRead(ctx->reader, MyReplicationSlot->data.restart_lsn);
 
-               /* Initialize our return value in case we don't do anything */
-               retlsn = MyReplicationSlot->data.confirmed_flush;
-
                /* invalidate non-timetravel entries */
                InvalidateSystemCaches();
 
index 9de63686ecb599d84218140981991109238c984a..bf9643ffb4a108462e4c4e745c7e1664cb81f1d1 100644 (file)
@@ -6434,13 +6434,12 @@ float4_to_char(PG_FUNCTION_ARGS)
        int                     out_pre_spaces = 0,
                                sign = 0;
        char       *numstr,
-                          *orgnum,
                           *p;
 
        NUM_TOCHAR_prepare;
 
        if (IS_ROMAN(&Num))
-               numstr = orgnum = int_to_roman((int) rint(value));
+               numstr = int_to_roman((int) rint(value));
        else if (IS_EEEE(&Num))
        {
                if (isnan(value) || isinf(value))
@@ -6456,20 +6455,19 @@ float4_to_char(PG_FUNCTION_ARGS)
                }
                else
                {
-                       numstr = orgnum = psprintf("%+.*e", Num.post, value);
+                       numstr = psprintf("%+.*e", Num.post, value);
 
                        /*
                         * Swap a leading positive sign for a space.
                         */
-                       if (*orgnum == '+')
-                               *orgnum = ' ';
-
-                       numstr = orgnum;
+                       if (*numstr == '+')
+                               *numstr = ' ';
                }
        }
        else
        {
                float4          val = value;
+               char       *orgnum;
                int                     numstr_pre_len;
 
                if (IS_MULTI(&Num))
@@ -6480,7 +6478,7 @@ float4_to_char(PG_FUNCTION_ARGS)
                        Num.pre += Num.multi;
                }
 
-               orgnum = (char *) psprintf("%.0f", fabs(val));
+               orgnum = psprintf("%.0f", fabs(val));
                numstr_pre_len = strlen(orgnum);
 
                /* adjust post digits to fit max float digits */
@@ -6538,13 +6536,12 @@ float8_to_char(PG_FUNCTION_ARGS)
        int                     out_pre_spaces = 0,
                                sign = 0;
        char       *numstr,
-                          *orgnum,
                           *p;
 
        NUM_TOCHAR_prepare;
 
        if (IS_ROMAN(&Num))
-               numstr = orgnum = int_to_roman((int) rint(value));
+               numstr = int_to_roman((int) rint(value));
        else if (IS_EEEE(&Num))
        {
                if (isnan(value) || isinf(value))
@@ -6560,20 +6557,19 @@ float8_to_char(PG_FUNCTION_ARGS)
                }
                else
                {
-                       numstr = orgnum = (char *) psprintf("%+.*e", Num.post, value);
+                       numstr = psprintf("%+.*e", Num.post, value);
 
                        /*
                         * Swap a leading positive sign for a space.
                         */
-                       if (*orgnum == '+')
-                               *orgnum = ' ';
-
-                       numstr = orgnum;
+                       if (*numstr == '+')
+                               *numstr = ' ';
                }
        }
        else
        {
                float8          val = value;
+               char       *orgnum;
                int                     numstr_pre_len;
 
                if (IS_MULTI(&Num))
@@ -6583,6 +6579,7 @@ float8_to_char(PG_FUNCTION_ARGS)
                        val = value * multi;
                        Num.pre += Num.multi;
                }
+
                orgnum = psprintf("%.0f", fabs(val));
                numstr_pre_len = strlen(orgnum);
 
index 5a09d65fdcec8ac17d8492a078a50a3d38597b35..d370348a1c5157fb64debc3ebb288817b5c776f1 100644 (file)
@@ -4687,8 +4687,8 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
                                rk1,
                                rk2;
 
-       r1 = rk1 = JsonbIteratorNext(it1, &v1, false);
-       r2 = rk2 = JsonbIteratorNext(it2, &v2, false);
+       rk1 = JsonbIteratorNext(it1, &v1, false);
+       rk2 = JsonbIteratorNext(it2, &v2, false);
 
        /*
         * Both elements are objects.
@@ -4696,15 +4696,15 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
        if (rk1 == WJB_BEGIN_OBJECT && rk2 == WJB_BEGIN_OBJECT)
        {
                /*
-                * Append the all tokens from v1 to res, except last WJB_END_OBJECT
+                * Append all the tokens from v1 to res, except last WJB_END_OBJECT
                 * (because res will not be finished yet).
                 */
-               pushJsonbValue(state, r1, NULL);
+               pushJsonbValue(state, rk1, NULL);
                while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_OBJECT)
                        pushJsonbValue(state, r1, &v1);
 
                /*
-                * Append the all tokens from v2 to res, include last WJB_END_OBJECT
+                * Append all the tokens from v2 to res, include last WJB_END_OBJECT
                 * (the concatenation will be completed).
                 */
                while ((r2 = JsonbIteratorNext(it2, &v2, true)) != WJB_DONE)
@@ -4716,7 +4716,7 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
         */
        else if (rk1 == WJB_BEGIN_ARRAY && rk2 == WJB_BEGIN_ARRAY)
        {
-               pushJsonbValue(state, r1, NULL);
+               pushJsonbValue(state, rk1, NULL);
 
                while ((r1 = JsonbIteratorNext(it1, &v1, true)) != WJB_END_ARRAY)
                {
@@ -4736,10 +4736,8 @@ IteratorConcat(JsonbIterator **it1, JsonbIterator **it2,
        else if (((rk1 == WJB_BEGIN_ARRAY && !(*it1)->isScalar) && rk2 == WJB_BEGIN_OBJECT) ||
                         (rk1 == WJB_BEGIN_OBJECT && (rk2 == WJB_BEGIN_ARRAY && !(*it2)->isScalar)))
        {
-
                JsonbIterator **it_array = rk1 == WJB_BEGIN_ARRAY ? it1 : it2;
                JsonbIterator **it_object = rk1 == WJB_BEGIN_OBJECT ? it1 : it2;
-
                bool            prepend = (rk1 == WJB_BEGIN_OBJECT);
 
                pushJsonbValue(state, WJB_BEGIN_ARRAY, NULL);
index 125ed2ff5a46d018ca778dc23ef5836d4e7c5382..a8bc65421966db26dda9d8d035558c56d6e53131 100644 (file)
@@ -408,7 +408,6 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
        int                     i;
        int                     ntups;
        bool            failed = false;
-       bool            parallel = concurrentCons > 1;
        bool            tables_listed = false;
        bool            has_where = false;
        const char *stage_commands[] = {
@@ -651,25 +650,19 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
        PQclear(res);
 
        /*
-        * If there are more connections than vacuumable relations, we don't need
-        * to use them all.
+        * Ensure concurrentCons is sane.  If there are more connections than
+        * vacuumable relations, we don't need to use them all.
         */
-       if (parallel)
-       {
-               if (concurrentCons > ntups)
-                       concurrentCons = ntups;
-               if (concurrentCons <= 1)
-                       parallel = false;
-       }
+       if (concurrentCons > ntups)
+               concurrentCons = ntups;
+       if (concurrentCons <= 0)
+               concurrentCons = 1;
 
        /*
         * Setup the database connections. We reuse the connection we already have
         * for the first slot.  If not in parallel mode, the first slot in the
         * array contains the connection.
         */
-       if (concurrentCons <= 0)
-               concurrentCons = 1;
-
        slots = ParallelSlotsSetup(dbname, host, port, username, prompt_password,
                                                           progname, echo, conn, concurrentCons);