Change argument type of pq_sendbytes from char * to void *
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 14 Feb 2023 12:32:19 +0000 (13:32 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 14 Feb 2023 12:32:19 +0000 (13:32 +0100)
This is a follow-up to 1f605b82ba66ece8b421b10d41094dd2e3c0c48b.  It
allows getting rid of further casts at call sites.

Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/783a4edb-84f9-6df2-7470-2ef5ccc6607a@enterprisedb.com

src/backend/libpq/pqformat.c
src/backend/utils/adt/array_userfuncs.c
src/backend/utils/adt/uuid.c
src/backend/utils/adt/varbit.c
src/include/libpq/pqformat.h

index b7e2c7b6c90fa70839055bff8a6911d48897031c..d712c80b5e76b7b488211291bbb63c51203c7cad 100644 (file)
@@ -123,7 +123,7 @@ pq_beginmessage_reuse(StringInfo buf, char msgtype)
  * --------------------------------
  */
 void
-pq_sendbytes(StringInfo buf, const char *data, int datalen)
+pq_sendbytes(StringInfo buf, const void *data, int datalen)
 {
    /* use variant that maintains a trailing null-byte, out of caution */
    appendBinaryStringInfo(buf, data, datalen);
index c8a8d33ca35a9c38cde947301183448f286a0fd3..80750191d8d2d79870c8d242c000bb61dd912c94 100644 (file)
@@ -654,7 +654,7 @@ array_agg_serialize(PG_FUNCTION_ARGS)
    pq_sendbyte(&buf, state->typalign);
 
    /* dnulls */
-   pq_sendbytes(&buf, (char *) state->dnulls, sizeof(bool) * state->nelems);
+   pq_sendbytes(&buf, state->dnulls, sizeof(bool) * state->nelems);
 
    /*
     * dvalues.  By agreement with array_agg_deserialize, when the element
@@ -664,8 +664,7 @@ array_agg_serialize(PG_FUNCTION_ARGS)
     * must be sent first).
     */
    if (state->typbyval)
-       pq_sendbytes(&buf, (char *) state->dvalues,
-                    sizeof(Datum) * state->nelems);
+       pq_sendbytes(&buf, state->dvalues, sizeof(Datum) * state->nelems);
    else
    {
        SerialIOData *iodata;
@@ -1097,7 +1096,7 @@ array_agg_array_serialize(PG_FUNCTION_ARGS)
    if (state->nullbitmap)
    {
        Assert(state->aitems > 0);
-       pq_sendbytes(&buf, (char *) state->nullbitmap, (state->aitems + 7) / 8);
+       pq_sendbytes(&buf, state->nullbitmap, (state->aitems + 7) / 8);
    }
 
    /* nitems */
@@ -1107,10 +1106,10 @@ array_agg_array_serialize(PG_FUNCTION_ARGS)
    pq_sendint32(&buf, state->ndims);
 
    /* dims: XXX should we just send ndims elements? */
-   pq_sendbytes(&buf, (char *) state->dims, sizeof(state->dims));
+   pq_sendbytes(&buf, state->dims, sizeof(state->dims));
 
    /* lbs */
-   pq_sendbytes(&buf, (char *) state->lbs, sizeof(state->lbs));
+   pq_sendbytes(&buf, state->lbs, sizeof(state->lbs));
 
    result = pq_endtypsend(&buf);
 
index 76ff6c533f8c66009c77d7ba7397cbc0ba279067..4f7aa768fda4db6936b875ffcd054836ca5586b5 100644 (file)
@@ -154,7 +154,7 @@ uuid_send(PG_FUNCTION_ARGS)
    StringInfoData buffer;
 
    pq_begintypsend(&buffer);
-   pq_sendbytes(&buffer, (char *) uuid->data, UUID_LEN);
+   pq_sendbytes(&buffer, uuid->data, UUID_LEN);
    PG_RETURN_BYTEA_P(pq_endtypsend(&buffer));
 }
 
index 4fde0c1b1439e23dacc8f7a12c9f9f881cdf3067..3dbbd1207f9ddb944d7f5922cb67f971ea45ffac 100644 (file)
@@ -685,7 +685,7 @@ varbit_send(PG_FUNCTION_ARGS)
 
    pq_begintypsend(&buf);
    pq_sendint32(&buf, VARBITLEN(s));
-   pq_sendbytes(&buf, (char *) VARBITS(s), VARBITBYTES(s));
+   pq_sendbytes(&buf, VARBITS(s), VARBITBYTES(s));
    PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
 }
 
index c5644c0061a9f4c7d9b4526bd3f1cc103a888da3..0d2f958af33dd12b753364b5bbf28e19a8e8c8ca 100644 (file)
@@ -22,7 +22,7 @@ extern void pq_beginmessage_reuse(StringInfo buf, char msgtype);
 extern void pq_endmessage(StringInfo buf);
 extern void pq_endmessage_reuse(StringInfo buf);
 
-extern void pq_sendbytes(StringInfo buf, const char *data, int datalen);
+extern void pq_sendbytes(StringInfo buf, const void *data, int datalen);
 extern void pq_sendcountedtext(StringInfo buf, const char *str, int slen,
                               bool countincludesself);
 extern void pq_sendtext(StringInfo buf, const char *str, int slen);