Skip to content

Commit dde16d5

Browse files
committed
Remove useless cast in setsockopt call (closes #721)
1 parent 8e769e7 commit dde16d5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/modbus-tcp.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int _modbus_tcp_set_ipv4_options(int s)
230230
/* Set the TCP no delay flag */
231231
/* SOL_TCP = IPPROTO_TCP */
232232
option = 1;
233-
rc = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const void *) &option, sizeof(int));
233+
rc = setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof(int));
234234
if (rc == -1) {
235235
return -1;
236236
}
@@ -258,7 +258,7 @@ static int _modbus_tcp_set_ipv4_options(int s)
258258
**/
259259
/* Set the IP low delay option */
260260
option = IPTOS_LOWDELAY;
261-
rc = setsockopt(s, IPPROTO_IP, IP_TOS, (const void *) &option, sizeof(int));
261+
rc = setsockopt(s, IPPROTO_IP, IP_TOS, &option, sizeof(int));
262262
if (rc == -1) {
263263
return -1;
264264
}
@@ -547,8 +547,7 @@ int modbus_tcp_listen(modbus_t *ctx, int nb_connection)
547547
}
548548

549549
enable = 1;
550-
if (setsockopt(new_s, SOL_SOCKET, SO_REUSEADDR, (char *) &enable, sizeof(enable)) ==
551-
-1) {
550+
if (setsockopt(new_s, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) {
552551
close(new_s);
553552
return -1;
554553
}
@@ -665,8 +664,7 @@ int modbus_tcp_pi_listen(modbus_t *ctx, int nb_connection)
665664
continue;
666665
} else {
667666
int enable = 1;
668-
rc =
669-
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *) &enable, sizeof(enable));
667+
rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
670668
if (rc != 0) {
671669
close(s);
672670
if (ctx->debug) {

0 commit comments

Comments
 (0)