1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-21 00:42:43 +03:00

Remove various unnecessary (char *) casts

Remove a number of (char *) casts that are unnecessary.  Or in some
cases, rewrite the code to make the purpose of the cast clearer.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Discussion: https://www.postgresql.org/message-id/flat/fd1fcedb-3492-4fc8-9e3e-74b97f2db6c7%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-02-20 19:49:27 +01:00
parent ab84d0ff80
commit 3e4d868615
18 changed files with 34 additions and 32 deletions

View File

@@ -4287,7 +4287,7 @@ WriteControlFile(void)
/* Contents are protected with a CRC */
INIT_CRC32C(ControlFile->crc);
COMP_CRC32C(ControlFile->crc,
(char *) ControlFile,
ControlFile,
offsetof(ControlFileData, crc));
FIN_CRC32C(ControlFile->crc);
@@ -4405,7 +4405,7 @@ ReadControlFile(void)
/* Now check the CRC. */
INIT_CRC32C(crc);
COMP_CRC32C(crc,
(char *) ControlFile,
ControlFile,
offsetof(ControlFileData, crc));
FIN_CRC32C(crc);

View File

@@ -2932,8 +2932,8 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
radius_packet radius_recv_pack;
radius_packet *packet = &radius_send_pack;
radius_packet *receivepacket = &radius_recv_pack;
char *radius_buffer = (char *) &radius_send_pack;
char *receive_buffer = (char *) &radius_recv_pack;
void *radius_buffer = &radius_send_pack;
void *receive_buffer = &radius_recv_pack;
int32 service = pg_hton32(RADIUS_AUTHENTICATE_ONLY);
uint8 *cryptvector;
int encryptedpasswordlen;
@@ -3204,7 +3204,9 @@ PerformRadiusTransaction(const char *server, const char *secret, const char *por
* original packet */
if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no
* attributes at all */
memcpy(cryptvector + RADIUS_HEADER_LENGTH, receive_buffer + RADIUS_HEADER_LENGTH, packetlength - RADIUS_HEADER_LENGTH);
memcpy(cryptvector + RADIUS_HEADER_LENGTH,
(char *) receive_buffer + RADIUS_HEADER_LENGTH,
packetlength - RADIUS_HEADER_LENGTH);
memcpy(cryptvector + packetlength, secret, strlen(secret));
if (!pg_md5_binary(cryptvector,

View File

@@ -40,7 +40,7 @@
/* Copy a field that is a pointer to a C string, or perhaps NULL */
#define COPY_STRING_FIELD(fldname) \
(newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
(newnode->fldname = from->fldname ? pstrdup(from->fldname) : NULL)
/* Copy a field that is an inline array */
#define COPY_ARRAY_FIELD(fldname) \

View File

@@ -51,7 +51,7 @@ makeSimpleA_Expr(A_Expr_Kind kind, char *name,
A_Expr *a = makeNode(A_Expr);
a->kind = kind;
a->name = list_make1(makeString((char *) name));
a->name = list_make1(makeString(name));
a->lexpr = lexpr;
a->rexpr = rexpr;
a->location = location;

View File

@@ -1502,7 +1502,7 @@ PageSetChecksumCopy(Page page, BlockNumber blkno)
/* If we don't need a checksum, just return the passed-in data */
if (PageIsNew(page) || !DataChecksumsEnabled())
return (char *) page;
return page;
/*
* We allocate the copy space once and use it over on each subsequent

View File

@@ -854,7 +854,7 @@ read_relmap_file(RelMapFile *map, char *dbpath, bool lock_held, int elevel)
/* verify the CRC */
INIT_CRC32C(crc);
COMP_CRC32C(crc, (char *) map, offsetof(RelMapFile, crc));
COMP_CRC32C(crc, map, offsetof(RelMapFile, crc));
FIN_CRC32C(crc);
if (!EQ_CRC32C(crc, map->crc))
@@ -910,7 +910,7 @@ write_relmap_file(RelMapFile *newmap, bool write_wal, bool send_sinval,
elog(ERROR, "attempt to write bogus relation mapping");
INIT_CRC32C(newmap->crc);
COMP_CRC32C(newmap->crc, (char *) newmap, offsetof(RelMapFile, crc));
COMP_CRC32C(newmap->crc, newmap, offsetof(RelMapFile, crc));
FIN_CRC32C(newmap->crc);
/*

View File

@@ -206,7 +206,7 @@ write_jsonlog(ErrorData *edata)
/* Error severity */
if (edata->elevel)
appendJSONKeyValue(&buf, "error_severity",
(char *) error_severity(edata->elevel), true);
error_severity(edata->elevel), true);
/* SQL state code */
if (edata->sqlerrcode)