Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 506183b

Browse files
committed
Remove unnecessary (char *) casts [string]
Remove (char *) casts around string functions where the arguments or result already have the right type and the cast is useless (or worse, potentially casts away a qualifier, but this doesn't appear to be the case here). Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://www.postgresql.org/message-id/flat/fd1fcedb-3492-4fc8-9e3e-74b97f2db6c7%40eisentraut.org
1 parent 0bc34ad commit 506183b

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

contrib/fuzzystrmatch/dmetaphone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,13 @@ IsVowel(metastring *s, int pos)
308308
static int
309309
SlavoGermanic(metastring *s)
310310
{
311-
if ((char *) strstr(s->str, "W"))
311+
if (strstr(s->str, "W"))
312312
return 1;
313-
else if ((char *) strstr(s->str, "K"))
313+
else if (strstr(s->str, "K"))
314314
return 1;
315-
else if ((char *) strstr(s->str, "CZ"))
315+
else if (strstr(s->str, "CZ"))
316316
return 1;
317-
else if ((char *) strstr(s->str, "WITZ"))
317+
else if (strstr(s->str, "WITZ"))
318318
return 1;
319319
else
320320
return 0;

doc/src/sgml/gist.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ fill_my_string_relopt(const char *value, void *ptr)
10271027
int len = strlen(tmp);
10281028

10291029
if (ptr)
1030-
strcpy((char *) ptr, tmp);
1030+
strcpy(ptr, tmp);
10311031

10321032
pfree(tmp);
10331033
return len + 1;

src/backend/replication/walreceiver.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
249249

250250
/* Fetch information required to start streaming */
251251
walrcv->ready_to_display = false;
252-
strlcpy(conninfo, (char *) walrcv->conninfo, MAXCONNINFO);
253-
strlcpy(slotname, (char *) walrcv->slotname, NAMEDATALEN);
252+
strlcpy(conninfo, walrcv->conninfo, MAXCONNINFO);
253+
strlcpy(slotname, walrcv->slotname, NAMEDATALEN);
254254
is_temp_slot = walrcv->is_temp_slot;
255255
startpoint = walrcv->receiveStart;
256256
startpointTLI = walrcv->receiveStartTLI;
@@ -317,11 +317,11 @@ WalReceiverMain(char *startup_data, size_t startup_data_len)
317317
SpinLockAcquire(&walrcv->mutex);
318318
memset(walrcv->conninfo, 0, MAXCONNINFO);
319319
if (tmp_conninfo)
320-
strlcpy((char *) walrcv->conninfo, tmp_conninfo, MAXCONNINFO);
320+
strlcpy(walrcv->conninfo, tmp_conninfo, MAXCONNINFO);
321321

322322
memset(walrcv->sender_host, 0, NI_MAXHOST);
323323
if (sender_host)
324-
strlcpy((char *) walrcv->sender_host, sender_host, NI_MAXHOST);
324+
strlcpy(walrcv->sender_host, sender_host, NI_MAXHOST);
325325

326326
walrcv->sender_port = sender_port;
327327
walrcv->ready_to_display = true;
@@ -1434,10 +1434,10 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
14341434
last_receipt_time = WalRcv->lastMsgReceiptTime;
14351435
latest_end_lsn = WalRcv->latestWalEnd;
14361436
latest_end_time = WalRcv->latestWalEndTime;
1437-
strlcpy(slotname, (char *) WalRcv->slotname, sizeof(slotname));
1438-
strlcpy(sender_host, (char *) WalRcv->sender_host, sizeof(sender_host));
1437+
strlcpy(slotname, WalRcv->slotname, sizeof(slotname));
1438+
strlcpy(sender_host, WalRcv->sender_host, sizeof(sender_host));
14391439
sender_port = WalRcv->sender_port;
1440-
strlcpy(conninfo, (char *) WalRcv->conninfo, sizeof(conninfo));
1440+
strlcpy(conninfo, WalRcv->conninfo, sizeof(conninfo));
14411441
SpinLockRelease(&WalRcv->mutex);
14421442

14431443
/*

src/backend/replication/walreceiverfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
267267
walrcv->walRcvState == WALRCV_WAITING);
268268

269269
if (conninfo != NULL)
270-
strlcpy((char *) walrcv->conninfo, conninfo, MAXCONNINFO);
270+
strlcpy(walrcv->conninfo, conninfo, MAXCONNINFO);
271271
else
272272
walrcv->conninfo[0] = '\0';
273273

@@ -279,7 +279,7 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo,
279279
*/
280280
if (slotname != NULL && slotname[0] != '\0')
281281
{
282-
strlcpy((char *) walrcv->slotname, slotname, NAMEDATALEN);
282+
strlcpy(walrcv->slotname, slotname, NAMEDATALEN);
283283
walrcv->is_temp_slot = false;
284284
}
285285
else

src/backend/utils/activity/backend_status.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,11 +795,11 @@ pgstat_read_current_status(void)
795795
* strcpy is safe even if the string is modified concurrently,
796796
* because there's always a \0 at the end of the buffer.
797797
*/
798-
strcpy(localappname, (char *) beentry->st_appname);
798+
strcpy(localappname, beentry->st_appname);
799799
localentry->backendStatus.st_appname = localappname;
800-
strcpy(localclienthostname, (char *) beentry->st_clienthostname);
800+
strcpy(localclienthostname, beentry->st_clienthostname);
801801
localentry->backendStatus.st_clienthostname = localclienthostname;
802-
strcpy(localactivity, (char *) beentry->st_activity_raw);
802+
strcpy(localactivity, beentry->st_activity_raw);
803803
localentry->backendStatus.st_activity_raw = localactivity;
804804
#ifdef USE_SSL
805805
if (beentry->st_ssl)

src/interfaces/ecpg/pgtypeslib/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pgtypes_alloc(long size)
1919
char *
2020
pgtypes_strdup(const char *str)
2121
{
22-
char *new = (char *) strdup(str);
22+
char *new = strdup(str);
2323

2424
if (!new)
2525
errno = ENOMEM;

0 commit comments

Comments
 (0)