Skip to content

Commit 1f605b8

Browse files
committed
Change argument of appendBinaryStringInfo from char * to void *
There is some code that uses this function to assemble some kind of packed binary layout, which requires a bunch of casts because of this. Functions taking binary data plus length should take void * instead, like memcpy() for example. Discussion: https://www.postgresql.org/message-id/flat/a0086cfc-ff0f-2827-20fe-52b591d2666c%40enterprisedb.com
1 parent 33a33f0 commit 1f605b8

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/backend/utils/adt/jsonpath.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,18 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
267267
case jpiString:
268268
case jpiVariable:
269269
case jpiKey:
270-
appendBinaryStringInfo(buf, (char *) &item->value.string.len,
270+
appendBinaryStringInfo(buf, &item->value.string.len,
271271
sizeof(item->value.string.len));
272272
appendBinaryStringInfo(buf, item->value.string.val,
273273
item->value.string.len);
274274
appendStringInfoChar(buf, '\0');
275275
break;
276276
case jpiNumeric:
277-
appendBinaryStringInfo(buf, (char *) item->value.numeric,
277+
appendBinaryStringInfo(buf, item->value.numeric,
278278
VARSIZE(item->value.numeric));
279279
break;
280280
case jpiBool:
281-
appendBinaryStringInfo(buf, (char *) &item->value.boolean,
281+
appendBinaryStringInfo(buf, &item->value.boolean,
282282
sizeof(item->value.boolean));
283283
break;
284284
case jpiAnd:
@@ -328,11 +328,11 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
328328
int32 offs;
329329

330330
appendBinaryStringInfo(buf,
331-
(char *) &item->value.like_regex.flags,
331+
&item->value.like_regex.flags,
332332
sizeof(item->value.like_regex.flags));
333333
offs = reserveSpaceForItemPointer(buf);
334334
appendBinaryStringInfo(buf,
335-
(char *) &item->value.like_regex.patternlen,
335+
&item->value.like_regex.patternlen,
336336
sizeof(item->value.like_regex.patternlen));
337337
appendBinaryStringInfo(buf, item->value.like_regex.pattern,
338338
item->value.like_regex.patternlen);
@@ -393,7 +393,7 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
393393
int offset;
394394
int i;
395395

396-
appendBinaryStringInfo(buf, (char *) &nelems, sizeof(nelems));
396+
appendBinaryStringInfo(buf, &nelems, sizeof(nelems));
397397

398398
offset = buf->len;
399399

@@ -431,10 +431,10 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
431431
break;
432432
case jpiAny:
433433
appendBinaryStringInfo(buf,
434-
(char *) &item->value.anybounds.first,
434+
&item->value.anybounds.first,
435435
sizeof(item->value.anybounds.first));
436436
appendBinaryStringInfo(buf,
437-
(char *) &item->value.anybounds.last,
437+
&item->value.anybounds.last,
438438
sizeof(item->value.anybounds.last));
439439
break;
440440
case jpiType:
@@ -496,7 +496,7 @@ reserveSpaceForItemPointer(StringInfo buf)
496496
int32 pos = buf->len;
497497
int32 ptr = 0;
498498

499-
appendBinaryStringInfo(buf, (char *) &ptr, sizeof(ptr));
499+
appendBinaryStringInfo(buf, &ptr, sizeof(ptr));
500500

501501
return pos;
502502
}

src/backend/utils/adt/xid8funcs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ buf_init(FullTransactionId xmin, FullTransactionId xmax)
260260
snap.nxip = 0;
261261

262262
buf = makeStringInfo();
263-
appendBinaryStringInfo(buf, (char *) &snap, PG_SNAPSHOT_SIZE(0));
263+
appendBinaryStringInfo(buf, &snap, PG_SNAPSHOT_SIZE(0));
264264
return buf;
265265
}
266266

@@ -272,7 +272,7 @@ buf_add_txid(StringInfo buf, FullTransactionId fxid)
272272
/* do this before possible realloc */
273273
snap->nxip++;
274274

275-
appendBinaryStringInfo(buf, (char *) &fxid, sizeof(fxid));
275+
appendBinaryStringInfo(buf, &fxid, sizeof(fxid));
276276
}
277277

278278
static pg_snapshot *

src/common/stringinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ appendStringInfoSpaces(StringInfo str, int count)
224224
* if necessary. Ensures that a trailing null byte is present.
225225
*/
226226
void
227-
appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
227+
appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
228228
{
229229
Assert(str != NULL);
230230

@@ -250,7 +250,7 @@ appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
250250
* if necessary. Does not ensure a trailing null-byte exists.
251251
*/
252252
void
253-
appendBinaryStringInfoNT(StringInfo str, const char *data, int datalen)
253+
appendBinaryStringInfoNT(StringInfo str, const void *data, int datalen)
254254
{
255255
Assert(str != NULL);
256256

src/include/lib/stringinfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ extern void appendStringInfoSpaces(StringInfo str, int count);
142142
* if necessary.
143143
*/
144144
extern void appendBinaryStringInfo(StringInfo str,
145-
const char *data, int datalen);
145+
const void *data, int datalen);
146146

147147
/*------------------------
148148
* appendBinaryStringInfoNT
149149
* Append arbitrary binary data to a StringInfo, allocating more space
150150
* if necessary. Does not ensure a trailing null-byte exists.
151151
*/
152152
extern void appendBinaryStringInfoNT(StringInfo str,
153-
const char *data, int datalen);
153+
const void *data, int datalen);
154154

155155
/*------------------------
156156
* enlargeStringInfo

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