Skip to contentSkip to conversation

unit: Address -Werror=unused-but-set-parameter compilation errors.

PATCH New Grant Erickson 1 participant 1 message Nov 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unit: Address -Werror=unused-but-set-parameter compilation errors.

This addresses a -Werror=unused-but-set-parameter compilation error surfaced by both GCC and clang/LLVM in the 'getsockopt' socket dummy in the iptables unit test when --enable-maintainer-mode is asserted and connman is configured with --with-firewall=iptables:

unit/test-iptables.c:302:58: error: parameter 'optval' set but not
used [-Werror=unused-but-set-parameter]

Each assignment to 'optval' only changed the dummy's local copy of the pointer and never reached the caller, so the assignments, and the always-NULL locals they assigned from, are removed. Behavior is unchanged.

---
 unit/test-iptables.c | 9 ---------
 1 file changed, 9 deletions(-)
unit/test-iptables.c +0 -9
index a96d8679f46b..5be41ac683a9 100644
@@ -302,11 +302,6 @@ int socket(int domain, int type, int protocol)
 int getsockopt(int sockfd, int level, int optname, void *optval,
 			socklen_t *optlen)
 {
-	struct ipt_getinfo *info = NULL;
-	struct ipt_get_entries *entries = NULL;
-	struct ip6t_getinfo *info6 = NULL;
-	struct ip6t_get_entries *entries6 = NULL;
-
 	DBG("");
 
 	g_assert_cmpint(global_sockfd, ==, sockfd);
@@ -318,11 +313,9 @@ int getsockopt(int sockfd, int level, int optname, void *optval,
 		switch (optname) {
 		case IPT_SO_GET_ENTRIES:
 			DBG("IPT_SO_GET_ENTRIES");
-			optval = entries;
 			break;
 		case IPT_SO_GET_INFO:
 			DBG("IPT_SO_GET_INFO");
-			optval = info;
 			break;
 		default:
 			DBG("optname %d", optname);
@@ -335,11 +328,9 @@ int getsockopt(int sockfd, int level, int optname, void *optval,
 		switch (optname) {
 		case IP6T_SO_GET_ENTRIES:
 			DBG("IP6T_SO_GET_ENTRIES");
-			optval = entries6;
 			break;
 		case IP6T_SO_GET_INFO:
 			DBG("IP6T_SO_GET_INFO");
-			optval = info6;
 			break;
 		default:
 			DBG("optname %d", optname);
Signature · 1 line
2.52.0