Skip to contentSkip to conversation

net: socket: suppress unused warning

PATCH Superseded Vincenzo Palazzo 2 participants 2 messages Mar 9, 2023 – Mar 10, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: socket: suppress unused warning

suppress unused warnings and fix the error that there is with the W=1 enabled.

Warning generated

net/socket.c: In function ‘__sys_getsockopt’:
net/socket.c:2300:13: error: variable ‘max_optlen’ set but not used [-Werror=unused-but-set-variable]
2300 | int max_optlen;

---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +1 -1
index 6bae8ce7059e..20edd4b222ca 100644
@@ -2297,7 +2297,7 @@ int __sys_getsockopt(int fd, int level, int optname, char __user *optval,
 {
 	int err, fput_needed;
 	struct socket *sock;
-	int max_optlen;
+	int max_optlen __maybe_unused;
 
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
Signature · 1 line
2.39.2
#1 lore raw
From:   Vincenzo Palazzo <[email protected]>
Date:   Thu,  9 Mar 2023 17:00:01 +0100
Quoted 19 lines

suppress unused warnings and fix the error that there is with the W=1 enabled.

Warning generated

net/socket.c: In function ‘__sys_getsockopt’:
net/socket.c:2300:13: error: variable ‘max_optlen’ set but not used [-Werror=unused-but-set-variable]
2300 | int max_optlen;

---
 net/socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/socket.c +0 -0
index 6bae8ce7059e..20edd4b222ca 100644

net/socket.c int __sys_getsockopt(int fd, int level, int optname, char __user *optval, · line 2297

Quoted 1 line
net/socket.c +0 -0
@@ -2297,7 +2297,7 @@ int __sys_getsockopt(int fd, int level, int optname, char __user *optval,
 {

Move max_optlen here to keep reverse xmas tree order.

	int max_optlen __maybe_unused;
Quoted 9 lines
net/socket.c +1 -1
 	int err, fput_needed;
 	struct socket *sock;
-	int max_optlen;
+	int max_optlen __maybe_unused;
 
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (!sock)
Signature · 1 line
2.39.2

Thanks,
Kuniyuki