From 373ebcd8d9a5d64f1db14c7a70b6b977e21cab4d Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Tue, 20 Feb 2024 14:02:52 +0100 Subject: [PATCH] common: optimize search path Optimize search path to avoid reading .vscode folder. Signed-off-by: Tomasz Gromadzki --- src/core/log.c | 2 +- src/core/log_internal.h | 6 +++--- src/test/core_log_max/call_all.c | 1 - src/test/core_log_max/core_log_max.c | 5 +++-- .../log_call_all_generate.py | 17 +++++++---------- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/core/log.c b/src/core/log.c index a761c0d9e5a..a2d15803878 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -243,7 +243,7 @@ void core_log(enum core_log_level level, int errnum, const char *file_name, int line_no, const char *function_name, const char *message_format, ...) { - char message[CORE_LOG_MSG_MAXPRINT] = ""; + char message[_CORE_LOG_MSG_MAXPRINT] = ""; va_list arg; va_start(arg, message_format); diff --git a/src/core/log_internal.h b/src/core/log_internal.h index 507c0f97400..c63d9e275e7 100644 --- a/src/core/log_internal.h +++ b/src/core/log_internal.h @@ -108,11 +108,11 @@ void core_log_init(void); void core_log_fini(void); /* The actual maximum expected log line is 407. - * Additional byte is used to detect buffer overflow in core_log tests. - * If actual max message lenghth is eaqual to 408, it means we have a buffer + * An additional byte is used to detect buffer overflow in core_log tests. + * If the actual max message length is equal to 408, it means we have a buffer * overflow */ -#define CORE_LOG_MSG_MAXPRINT 408 /* maximum expected log line */ +#define _CORE_LOG_MSG_MAXPRINT 408 /* maximum expected log line + 1*/ static inline int core_log_error_translate(int ret) diff --git a/src/test/core_log_max/call_all.c b/src/test/core_log_max/call_all.c index 701650ed023..827b63eb7d8 100644 --- a/src/test/core_log_max/call_all.c +++ b/src/test/core_log_max/call_all.c @@ -21,7 +21,6 @@ static uintmax_t _ju = UINTMAX_MAX; /* * Prevent abort() from CORE_LOG_FATAL() */ -#undef abort #define abort() do { ; } while(0) #include "call_all.c.generated" diff --git a/src/test/core_log_max/core_log_max.c b/src/test/core_log_max/core_log_max.c index 56f98e57d4d..de8c225ed70 100644 --- a/src/test/core_log_max/core_log_max.c +++ b/src/test/core_log_max/core_log_max.c @@ -139,7 +139,7 @@ test_ERR_W_ERRNO(const struct test_case *tc, int argc, char *argv[]) return NO_ARGS_CONSUMED; } -#define TOTAL_MESSAGE_NUM_EXPECTED 178 +#define TOTAL_MESSAGE_NUM_EXPECTED 212 static int Max_message_len = 0; static int Total_message_num = 0; static char The_longest_message[BIG_BUF_SIZE]; @@ -177,9 +177,10 @@ test_CORE_LOG(const struct test_case *tc, int argc, char *argv[]) call_all_CORE_LOG_ERROR(); call_all_CORE_LOG_ERROR_W_ERRNO(MAX_STRERROR_NUM); call_all_CORE_LOG_FATAL(); + call_all_CORE_LOG_FATAL_W_ERRNO(MAX_STRERROR_NUM); UT_OUT("The_longest_message: %s", The_longest_message); - UT_ASSERTeq(Max_message_len + 2, CORE_LOG_MSG_MAXPRINT); + UT_ASSERTeq(Max_message_len + 2, _CORE_LOG_MSG_MAXPRINT); UT_ASSERTeq(Total_message_num, TOTAL_MESSAGE_NUM_EXPECTED); return NO_ARGS_CONSUMED; diff --git a/utils/call_stacks_analysis/log_call_all_generate.py b/utils/call_stacks_analysis/log_call_all_generate.py index b8b86b5ef2a..251f7be5df7 100755 --- a/utils/call_stacks_analysis/log_call_all_generate.py +++ b/utils/call_stacks_analysis/log_call_all_generate.py @@ -12,8 +12,8 @@ DEBUG = False PARSER_DEBUG = False -TOP = '../../' -OUTPUT_PATH = TOP + 'src/test/core_log_max/' +TOP = '../../src/' +OUTPUT_PATH = TOP + 'test/core_log_max/' OUTPUT_C = OUTPUT_PATH + 'call_all.c.generated' NOTICE = """/* @@ -68,13 +68,10 @@ def extract_append_code(file_name: str, start_line: int, code: str) -> str: return code IGNORE_FILES = [ - '.git/', - 'src/core/log_internal.h', - 'src/libpmem2/', - 'src/libpmempool/', - 'src/test/', - 'utils/', - 'CODING_STYLE.md', + 'core/log_internal.h', + 'libpmem2/', + 'libpmempool/', + 'test/', ] def file_should_be_ignored(file: str) -> bool: @@ -363,7 +360,7 @@ def generate_call(file, func: str, call: Dict) -> str: args = ', ' + ', '.join(call['args']) else: args = '' - file.write(f'\t// {call["file"]}:{call["line"]}\n') + file.write(f'\t// src/{call["file"]}:{call["line"]}\n') file.write(f'\t{func}("{call["format_string"]}"{args});\n') def generate_func_with_errno(func: str, calls: List[Dict]) -> None: