]> granicus.if.org Git - postgresql/commitdiff
Remove unnecessary casts from size_t to int
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 6 Jun 2019 12:32:54 +0000 (14:32 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 4 Jul 2019 15:02:13 +0000 (17:02 +0200)
We can use the %zu format specifier directly, no need to cast to int.

src/interfaces/ecpg/preproc/ecpg.addons
src/interfaces/ecpg/preproc/ecpg.trailer

index 4e303753027d81d3170b6040c817dec6621d0a54..cbffd50e14cf67bd2cd21b6ce40cdd9033b5b30c 100644 (file)
@@ -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);
index 1d58c778d9f83434493a72514a43d705706fe966..b303a9cbd0ce8fdb3ca1f132ea07695c3dbaf9c9 100644 (file)
@@ -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;
                }