From b3c5b3a7dc244042811c7906a4489acf184518da Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Mon, 12 May 2025 15:39:07 +0200 Subject: [PATCH] boards/native/nrf_bsim: Declare as pointer to constant data To be clearer to the compiler and users. Signed-off-by: Alberto Escolar Piedras --- boards/native/nrf_bsim/common/bstests.h | 2 +- boards/native/nrf_bsim/common/bstests_entry.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/boards/native/nrf_bsim/common/bstests.h b/boards/native/nrf_bsim/common/bstests.h index ee22240a380..7c892d0ead2 100644 --- a/boards/native/nrf_bsim/common/bstests.h +++ b/boards/native/nrf_bsim/common/bstests.h @@ -92,7 +92,7 @@ struct bst_test_instance { {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} struct bst_test_list { - struct bst_test_instance *test_instance; + const struct bst_test_instance *test_instance; struct bst_test_list *next; }; diff --git a/boards/native/nrf_bsim/common/bstests_entry.c b/boards/native/nrf_bsim/common/bstests_entry.c index 7b22a50ebf5..6822afb0a8c 100644 --- a/boards/native/nrf_bsim/common/bstests_entry.c +++ b/boards/native/nrf_bsim/common/bstests_entry.c @@ -21,7 +21,7 @@ */ enum bst_result_t bst_result; -static struct bst_test_instance *current_test; +static const struct bst_test_instance *current_test; static struct bst_test_list *test_list_top; __attribute__((weak)) bst_test_install_t test_installers[] = { NULL }; @@ -42,8 +42,7 @@ struct bst_test_list *bst_add_tests(struct bst_test_list *tests, if (test_def[idx].test_id != NULL) { head = bs_malloc(sizeof(struct bst_test_list)); head->next = NULL; - head->test_instance = (struct bst_test_instance *) - &test_def[idx++]; + head->test_instance = &test_def[idx++]; tail = head; } } @@ -51,16 +50,14 @@ struct bst_test_list *bst_add_tests(struct bst_test_list *tests, while (test_def[idx].test_id != NULL) { tail->next = bs_malloc(sizeof(struct bst_test_list)); tail = tail->next; - tail->test_instance = (struct bst_test_instance *) - &test_def[idx++]; + tail->test_instance = &test_def[idx++]; tail->next = NULL; } return head; } -static struct bst_test_instance *bst_test_find(struct bst_test_list *tests, - char *test_id) +static const struct bst_test_instance *bst_test_find(struct bst_test_list *tests, char *test_id) { struct bst_test_list *top = tests;