Skip to content

Commit 973e9fb

Browse files
committed
Add const qualifiers where they are accidentally cast away
This only produces warnings under -Wcast-qual, but it's more correct and consistent in any case.
1 parent 41e3c94 commit 973e9fb

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

contrib/intarray/_intbig_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ typedef struct
332332
static int
333333
comparecost(const void *a, const void *b)
334334
{
335-
return ((SPLITCOST *) a)->cost - ((SPLITCOST *) b)->cost;
335+
return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
336336
}
337337

338338

contrib/ltree/ltree_gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ static int
275275
treekey_cmp(const void *a, const void *b)
276276
{
277277
return ltree_compare(
278-
((RIX *) a)->r,
279-
((RIX *) b)->r
278+
((const RIX *) a)->r,
279+
((const RIX *) b)->r
280280
);
281281
}
282282

src/backend/access/gist/gistproc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ typedef struct
284284
static int
285285
interval_cmp_lower(const void *i1, const void *i2)
286286
{
287-
double lower1 = ((SplitInterval *) i1)->lower,
288-
lower2 = ((SplitInterval *) i2)->lower;
287+
double lower1 = ((const SplitInterval *) i1)->lower,
288+
lower2 = ((const SplitInterval *) i2)->lower;
289289

290290
if (lower1 < lower2)
291291
return -1;
@@ -301,8 +301,8 @@ interval_cmp_lower(const void *i1, const void *i2)
301301
static int
302302
interval_cmp_upper(const void *i1, const void *i2)
303303
{
304-
double upper1 = ((SplitInterval *) i1)->upper,
305-
upper2 = ((SplitInterval *) i2)->upper;
304+
double upper1 = ((const SplitInterval *) i1)->upper,
305+
upper2 = ((const SplitInterval *) i2)->upper;
306306

307307
if (upper1 < upper2)
308308
return -1;
@@ -455,8 +455,8 @@ box_penalty(BOX *original, BOX *new)
455455
static int
456456
common_entry_cmp(const void *i1, const void *i2)
457457
{
458-
double delta1 = ((CommonEntry *) i1)->delta,
459-
delta2 = ((CommonEntry *) i2)->delta;
458+
double delta1 = ((const CommonEntry *) i1)->delta,
459+
delta2 = ((const CommonEntry *) i2)->delta;
460460

461461
if (delta1 < delta2)
462462
return -1;

src/backend/utils/adt/tsquery_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ QTNodeCompare(QTNode *an, QTNode *bn)
134134
static int
135135
cmpQTN(const void *a, const void *b)
136136
{
137-
return QTNodeCompare(*(QTNode **) a, *(QTNode **) b);
137+
return QTNodeCompare(*(QTNode * const *) a, *(QTNode * const *) b);
138138
}
139139

140140
void

src/backend/utils/adt/xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ xml_recv(PG_FUNCTION_ARGS)
311311
str = VARDATA(result);
312312
str[nbytes] = '\0';
313313

314-
parse_xml_decl((xmlChar *) str, NULL, NULL, &encodingStr, NULL);
314+
parse_xml_decl((const xmlChar *) str, NULL, NULL, &encodingStr, NULL);
315315

316316
/*
317317
* If encoding wasn't explicitly specified in the XML header, treat it as

src/backend/utils/misc/guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,8 +3780,8 @@ find_option(const char *name, bool create_placeholders, int elevel)
37803780
static int
37813781
guc_var_compare(const void *a, const void *b)
37823782
{
3783-
struct config_generic *confa = *(struct config_generic **) a;
3784-
struct config_generic *confb = *(struct config_generic **) b;
3783+
const struct config_generic *confa = *(struct config_generic * const *) a;
3784+
const struct config_generic *confb = *(struct config_generic * const *) b;
37853785

37863786
return guc_name_compare(confa->name, confb->name);
37873787
}

src/bin/psql/mbprint.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
217217

218218
for (; *pwcs && len > 0; pwcs += chlen)
219219
{
220-
chlen = PQmblen((char *) pwcs, encoding);
220+
chlen = PQmblen((const char *) pwcs, encoding);
221221
if (len < (size_t) chlen)
222222
break;
223-
w = PQdsplen((char *) pwcs, encoding);
223+
w = PQdsplen((const char *) pwcs, encoding);
224224

225225
if (chlen == 1) /* single-byte char */
226226
{
@@ -298,10 +298,10 @@ pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
298298

299299
for (; *pwcs && len > 0; pwcs += chlen)
300300
{
301-
chlen = PQmblen((char *) pwcs, encoding);
301+
chlen = PQmblen((const char *) pwcs, encoding);
302302
if (len < (size_t) chlen)
303303
break;
304-
w = PQdsplen((char *) pwcs, encoding);
304+
w = PQdsplen((const char *) pwcs, encoding);
305305

306306
if (chlen == 1) /* single-byte char */
307307
{

src/include/c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ typedef NameData *Name;
478478
* PointerIsValid
479479
* True iff pointer is valid.
480480
*/
481-
#define PointerIsValid(pointer) ((void*)(pointer) != NULL)
481+
#define PointerIsValid(pointer) ((const void*)(pointer) != NULL)
482482

483483
/*
484484
* PointerIsAligned

src/include/utils/pg_crc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef uint32 pg_crc32;
4040
/* Accumulate some (more) bytes into a CRC */
4141
#define COMP_CRC32(crc, data, len) \
4242
do { \
43-
unsigned char *__data = (unsigned char *) (data); \
43+
const unsigned char *__data = (const unsigned char *) (data); \
4444
uint32 __len = (len); \
4545
\
4646
while (__len-- > 0) \

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