From effb76c61e8df884cbf1125a58eac59d2034dd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Battrel?= Date: Fri, 28 Oct 2022 11:05:01 +0200 Subject: [PATCH] Bluetooth: Move re-implementation of `snprintk` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the function in the `subsys/testsuite/ztest/src/ztest_mock.c` files. This is motivated by the fact that there is others re-implementation of `*printk` functions using libc counterparts in the `ztest_mock.c` file. Signed-off-by: Théo Battrel --- subsys/testsuite/ztest/src/ztest_mock.c | 13 +++++++++++++ .../host/keys/bt_keys_get_addr/src/main.c | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest_mock.c b/subsys/testsuite/ztest/src/ztest_mock.c index 4ed369eb440..4fe6d6e64ad 100644 --- a/subsys/testsuite/ztest/src/ztest_mock.c +++ b/subsys/testsuite/ztest/src/ztest_mock.c @@ -56,6 +56,19 @@ void vprintk(const char *fmt, va_list ap) { vprintf(fmt, ap); } + +int snprintk(char *str, size_t size, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = snprintf(str, size, fmt, ap); + va_end(ap); + + return ret; +} + #else /* diff --git a/tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c b/tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c index 8515f55b5b1..06213463181 100644 --- a/tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c +++ b/tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c @@ -4,7 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include #include #include #include @@ -17,19 +16,6 @@ DEFINE_FFF_GLOBALS; -/* Define snprintk to use libc since we are not compiling the whole kernel. */ -int snprintk(char *str, size_t size, const char *fmt, ...) -{ - va_list ap; - int ret; - - va_start(ap, fmt); - ret = snprintf(str, size, fmt, ap); - va_end(ap); - - return ret; -} - /* This LUT contains different combinations of ID and Address pairs */ const struct id_addr_pair testing_id_addr_pair_lut[] = { { BT_ADDR_ID_1, BT_ADDR_LE_1 },