Skip to content

Commit d41f510

Browse files
committed
ecpg: Clean up some const usage
1 parent 8efb0bc commit d41f510

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,15 +1083,15 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
10831083
}
10841084

10851085
static void
1086-
free_params(const char **paramValues, int nParams, bool print, int lineno)
1086+
free_params(char **paramValues, int nParams, bool print, int lineno)
10871087
{
10881088
int n;
10891089

10901090
for (n = 0; n < nParams; n++)
10911091
{
10921092
if (print)
10931093
ecpg_log("free_params on line %d: parameter %d = %s\n", lineno, n + 1, paramValues[n] ? paramValues[n] : "null");
1094-
ecpg_free((void *) (paramValues[n]));
1094+
ecpg_free(paramValues[n]);
10951095
}
10961096
ecpg_free(paramValues);
10971097
}
@@ -1138,7 +1138,7 @@ ecpg_execute(struct statement * stmt)
11381138
PGnotify *notify;
11391139
struct variable *var;
11401140
int desc_counter = 0;
1141-
const char **paramValues = NULL;
1141+
char **paramValues = NULL;
11421142
int nParams = 0;
11431143
int position = 0;
11441144
struct sqlca_t *sqlca = ECPGget_sqlca();
@@ -1380,7 +1380,7 @@ ecpg_execute(struct statement * stmt)
13801380
else
13811381
{
13821382
nParams++;
1383-
if (!(paramValues = (const char **) ecpg_realloc(paramValues, sizeof(const char *) * nParams, stmt->lineno)))
1383+
if (!(paramValues = (char **) ecpg_realloc(paramValues, sizeof(char *) * nParams, stmt->lineno)))
13841384
{
13851385
ecpg_free(paramValues);
13861386
return false;
@@ -1441,7 +1441,7 @@ ecpg_execute(struct statement * stmt)
14411441
ecpg_log("ecpg_execute on line %d: query: %s; with %d parameter(s) on connection %s\n", stmt->lineno, stmt->command, nParams, stmt->connection->name);
14421442
if (stmt->statement_type == ECPGst_execute)
14431443
{
1444-
results = PQexecPrepared(stmt->connection->connection, stmt->name, nParams, paramValues, NULL, NULL, 0);
1444+
results = PQexecPrepared(stmt->connection->connection, stmt->name, nParams, (const char *const*) paramValues, NULL, NULL, 0);
14451445
ecpg_log("ecpg_execute on line %d: using PQexecPrepared for \"%s\"\n", stmt->lineno, stmt->command);
14461446
}
14471447
else
@@ -1453,7 +1453,7 @@ ecpg_execute(struct statement * stmt)
14531453
}
14541454
else
14551455
{
1456-
results = PQexecParams(stmt->connection->connection, stmt->command, nParams, NULL, paramValues, NULL, NULL, 0);
1456+
results = PQexecParams(stmt->connection->connection, stmt->command, nParams, NULL, (const char *const*) paramValues, NULL, NULL, 0);
14571457
ecpg_log("ecpg_execute on line %d: using PQexecParams\n", stmt->lineno);
14581458
}
14591459
}

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct
1919
char stmtID[STMTID_SIZE];
2020
char *ecpgQuery;
2121
long execs; /* # of executions */
22-
char *connection; /* connection for the statement */
22+
const char *connection; /* connection for the statement */
2323
} stmtCacheEntry;
2424

2525
static int nextStmtID = 1;
@@ -456,7 +456,7 @@ AddStmtToCache(int lineno, /* line # of statement */
456456
entry = &stmtCacheEntries[entNo];
457457
entry->lineno = lineno;
458458
entry->ecpgQuery = ecpg_strdup(ecpgQuery, lineno);
459-
entry->connection = (char *) connection;
459+
entry->connection = connection;
460460
entry->execs = 0;
461461
memcpy(entry->stmtID, stmtID, sizeof(entry->stmtID));
462462

src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,14 @@ struct variable *
317317
descriptor_variable(const char *name, int input)
318318
{
319319
static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
320-
static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
321-
static const struct variable varspace[2] = {
322-
{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
323-
{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
320+
static struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
321+
static struct variable varspace[2] = {
322+
{descriptor_names[0], &descriptor_type, 0, NULL},
323+
{descriptor_names[1], &descriptor_type, 0, NULL}
324324
};
325325

326326
strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
327-
return (struct variable *) & varspace[input];
327+
return &varspace[input];
328328
}
329329

330330
struct variable *

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy