From: Peter Eisentraut Date: Thu, 6 Jun 2019 12:32:54 +0000 (+0200) Subject: Remove unnecessary casts from size_t to int X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5ab9df7774b4570ff50e64b7fa3ba8295596d06;p=postgresql Remove unnecessary casts from size_t to int We can use the %zu format specifier directly, no need to cast to int. --- diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons index 4e30375302..cbffd50e14 100644 --- a/src/interfaces/ecpg/preproc/ecpg.addons +++ b/src/interfaces/ecpg/preproc/ecpg.addons @@ -36,7 +36,7 @@ ECPG: stmtExecuteStmt block /* It must be cut off double quotation because new_variable() double-quotes. */ str[strlen(str) - 1] = '\0'; - sprintf(length, "%d", (int) strlen(str)); + sprintf(length, "%zu", strlen(str)); add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator); } output_statement(cat_str(3, mm_strdup("execute"), mm_strdup("$0"), $1.type), 0, ECPGst_exec_with_exprlist); @@ -63,7 +63,7 @@ ECPG: stmtPrepareStmt block /* It must be cut off double quotation because new_variable() double-quotes. */ str[strlen(str) - 1] = '\0'; - sprintf(length, "%d", (int) strlen(str)); + sprintf(length, "%zu", strlen(str)); add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator); } output_statement(cat_str(5, mm_strdup("prepare"), mm_strdup("$0"), $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_prepare); diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index 1d58c778d9..b303a9cbd0 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1099,7 +1099,7 @@ UsingValue: UsingConst { char *length = mm_alloc(32); - sprintf(length, "%d", (int) strlen($1)); + sprintf(length, "%zu", strlen($1)); add_variable_to_head(&argsinsert, new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator); } | civar { $$ = EMPTY; } @@ -1226,7 +1226,7 @@ IntConstVar: Iconst { char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); - sprintf(length, "%d", (int) strlen($1)); + sprintf(length, "%zu", strlen($1)); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); $$ = $1; } @@ -1272,7 +1272,7 @@ AllConstVar: ecpg_fconst { char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); - sprintf(length, "%d", (int) strlen($1)); + sprintf(length, "%zu", strlen($1)); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); $$ = $1; } @@ -1287,7 +1287,7 @@ AllConstVar: ecpg_fconst char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *var = cat2_str(mm_strdup("-"), $2); - sprintf(length, "%d", (int) strlen(var)); + sprintf(length, "%zu", strlen(var)); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); $$ = var; } @@ -1297,7 +1297,7 @@ AllConstVar: ecpg_fconst char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *var = cat2_str(mm_strdup("-"), $2); - sprintf(length, "%d", (int) strlen(var)); + sprintf(length, "%zu", strlen(var)); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); $$ = var; } @@ -1308,7 +1308,7 @@ AllConstVar: ecpg_fconst char *var = $1 + 1; var[strlen(var) - 1] = '\0'; - sprintf(length, "%d", (int) strlen(var)); + sprintf(length, "%zu", strlen(var)); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); $$ = var; }