Просмотр исходного кода

Optimize security macro using unlikely branch

Andrew Savchenko лет назад: 3
Родитель
Сommit
707c7029e7
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      macros.h

+ 2 - 2
macros.h

@@ -50,12 +50,12 @@
 #define MSG_SECURITY_PROBLEM(a) "Security problem: "a". Don't use this application until the bug will be fixed. Report about the problem to: "AUTHOR
 
 #define require_strlen_le(str, limit) \
-	if (strlen(str) >= limit)\
+	if (unlikely( strlen(str) >= limit ))\
 		critical("length of "TOSTR(str)" (\"%s\") >= "TOSTR(limit));\
 	 
 #define SAFE(code, onfail) __extension__({\
 		long _SAFE_rc;\
-		if ((_SAFE_rc = code)) {\
+		if (unlikely((_SAFE_rc = code))) {\
 			error("Got error while "TOSTR(code));\
 			onfail;\
 		} \