diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-05 13:17:32 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-09-05 13:17:32 -0400 |
commit | a5cc4dab6d1d694f113912a2aca7012a95262f0b (patch) | |
tree | 73f084898fcefb8a93a10972721c0826fd2d6e0e /src/backend/utils/adt/formatting.c | |
parent | 8febfd1855450f50f17419def41c2ea9bcf994d5 (diff) | |
download | postgresql-a5cc4dab6d1d694f113912a2aca7012a95262f0b.tar.gz postgresql-a5cc4dab6d1d694f113912a2aca7012a95262f0b.zip |
Yet more elimination of dead stores and useless initializations.
I'm not sure what tool Ranier was using, but the ones I contributed
were found by using a newer version of scan-build than I tried before.
Ranier Vilela and Tom Lane
Discussion: https://postgr.es/m/CAEudQAo1+AcGppxDSg8k+zF4+Kv+eJyqzEDdbpDg58-=MQcerQ@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index bf9643ffb4a..7d09537d82b 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1510,8 +1510,7 @@ static const char * get_th(char *num, int type) { int len = strlen(num), - last, - seclast; + last; last = *(num + (len - 1)); if (!isdigit((unsigned char) last)) @@ -1523,7 +1522,7 @@ get_th(char *num, int type) * All "teens" (<x>1[0-9]) get 'TH/th', while <x>[02-9][123] still get * 'ST/st', 'ND/nd', 'RD/rd', respectively */ - if ((len > 1) && ((seclast = num[len - 2]) == '1')) + if ((len > 1) && (num[len - 2] == '1')) last = 0; switch (last) @@ -4932,9 +4931,9 @@ NUM_cache(int len, NUMDesc *Num, text *pars_str, bool *shouldFree) static char * int_to_roman(int number) { - int len = 0, - num = 0; - char *p = NULL, + int len, + num; + char *p, *result, numstr[12]; @@ -4950,7 +4949,7 @@ int_to_roman(int number) for (p = numstr; *p != '\0'; p++, --len) { - num = *p - 49; /* 48 ascii + 1 */ + num = *p - ('0' + 1); if (num < 0) continue; @@ -6118,7 +6117,7 @@ numeric_to_char(PG_FUNCTION_ARGS) x = DatumGetNumeric(DirectFunctionCall2(numeric_round, NumericGetDatum(value), Int32GetDatum(0))); - numstr = orgnum = + numstr = int_to_roman(DatumGetInt32(DirectFunctionCall1(numeric_int4, NumericGetDatum(x)))); } @@ -6239,7 +6238,7 @@ int4_to_char(PG_FUNCTION_ARGS) * On DateType depend part (int32) */ if (IS_ROMAN(&Num)) - numstr = orgnum = int_to_roman(value); + numstr = int_to_roman(value); else if (IS_EEEE(&Num)) { /* we can do it easily because float8 won't lose any precision */ @@ -6335,7 +6334,7 @@ int8_to_char(PG_FUNCTION_ARGS) if (IS_ROMAN(&Num)) { /* Currently don't support int8 conversion to roman... */ - numstr = orgnum = int_to_roman(DatumGetInt32(DirectFunctionCall1(int84, Int64GetDatum(value)))); + numstr = int_to_roman(DatumGetInt32(DirectFunctionCall1(int84, Int64GetDatum(value)))); } else if (IS_EEEE(&Num)) { |