From d789a97ac5f3f2c1c771a8bf1a5a3a5eca53e787 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 24 Apr 2023 21:46:45 +0300 Subject: [PATCH 38/38] Rearrange sg_failure_ret[_val]() To make it clear to compiler/analyzer that sg_success is FALSE after this, and not potentially restored to TRUE by the logging call. See osdn #45822 Signed-off-by: Marko Lindqvist --- server/savegame/savecompat.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/savegame/savecompat.h b/server/savegame/savecompat.h index b4afc786c3..5fcf81bbd9 100644 --- a/server/savegame/savecompat.h +++ b/server/savegame/savecompat.h @@ -151,6 +151,7 @@ struct loaddata { if (!sg_success) { \ return; \ } + #define sg_check_ret_val(_val) \ if (!sg_success) { \ return _val; \ @@ -160,11 +161,13 @@ struct loaddata { if (!(condition)) { \ log_sg(message, ## __VA_ARGS__); \ } + #define sg_warn_ret(condition, message, ...) \ if (!(condition)) { \ log_sg(message, ## __VA_ARGS__); \ return; \ } + #define sg_warn_ret_val(condition, _val, message, ...) \ if (!(condition)) { \ log_sg(message, ## __VA_ARGS__); \ @@ -173,14 +176,15 @@ struct loaddata { #define sg_failure_ret(condition, message, ...) \ if (!(condition)) { \ - sg_success = FALSE; \ log_sg(message, ## __VA_ARGS__); \ + sg_success = FALSE; \ sg_check_ret(); \ } + #define sg_failure_ret_val(condition, _val, message, ...) \ if (!(condition)) { \ - sg_success = FALSE; \ log_sg(message, ## __VA_ARGS__); \ + sg_success = FALSE; \ sg_check_ret_val(_val); \ } -- 2.39.2