diff options
| author | Peter Eisentraut <peter@eisentraut.org> | 2025-12-02 10:05:12 +0100 |
|---|---|---|
| committer | Peter Eisentraut <peter@eisentraut.org> | 2025-12-02 10:09:32 +0100 |
| commit | 4f941d432b42eccd99ba0d22e3a59c073ac2406a (patch) | |
| tree | 0d9b07faff2842d0fe07a39d761b2fd0ac99ab89 /src/interfaces/ecpg/ecpglib/execute.c | |
| parent | 35988b31db7767ba446009611b9928add1d40f98 (diff) | |
Remove useless casting to same type
This removes some casts where the input already has the same type as
the type specified by the cast. Their presence could cause risks of
hiding actual type mismatches in the future or silently discarding
qualifiers. It also improves readability. Same kind of idea as
7f798aca1d5 and ef8fe693606. (This does not change all such
instances, but only those hand-picked by the author.)
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/aSQy2JawavlVlEB0%40ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
| -rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 84a4a9fc578..bd10fef5748 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -54,7 +54,7 @@ quote_postgres(char *arg, bool quote, int lineno) { length = strlen(arg); buffer_len = 2 * length + 1; - res = (char *) ecpg_alloc(buffer_len + 3, lineno); + res = ecpg_alloc(buffer_len + 3, lineno); if (!res) return res; escaped_len = PQescapeString(res + 1, arg, buffer_len); @@ -263,7 +263,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia return cache_entry->isarray; } - array_query = (char *) ecpg_alloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno); + array_query = ecpg_alloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno); if (array_query == NULL) return ECPG_ARRAY_ERROR; @@ -391,7 +391,7 @@ ecpg_store_result(const PGresult *results, int act_field, } ecpg_log("ecpg_store_result on line %d: allocating memory for %d tuples\n", stmt->lineno, ntuples); - var->value = (char *) ecpg_auto_alloc(len, stmt->lineno); + var->value = ecpg_auto_alloc(len, stmt->lineno); if (!var->value) return false; *((char **) var->pointer) = var->value; @@ -402,7 +402,7 @@ ecpg_store_result(const PGresult *results, int act_field, { int len = var->ind_offset * ntuples; - var->ind_value = (char *) ecpg_auto_alloc(len, stmt->lineno); + var->ind_value = ecpg_auto_alloc(len, stmt->lineno); if (!var->ind_value) return false; *((char **) var->ind_pointer) = var->ind_value; @@ -822,7 +822,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari struct ECPGgeneric_bytea *variable = (struct ECPGgeneric_bytea *) (var->value); - if (!(mallocedval = (char *) ecpg_alloc(variable->len, lineno))) + if (!(mallocedval = ecpg_alloc(variable->len, lineno))) return false; memcpy(mallocedval, variable->arr, variable->len); @@ -835,7 +835,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari struct ECPGgeneric_varchar *variable = (struct ECPGgeneric_varchar *) (var->value); - if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, lineno))) + if (!(newcopy = ecpg_alloc(variable->len + 1, lineno))) return false; strncpy(newcopy, variable->arr, variable->len); @@ -1128,9 +1128,7 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe { char *newcopy; - if (!(newcopy = (char *) ecpg_alloc(strlen(stmt->command) - + strlen(tobeinserted) - + 1, stmt->lineno))) + if (!(newcopy = ecpg_alloc(strlen(stmt->command) + strlen(tobeinserted) + 1, stmt->lineno))) { ecpg_free(tobeinserted); return false; @@ -1536,7 +1534,7 @@ ecpg_build_params(struct statement *stmt) int buffersize = sizeof(int) * CHAR_BIT * 10 / 3; /* a rough guess of the * size we need */ - if (!(tobeinserted = (char *) ecpg_alloc(buffersize, stmt->lineno))) + if (!(tobeinserted = ecpg_alloc(buffersize, stmt->lineno))) { ecpg_free_params(stmt, false); return false; |
