aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2011-09-11 21:54:32 +0300
committerPeter Eisentraut <peter_e@gmx.net>2011-09-11 21:54:32 +0300
commit1b81c2fe6ee2b26d37610c3d381a87fa17af0a7c (patch)
tree09075f19d47fd81df20beb96e27e0f21ad2a0729 /src/backend
parent02bca4f35164dd1873eab9b8e6167e42a79157c4 (diff)
downloadpostgresql-1b81c2fe6ee2b26d37610c3d381a87fa17af0a7c.tar.gz
postgresql-1b81c2fe6ee2b26d37610c3d381a87fa17af0a7c.zip
Remove many -Wcast-qual warnings
This addresses only those cases that are easy to fix by adding or moving a const qualifier or removing an unnecessary cast. There are many more complicated cases remaining.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/analyze.c16
-rw-r--r--src/backend/commands/copy.c8
-rw-r--r--src/backend/libpq/ip.c12
-rw-r--r--src/backend/libpq/md5.c8
-rw-r--r--src/backend/nodes/makefuncs.c2
-rw-r--r--src/backend/nodes/tidbitmap.c4
-rw-r--r--src/backend/postmaster/autovacuum.c4
-rw-r--r--src/backend/storage/lmgr/lock.c6
-rw-r--r--src/backend/tsearch/dict_synonym.c2
-rw-r--r--src/backend/tsearch/dict_thesaurus.c8
-rw-r--r--src/backend/tsearch/spell.c8
-rw-r--r--src/backend/tsearch/to_tsany.c8
-rw-r--r--src/backend/tsearch/ts_utils.c2
-rw-r--r--src/backend/utils/adt/tsgistidx.c8
-rw-r--r--src/backend/utils/adt/tsquery_gist.c4
-rw-r--r--src/backend/utils/adt/tsrank.c8
-rw-r--r--src/backend/utils/adt/xml.c4
-rw-r--r--src/backend/utils/mb/conv.c20
18 files changed, 66 insertions, 66 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 36cb40d4517..18d44c572c7 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1362,8 +1362,8 @@ get_next_S(double t, int n, double *stateptr)
static int
compare_rows(const void *a, const void *b)
{
- HeapTuple ha = *(HeapTuple *) a;
- HeapTuple hb = *(HeapTuple *) b;
+ HeapTuple ha = *(const HeapTuple *) a;
+ HeapTuple hb = *(const HeapTuple *) b;
BlockNumber ba = ItemPointerGetBlockNumber(&ha->t_self);
OffsetNumber oa = ItemPointerGetOffsetNumber(&ha->t_self);
BlockNumber bb = ItemPointerGetBlockNumber(&hb->t_self);
@@ -2700,10 +2700,10 @@ compute_scalar_stats(VacAttrStatsP stats,
static int
compare_scalars(const void *a, const void *b, void *arg)
{
- Datum da = ((ScalarItem *) a)->value;
- int ta = ((ScalarItem *) a)->tupno;
- Datum db = ((ScalarItem *) b)->value;
- int tb = ((ScalarItem *) b)->tupno;
+ Datum da = ((const ScalarItem *) a)->value;
+ int ta = ((const ScalarItem *) a)->tupno;
+ Datum db = ((const ScalarItem *) b)->value;
+ int tb = ((const ScalarItem *) b)->tupno;
CompareScalarsContext *cxt = (CompareScalarsContext *) arg;
int32 compare;
@@ -2734,8 +2734,8 @@ compare_scalars(const void *a, const void *b, void *arg)
static int
compare_mcvs(const void *a, const void *b)
{
- int da = ((ScalarMCVItem *) a)->first;
- int db = ((ScalarMCVItem *) b)->first;
+ int da = ((const ScalarMCVItem *) a)->first;
+ int db = ((const ScalarMCVItem *) b)->first;
return da - db;
}
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 528a3a1f539..a9c1980e5d5 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -296,7 +296,7 @@ static char *limit_printout_length(const char *str);
static void SendCopyBegin(CopyState cstate);
static void ReceiveCopyBegin(CopyState cstate);
static void SendCopyEnd(CopyState cstate);
-static void CopySendData(CopyState cstate, void *databuf, int datasize);
+static void CopySendData(CopyState cstate, const void *databuf, int datasize);
static void CopySendString(CopyState cstate, const char *str);
static void CopySendChar(CopyState cstate, char c);
static void CopySendEndOfRow(CopyState cstate);
@@ -431,9 +431,9 @@ SendCopyEnd(CopyState cstate)
*----------
*/
static void
-CopySendData(CopyState cstate, void *databuf, int datasize)
+CopySendData(CopyState cstate, const void *databuf, int datasize)
{
- appendBinaryStringInfo(cstate->fe_msgbuf, (char *) databuf, datasize);
+ appendBinaryStringInfo(cstate->fe_msgbuf, databuf, datasize);
}
static void
@@ -1535,7 +1535,7 @@ CopyTo(CopyState cstate)
int32 tmp;
/* Signature */
- CopySendData(cstate, (char *) BinarySignature, 11);
+ CopySendData(cstate, BinarySignature, 11);
/* Flags field */
tmp = 0;
if (cstate->oids)
diff --git a/src/backend/libpq/ip.c b/src/backend/libpq/ip.c
index cc6c2abac68..71fd9e76a29 100644
--- a/src/backend/libpq/ip.c
+++ b/src/backend/libpq/ip.c
@@ -283,14 +283,14 @@ pg_range_sockaddr(const struct sockaddr_storage * addr,
const struct sockaddr_storage * netmask)
{
if (addr->ss_family == AF_INET)
- return range_sockaddr_AF_INET((struct sockaddr_in *) addr,
- (struct sockaddr_in *) netaddr,
- (struct sockaddr_in *) netmask);
+ return range_sockaddr_AF_INET((const struct sockaddr_in *) addr,
+ (const struct sockaddr_in *) netaddr,
+ (const struct sockaddr_in *) netmask);
#ifdef HAVE_IPV6
else if (addr->ss_family == AF_INET6)
- return range_sockaddr_AF_INET6((struct sockaddr_in6 *) addr,
- (struct sockaddr_in6 *) netaddr,
- (struct sockaddr_in6 *) netmask);
+ return range_sockaddr_AF_INET6((const struct sockaddr_in6 *) addr,
+ (const struct sockaddr_in6 *) netaddr,
+ (const struct sockaddr_in6 *) netmask);
#endif
else
return 0;
diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c
index d40c37b6375..dd8c5ae50b3 100644
--- a/src/backend/libpq/md5.c
+++ b/src/backend/libpq/md5.c
@@ -33,7 +33,7 @@
* when it is no longer needed.
*/
static uint8 *
-createPaddedCopyWithLength(uint8 *b, uint32 *l)
+createPaddedCopyWithLength(const uint8 *b, uint32 *l)
{
uint8 *ret;
uint32 q;
@@ -182,7 +182,7 @@ doTheRounds(uint32 X[16], uint32 state[4])
}
static int
-calculateDigestFromBuffer(uint8 *b, uint32 len, uint8 sum[16])
+calculateDigestFromBuffer(const uint8 *b, uint32 len, uint8 sum[16])
{
register uint32 i,
j,
@@ -291,7 +291,7 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum)
{
uint8 sum[16];
- if (!calculateDigestFromBuffer((uint8 *) buff, len, sum))
+ if (!calculateDigestFromBuffer(buff, len, sum))
return false;
bytesToHex(sum, hexsum);
@@ -301,7 +301,7 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum)
bool
pg_md5_binary(const void *buff, size_t len, void *outbuf)
{
- if (!calculateDigestFromBuffer((uint8 *) buff, len, outbuf))
+ if (!calculateDigestFromBuffer(buff, len, outbuf))
return false;
return true;
}
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 4d2eccf8179..9070cd2d739 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -45,7 +45,7 @@ makeA_Expr(A_Expr_Kind kind, List *name,
* As above, given a simple (unqualified) operator name
*/
A_Expr *
-makeSimpleA_Expr(A_Expr_Kind kind, const char *name,
+makeSimpleA_Expr(A_Expr_Kind kind, char *name,
Node *lexpr, Node *rexpr, int location)
{
A_Expr *a = makeNode(A_Expr);
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 2363ec22a43..a2e9e21885b 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1011,8 +1011,8 @@ tbm_lossify(TIDBitmap *tbm)
static int
tbm_comparator(const void *left, const void *right)
{
- BlockNumber l = (*((const PagetableEntry **) left))->blockno;
- BlockNumber r = (*((const PagetableEntry **) right))->blockno;
+ BlockNumber l = (*((PagetableEntry * const *) left))->blockno;
+ BlockNumber r = (*((PagetableEntry * const *) right))->blockno;
if (l < r)
return -1;
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 4e211977b28..3b71232b882 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1028,10 +1028,10 @@ rebuild_database_list(Oid newdb)
static int
db_comparator(const void *a, const void *b)
{
- if (((avl_dbase *) a)->adl_score == ((avl_dbase *) b)->adl_score)
+ if (((const avl_dbase *) a)->adl_score == ((const avl_dbase *) b)->adl_score)
return 0;
else
- return (((avl_dbase *) a)->adl_score < ((avl_dbase *) b)->adl_score) ? 1 : -1;
+ return (((const avl_dbase *) a)->adl_score < ((const avl_dbase *) b)->adl_score) ? 1 : -1;
}
/*
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 3264a659859..a1ce5d8b8a2 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -937,7 +937,7 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc,
* anytime.
*/
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
- (void *) locktag,
+ (const void *) locktag,
hashcode,
HASH_ENTER_NULL,
&found);
@@ -1673,7 +1673,7 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
Assert(FastPathTag(locktag) && FastPathWeakMode(lockmode));
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
- (void *) locktag,
+ (const void *) locktag,
locallock->hashcode,
HASH_FIND,
&found);
@@ -2505,7 +2505,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
LWLockAcquire(partitionLock, LW_SHARED);
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
- (void *) locktag,
+ (const void *) locktag,
hashcode,
HASH_FIND,
NULL);
diff --git a/src/backend/tsearch/dict_synonym.c b/src/backend/tsearch/dict_synonym.c
index 0788b3da847..afe4f5212e7 100644
--- a/src/backend/tsearch/dict_synonym.c
+++ b/src/backend/tsearch/dict_synonym.c
@@ -83,7 +83,7 @@ findwrd(char *in, char **end, uint16 *flags)
static int
compareSyn(const void *a, const void *b)
{
- return strcmp(((Syn *) a)->in, ((Syn *) b)->in);
+ return strcmp(((const Syn *) a)->in, ((const Syn *) b)->in);
}
diff --git a/src/backend/tsearch/dict_thesaurus.c b/src/backend/tsearch/dict_thesaurus.c
index 509420f70d0..e0d21c2ad61 100644
--- a/src/backend/tsearch/dict_thesaurus.c
+++ b/src/backend/tsearch/dict_thesaurus.c
@@ -348,7 +348,7 @@ cmpLexemeInfo(LexemeInfo *a, LexemeInfo *b)
}
static int
-cmpLexeme(TheLexeme *a, TheLexeme *b)
+cmpLexeme(const TheLexeme *a, const TheLexeme *b)
{
if (a->lexeme == NULL)
{
@@ -366,14 +366,14 @@ cmpLexeme(TheLexeme *a, TheLexeme *b)
static int
cmpLexemeQ(const void *a, const void *b)
{
- return cmpLexeme((TheLexeme *) a, (TheLexeme *) b);
+ return cmpLexeme((const TheLexeme *) a, (const TheLexeme *) b);
}
static int
cmpTheLexeme(const void *a, const void *b)
{
- TheLexeme *la = (TheLexeme *) a;
- TheLexeme *lb = (TheLexeme *) b;
+ const TheLexeme *la = (const TheLexeme *) a;
+ const TheLexeme *lb = (const TheLexeme *) b;
int res;
if ((res = cmpLexeme(la, lb)) != 0)
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c
index be1663cd881..c9bc748b682 100644
--- a/src/backend/tsearch/spell.c
+++ b/src/backend/tsearch/spell.c
@@ -140,7 +140,7 @@ lowerstr_ctx(IspellDict *Conf, const char *src)
#define MAXNORMLEN 256
#define STRNCMP(s,p) strncmp( (s), (p), strlen(p) )
-#define GETWCHAR(W,L,N,T) ( ((uint8*)(W))[ ((T)==FF_PREFIX) ? (N) : ( (L) - 1 - (N) ) ] )
+#define GETWCHAR(W,L,N,T) ( ((const uint8*)(W))[ ((T)==FF_PREFIX) ? (N) : ( (L) - 1 - (N) ) ] )
#define GETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T )
static char *VoidString = "";
@@ -148,12 +148,12 @@ static char *VoidString = "";
static int
cmpspell(const void *s1, const void *s2)
{
- return (strcmp((*(const SPELL **) s1)->word, (*(const SPELL **) s2)->word));
+ return (strcmp((*(SPELL * const *) s1)->word, (*(SPELL * const *) s2)->word));
}
static int
cmpspellaffix(const void *s1, const void *s2)
{
- return (strncmp((*(const SPELL **) s1)->p.flag, (*(const SPELL **) s2)->p.flag, MAXFLAGLEN));
+ return (strncmp((*(SPELL * const *) s1)->p.flag, (*(SPELL * const *) s2)->p.flag, MAXFLAGLEN));
}
static char *
@@ -332,7 +332,7 @@ FindWord(IspellDict *Conf, const char *word, int affixflag, int flag)
SPNodeData *StopLow,
*StopHigh,
*StopMiddle;
- uint8 *ptr = (uint8 *) word;
+ const uint8 *ptr = (const uint8 *) word;
flag &= FF_DICTFLAGMASK;
diff --git a/src/backend/tsearch/to_tsany.c b/src/backend/tsearch/to_tsany.c
index d143aaebfac..3f194ec6bfd 100644
--- a/src/backend/tsearch/to_tsany.c
+++ b/src/backend/tsearch/to_tsany.c
@@ -33,16 +33,16 @@ compareWORD(const void *a, const void *b)
int res;
res = tsCompareString(
- ((ParsedWord *) a)->word, ((ParsedWord *) a)->len,
- ((ParsedWord *) b)->word, ((ParsedWord *) b)->len,
+ ((const ParsedWord *) a)->word, ((const ParsedWord *) a)->len,
+ ((const ParsedWord *) b)->word, ((const ParsedWord *) b)->len,
false);
if (res == 0)
{
- if (((ParsedWord *) a)->pos.pos == ((ParsedWord *) b)->pos.pos)
+ if (((const ParsedWord *) a)->pos.pos == ((const ParsedWord *) b)->pos.pos)
return 0;
- res = (((ParsedWord *) a)->pos.pos > ((ParsedWord *) b)->pos.pos) ? 1 : -1;
+ res = (((const ParsedWord *) a)->pos.pos > ((const ParsedWord *) b)->pos.pos) ? 1 : -1;
}
return res;
diff --git a/src/backend/tsearch/ts_utils.c b/src/backend/tsearch/ts_utils.c
index c728ee2d2ac..5c4ace2bcf1 100644
--- a/src/backend/tsearch/ts_utils.c
+++ b/src/backend/tsearch/ts_utils.c
@@ -62,7 +62,7 @@ get_tsearch_config_filename(const char *basename,
static int
comparestr(const void *a, const void *b)
{
- return strcmp(*(char **) a, *(char **) b);
+ return strcmp(*(char * const *) a, *(char * const *) b);
}
/*
diff --git a/src/backend/utils/adt/tsgistidx.c b/src/backend/utils/adt/tsgistidx.c
index 1ac2b17237f..72f4a784d27 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -131,8 +131,8 @@ gtsvectorout(PG_FUNCTION_ARGS)
static int
compareint(const void *va, const void *vb)
{
- int4 a = *((int4 *) va);
- int4 b = *((int4 *) vb);
+ int4 a = *((const int4 *) va);
+ int4 b = *((const int4 *) vb);
if (a == b)
return 0;
@@ -593,8 +593,8 @@ typedef struct
static int
comparecost(const void *va, const void *vb)
{
- SPLITCOST *a = (SPLITCOST *) va;
- SPLITCOST *b = (SPLITCOST *) vb;
+ const SPLITCOST *a = (const SPLITCOST *) va;
+ const SPLITCOST *b = (const SPLITCOST *) vb;
if (a->cost == b->cost)
return 0;
diff --git a/src/backend/utils/adt/tsquery_gist.c b/src/backend/utils/adt/tsquery_gist.c
index bef86036dc1..d4468d617a4 100644
--- a/src/backend/utils/adt/tsquery_gist.c
+++ b/src/backend/utils/adt/tsquery_gist.c
@@ -156,10 +156,10 @@ typedef struct
static int
comparecost(const void *a, const void *b)
{
- if (((SPLITCOST *) a)->cost == ((SPLITCOST *) b)->cost)
+ if (((const SPLITCOST *) a)->cost == ((const SPLITCOST *) b)->cost)
return 0;
else
- return (((SPLITCOST *) a)->cost > ((SPLITCOST *) b)->cost) ? 1 : -1;
+ return (((const SPLITCOST *) a)->cost > ((const SPLITCOST *) b)->cost) ? 1 : -1;
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index 564d855817a..5a50b771fba 100644
--- a/src/backend/utils/adt/tsrank.c
+++ b/src/backend/utils/adt/tsrank.c
@@ -134,8 +134,8 @@ static int
compareQueryOperand(const void *a, const void *b, void *arg)
{
char *operand = (char *) arg;
- QueryOperand *qa = (*(QueryOperand **) a);
- QueryOperand *qb = (*(QueryOperand **) b);
+ QueryOperand *qa = (*(QueryOperand * const *) a);
+ QueryOperand *qb = (*(QueryOperand * const *) b);
return tsCompareString(operand + qa->distance, qa->length,
operand + qb->distance, qb->length,
@@ -498,8 +498,8 @@ typedef struct
static int
compareDocR(const void *va, const void *vb)
{
- DocRepresentation *a = (DocRepresentation *) va;
- DocRepresentation *b = (DocRepresentation *) vb;
+ const DocRepresentation *a = (const DocRepresentation *) va;
+ const DocRepresentation *b = (const DocRepresentation *) vb;
if (a->pos == b->pos)
return 0;
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 99b978c42c0..93ff366cd74 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -396,7 +396,7 @@ cstring_to_xmltype(const char *string)
static xmltype *
xmlBuffer_to_xmltype(xmlBufferPtr buf)
{
- return (xmltype *) cstring_to_text_with_len((char *) xmlBufferContent(buf),
+ return (xmltype *) cstring_to_text_with_len((const char *) xmlBufferContent(buf),
xmlBufferLength(buf));
}
#endif
@@ -1267,7 +1267,7 @@ static bool
print_xml_decl(StringInfo buf, const xmlChar *version,
pg_enc encoding, int standalone)
{
- if ((version && strcmp((char *) version, PG_XML_DEFAULT_VERSION) != 0)
+ if ((version && strcmp((const char *) version, PG_XML_DEFAULT_VERSION) != 0)
|| (encoding && encoding != PG_UTF8)
|| standalone != -1)
{
diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index 8af157b2d5e..0d7f471a15b 100644
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -247,8 +247,8 @@ compare1(const void *p1, const void *p2)
uint32 v1,
v2;
- v1 = *(uint32 *) p1;
- v2 = ((pg_utf_to_local *) p2)->utf;
+ v1 = *(const uint32 *) p1;
+ v2 = ((const pg_utf_to_local *) p2)->utf;
return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
}
@@ -262,8 +262,8 @@ compare2(const void *p1, const void *p2)
uint32 v1,
v2;
- v1 = *(uint32 *) p1;
- v2 = ((pg_local_to_utf *) p2)->code;
+ v1 = *(const uint32 *) p1;
+ v2 = ((const pg_local_to_utf *) p2)->code;
return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
}
@@ -279,10 +279,10 @@ compare3(const void *p1, const void *p2)
d1,
d2;
- s1 = *(uint32 *) p1;
- s2 = *((uint32 *) p1 + 1);
- d1 = ((pg_utf_to_local_combined *) p2)->utf1;
- d2 = ((pg_utf_to_local_combined *) p2)->utf2;
+ s1 = *(const uint32 *) p1;
+ s2 = *((const uint32 *) p1 + 1);
+ d1 = ((const pg_utf_to_local_combined *) p2)->utf1;
+ d2 = ((const pg_utf_to_local_combined *) p2)->utf2;
return (s1 > d1 || (s1 == d1 && s2 > d2)) ? 1 : ((s1 == d1 && s2 == d2) ? 0 : -1);
}
@@ -296,8 +296,8 @@ compare4(const void *p1, const void *p2)
uint32 v1,
v2;
- v1 = *(uint32 *) p1;
- v2 = ((pg_local_to_utf_combined *) p2)->code;
+ v1 = *(const uint32 *) p1;
+ v2 = ((const pg_local_to_utf_combined *) p2)->code;
return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
}