Skip to contentSkip to conversation

iwd: remove unnecessary semicolons

PATCH In review Rosen Penev 2 participants 5 messages Apr 10, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 iwd: remove unnecessary semicolons

Found with clang's -Wextra-semi-stmt

---
 monitor/nlmon.c | 27 ++++++++++++++++-----------
 src/crypto.c    |  2 +-
 src/eapol.c     |  6 +++---
 src/erp.c       |  2 +-
 src/fils.c      |  3 ++-
 src/ie.c        | 10 ++++++----
 src/main.c      |  2 +-
 src/sae.c       |  4 ++--
 src/station.c   |  2 +-
 src/wsc.c       |  2 +-
 10 files changed, 34 insertions(+), 26 deletions(-)
monitor/nlmon.c +16 -11
index 1f269ff0..df628c2c 100644
@@ -199,7 +199,7 @@ do { \
 		print_indent(4 + (level) * 4, COLOR_OFF, "", "", color, \
 								fmt, ## args)
 
-#define print_space(x) printf("%*c", (x), ' ');
+#define print_space(x) printf("%*c", (x), ' ')
 
 static void print_packet(const struct timeval *tv, char ident,
 					const char *color, const char *label,
@@ -3042,10 +3042,13 @@ static void print_p2p_status(unsigned int level, const char *label,
 }
 
 #define CHECK_CAPS_BIT(v, str)	\
-	if (caps & (v)) {	\
-		print_attr(level + 1, "%s", (str));	\
-		caps &= ~(v);	\
-	}
+	do {			\
+		if (caps & (v)) {				\
+			print_attr(level + 1, "%s", (str));	\
+			caps &= ~(v);				\
+		} 						\
+	} while(0)
+
 static void print_p2p_device_capability(unsigned int level, const char *label,
 					const void *data, uint16_t size)
 {
@@ -3178,11 +3181,13 @@ static void print_p2p_manageability(unsigned int level, const char *label,
 		return;
 	}
 
-#define CHECK_BIT(v, str)	\
-	if (val & (v)) {	\
-		print_attr(level + 1, "%s", (str));	\
-		val &= ~(v);	\
-	}
+#define CHECK_BIT(v, str)					\
+	do {							\
+		if (val & (v)) {				\
+			print_attr(level + 1, "%s", (str));	\
+			val &= ~(v);				\
+		}						\
+	} while(0)
 
 	val = *(const uint8_t *) data;
 
@@ -5239,7 +5244,7 @@ static void print_eap(unsigned int level, const void *data, uint32_t size)
 	default:
 		str = "Reserved";
 		break;
-	};
+	}
 
 	print_attr(level, "Code: %u (%s)", eap[0], str);
 	print_attr(level, "Identifier: %u", eap[1]);
src/crypto.c +1 -1
index c1fe83a2..696b5990 100644
@@ -469,7 +469,7 @@ int crypto_cipher_key_len(enum crypto_cipher cipher)
 		return 16;
 	case CRYPTO_CIPHER_BIP:
 		return 16;
-	};
+	}
 
 	return 0;
 }
src/eapol.c +3 -3
index 2c4b3dcd..b0036c10 100644
@@ -279,7 +279,7 @@ uint8_t *eapol_decrypt_key_data(enum ie_rsn_akm_suite akm, const uint8_t *kek,
 		break;
 	default:
 		return NULL;
-	};
+	}
 
 	buf = l_new(uint8_t, expected_len);
 
@@ -1674,7 +1674,7 @@ static void eapol_handle_ptk_3_of_4(struct eapol_sm *sm,
 			return;
 		}
 
-		igtk_key_index = l_get_le16(igtk);;
+		igtk_key_index = l_get_le16(igtk);
 		igtk += 2;
 		igtk_len -= 2;
 	} else
@@ -1834,7 +1834,7 @@ static void eapol_handle_gtk_1_of_2(struct eapol_sm *sm,
 		if (!igtk)
 			return;
 
-		igtk_key_index = l_get_le16(igtk);;
+		igtk_key_index = l_get_le16(igtk);
 		igtk += 2;
 		igtk_len -= 2;
 	} else
src/erp.c +1 -1
index cacd37d1..8c6f971c 100644
@@ -308,7 +308,7 @@ static bool erp_derive_reauth_keys(const uint8_t *emsk, size_t emsk_len,
 					void *r_rk, void *r_ik)
 {
 	char info[256];
-	char *ptr;;
+	char *ptr;
 
 	ptr = info + l_strlcpy(info, ERP_RRK_LABEL, sizeof(info)) + 1;
 
src/fils.c +2 -1
index 4291e792..2d2a0913 100644
@@ -1,3 +1,4 @@
+
 /*
  *
  *  Wireless daemon for Linux
@@ -508,7 +509,7 @@ static int fils_rx_associate(struct auth_proto *driver, const uint8_t *frame,
 			if (!igtk)
 				goto invalid_ies;
 
-			igtk_key_index = l_get_le16(igtk);;
+			igtk_key_index = l_get_le16(igtk);
 			igtk += 2;
 			igtk_len -= 2;
 
src/ie.c +6 -4
index 8d212ea0..4b2e3780 100644
@@ -915,10 +915,12 @@ static bool ie_build_cipher_suite(uint8_t *data, const uint8_t *oui,
 	return false;
 }
 
-#define RETURN_AKM(data, oui, id)	\
-	memcpy((data), (oui), 3);	\
-	(data)[3] = (id);		\
-	return true;
+#define RETURN_AKM(data, oui, id)		\
+	do {					\
+		memcpy((data), (oui), 3);	\
+		(data)[3] = (id);		\
+		return true;			\
+	} while(0)
 
 /* 802.11-2016, Section 9.4.2.25.3 */
 static bool ie_build_rsn_akm_suite(uint8_t *data, enum ie_rsn_akm_suite suite)
src/main.c +1 -1
index 831fb315..f8f3043d 100644
@@ -339,7 +339,7 @@ static int check_crypto()
 		l_hashmap_insert(options, "CONFIG_PKCS7_MESSAGE_PARSER", &r);
 		l_hashmap_insert(options,
 					"CONFIG_PKCS8_PRIVATE_KEY_PARSER", &r);
-	};
+	}
 
 	if (l_hashmap_isempty(options))
 		goto done;
src/sae.c +2 -2
index 6abbad5e..97e3348e 100644
@@ -144,9 +144,9 @@ static bool sae_cn(const uint8_t *kck, uint16_t send_confirm,
 	iov[2].iov_base = (void *) e1;
 	iov[2].iov_len = l_ecc_point_get_data(element1, e1, sizeof(e1));
 	iov[3].iov_base = (void *) s2;
-	iov[3].iov_len = l_ecc_scalar_get_data(scalar2, s2, sizeof(s2));;
+	iov[3].iov_len = l_ecc_scalar_get_data(scalar2, s2, sizeof(s2));
 	iov[4].iov_base = (void *) e2;
-	iov[4].iov_len = l_ecc_point_get_data(element2, e2, sizeof(e2));;
+	iov[4].iov_len = l_ecc_point_get_data(element2, e2, sizeof(e2));
 
 	l_checksum_updatev(hmac, iov, 5);
 
src/station.c +1 -1
index ca47568c..d57a0f8d 100644
@@ -2174,7 +2174,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event,
 	case NETDEV_EVENT_RSSI_LEVEL_NOTIFY:
 		station_rssi_level_changed(station, l_get_u8(event_data));
 		break;
-	};
+	}
 }
 
 static bool station_try_next_bss(struct station *station)
src/wsc.c +1 -1
index ba58b6d4..2ac6de9c 100644
@@ -262,7 +262,7 @@ static void wsc_enrollee_netdev_event(struct netdev *netdev,
 	default:
 		l_debug("Unexpected event: %d", event);
 		break;
-	};
+	}
 }
 
 static void wsc_enrollee_handshake_event(struct handshake_state *hs,
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 module: add void to empty argument functions

Found with clang's -Wstrict-prototypes

---
 src/module.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/module.h +2 -2
index c0f1c6c1..8e1a9904 100644
@@ -47,5 +47,5 @@ struct iwd_module_depends {
 			.target = #dep,					\
 		};
 
-int iwd_modules_init();
-void iwd_modules_exit();
+int iwd_modules_init(void);
+void iwd_modules_exit(void);
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 nlmon: make len parameter a size_t

In reply to Rosen Penev

Fixes a sign comparison warning. Found with -Wsign-compare

---
 monitor/nlmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/nlmon.c +1 -1
index df628c2c..e54ae2e9 100644
@@ -7171,7 +7171,7 @@ static bool nlmon_receive(struct l_io *io, void *user_data)
 	unsigned char buf[8192];
 	unsigned char control[32];
 	ssize_t bytes_read;
-	int nlmsg_len;
+	size_t nlmsg_len;
 	int fd;
 
 	fd = l_io_get_fd(io);
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH 3/3] nlmon: make len parameter a size_t

Hi Rosen,

Quoted 10 lines · Rosen Penev

Fixes a sign comparison warning. Found with -Wsign-compare

---
  monitor/nlmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
monitor/nlmon.c +0 -0
index df628c2c..e54ae2e9 100644

monitor/nlmon.c static bool nlmon_receive(struct l_io *io, void *user_data) · line 7174

Quoted 5 lines
monitor/nlmon.c +1 -1
@@ -7171,7 +7171,7 @@ static bool nlmon_receive(struct l_io *io, void *user_data)
  	unsigned char buf[8192];
  	unsigned char control[32];
  	ssize_t bytes_read;
-	int nlmsg_len;
+	size_t nlmsg_len;

I think a different fix is neeeded. Please see commit 98e1d38056e7 ("monitor: Fix crash") for why this is an int.

Which line in particular are you seeing the sign comparison warning on?

Regards,
-Denis

#4 lore raw
In reply to Rosen Penev

Hi Rosen,

Quoted 14 lines · Rosen Penev

Found with clang's -Wextra-semi-stmt

---
  monitor/nlmon.c | 27 ++++++++++++++++-----------
  src/crypto.c    |  2 +-
  src/eapol.c     |  6 +++---
  src/erp.c       |  2 +-
  src/fils.c      |  3 ++-
  src/ie.c        | 10 ++++++----
  src/main.c      |  2 +-
  src/sae.c       |  4 ++--
  src/station.c   |  2 +-
  src/wsc.c       |  2 +-
  10 files changed, 34 insertions(+), 26 deletions(-)

Patches 1 & 2 applied, thanks.

Regards,
-Denis