Skip to contentSkip to conversation

eap: avoid nested functions

PATCH In review Marc-Antoine Perennou 3 participants 4 messages May 14, 2021 – May 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 eap: avoid nested functions

---
 src/eap.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
src/eap.c +2 -8
index 0645be47..53e35b5e 100644
@@ -416,6 +416,8 @@ static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id,
 #define IS_EXPANDED_RESPONSE(id, t) \
 	(type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
 
+#define response_is(wanted) ((type == wanted) || IS_EXPANDED_RESPONSE(0, wanted))
+
 static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
 				size_t len)
 {
@@ -428,14 +430,6 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
 				eap->method->vendor_id[2];
 	uint32_t our_vendor_type = eap->method->vendor_type;
 
-	bool response_is(enum eap_type wanted)
-	{
-		if (type == wanted)
-			return true;
-
-		return IS_EXPANDED_RESPONSE(0, wanted);
-	}
-
 	if (len < 1)
 		/* Invalid packets to be ignored */
 		return;
Signature · 1 line
2.30.0
#1 lore raw

PATCH 2/2 ap: update for new _auto_ destructors

---
 src/ap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/ap.c +1 -1
index 7eac07d7..82bdf34d 100644
@@ -3298,7 +3298,7 @@ static struct l_dbus_message *ap_dbus_start_profile(struct l_dbus *dbus,
 {
 	struct ap_if_data *ap_if = user_data;
 	const char *ssid;
-	_auto_(l_settings_free) struct l_settings *config = NULL;
+	_auto_(l_settings) config = NULL;
 	char *config_path;
 	int err;
 
Signature · 1 line
2.30.0
#2 lore raw

Re: [PATCH 2/2] ap: update for new _auto_ destructors

Heh, sorry, this one is supposed to be in another batch, off-by-one on my side.

#3 lore raw
In reply to Marc-Antoine Perennou

Hi Marc-Antoine,

Quoted 1 line · Marc-Antoine Perennou

No Signed-off-by please

src/eap.c static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id, · line 419

Quoted 13 lines
---
  src/eap.c | 10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)
src/eap.c +1 -0
index 0645be47..53e35b5e 100644
@@ -416,6 +416,8 @@ static const char *eap_type_to_str(enum eap_type type, uint32_t vendor_id,
  #define IS_EXPANDED_RESPONSE(id, t) \
  	(type == EAP_TYPE_EXPANDED && vendor_id == (id) && vendor_type == (t))
 
+#define response_is(wanted) ((type == wanted) || IS_EXPANDED_RESPONSE(0, 

Would it be safer to add '()' around wanted in at least the type == comparison?

wanted))

Quoted 10 lines
src/eap.c +1 -1
+
  static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
  				size_t len)
  {
@@ -428,14 +430,6 @@ static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt,
  				eap->method->vendor_id[2];
  	uint32_t our_vendor_type = eap->method->vendor_type;
 
-	bool response_is(enum eap_type wanted)

src/eap.c static void eap_handle_response(struct eap_state *eap, const uint8_t *pkt, · line 435

Quoted 10 lines
src/eap.c +0 -7
-	{
-		if (type == wanted)
-			return true;
-
-		return IS_EXPANDED_RESPONSE(0, wanted);
-	}
-
  	if (len < 1)
  		/* Invalid packets to be ignored */
  		return;

Regards,
-Denis