Skip to content

Commit a18357c

Browse files
peter-mitsiscarlescufi
authored andcommitted
tests: fixes logging.add.async build warning
Fixes github issue zephyrproject-rtos#54537. Using a variable to point to the desired format string generates a build warning when the -Wformat-security compiler flag is used. To resolve this, replace the variable with a macro to the format string. Signed-off-by: Peter Mitsis <[email protected]>
1 parent 86bc8d4 commit a18357c

File tree

1 file changed

+6
-5
lines changed
  • tests/subsys/logging/log_core_additional/src

1 file changed

+6
-5
lines changed

tests/subsys/logging/log_core_additional/src/log_test.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <zephyr/logging/log.h>
2121
#include <zephyr/logging/log_output.h>
2222

23+
#define TEST_MESSAGE "test msg"
24+
2325
#define LOG_MODULE_NAME log_test
2426
LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL_INF);
2527
static K_SEM_DEFINE(log_sem, 0, 1);
@@ -29,7 +31,6 @@ ZTEST_BMEM uint32_t source_id;
2931
/* used when log_msg create in user space */
3032
ZTEST_BMEM uint8_t domain, level;
3133
ZTEST_DMEM uint32_t msg_data = 0x1234;
32-
ZTEST_DMEM char *test_msg_usr = "test msg";
3334

3435
static uint8_t buf;
3536
static int char_out(uint8_t *data, size_t length, void *ctx)
@@ -489,7 +490,7 @@ ZTEST(test_log_core_additional, test_log_msg_create)
489490

490491
Z_LOG_MSG2_CREATE(!IS_ENABLED(CONFIG_USERSPACE), mode,
491492
Z_LOG_LOCAL_DOMAIN_ID, NULL,
492-
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, test_msg_usr);
493+
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, TEST_MESSAGE);
493494

494495
while (log_test_process()) {
495496
}
@@ -507,15 +508,15 @@ ZTEST_USER(test_log_core_additional, test_log_msg_create_user)
507508

508509
z_log_msg_runtime_create(domain, NULL,
509510
level, &msg_data, 0,
510-
sizeof(msg_data), test_msg_usr);
511+
sizeof(msg_data), TEST_MESSAGE);
511512
/* try z_log_msg_static_create() */
512513
Z_LOG_MSG2_STACK_CREATE(0, domain, NULL,
513514
level, &msg_data,
514-
sizeof(msg_data), test_msg_usr);
515+
sizeof(msg_data), TEST_MESSAGE);
515516

516517
Z_LOG_MSG2_CREATE(!IS_ENABLED(CONFIG_USERSPACE), mode,
517518
Z_LOG_LOCAL_DOMAIN_ID, NULL,
518-
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, test_msg_usr);
519+
LOG_LEVEL_INTERNAL_RAW_STRING, NULL, 0, TEST_MESSAGE);
519520

520521
while (log_test_process()) {
521522
}

0 commit comments

Comments
 (0)