Skip to contentSkip to conversation

handshake: use _hs directly in handshake_event

PATCH Applied James Prestwood 2 participants 2 messages Jan 26, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/1 handshake: use _hs directly in handshake_event

Certain platforms/compilers were having issues with using the 'hs' local in this macro (likely has something to do with the caller also using a local 'hs' variable name). This caused a crash on these platforms. Using the macro argument _hs directly fixes the crash.

---
 src/handshake.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
src/handshake.h +6 -7
index 34d4829d..7136087a 100644
@@ -166,19 +166,18 @@ struct handshake_state {
 
 #define handshake_event(_hs, event, ...)	\
 	(__extension__ ({	\
-		struct handshake_state *hs = (_hs);	\
 		bool freed = false;	\
 	\
-		if (hs->event_func && !hs->in_event) {	\
-			hs->in_event = true;	\
-			hs->event_func(hs, event, hs->user_data,	\
+		if ((_hs)->event_func && !(_hs)->in_event) {	\
+			(_hs)->in_event = true;	\
+			(_hs)->event_func((_hs), event, (_hs)->user_data,	\
 					##__VA_ARGS__); \
 	\
-			if (!hs->in_event) {	\
-				handshake_state_free(hs);	\
+			if (!(_hs)->in_event) {	\
+				handshake_state_free((_hs));	\
 				freed = true;	\
 			} else	\
-				hs->in_event = false;	\
+				(_hs)->in_event = false;	\
 		}	\
 		freed;	\
 	}))
Signature · 1 line
2.31.1
Applied
#1 lore raw

Hi James,

Quoted 8 lines · James Prestwood

Certain platforms/compilers were having issues with using the 'hs' local in this macro (likely has something to do with the caller also using a local 'hs' variable name). This caused a crash on these platforms. Using the macro argument _hs directly fixes the crash.

---
  src/handshake.h | 13 ++++++-------
  1 file changed, 6 insertions(+), 7 deletions(-)

Applied, thanks.

Regards,
-Denis