Skip to content

Commit 9e5b50a

Browse files
pabigotcarlescufi
authored andcommitted
tests: cbprintf: avoid checkpatch diagnostic
checkpatch wants parameters to IS_ENABLED() to be Kconfig constants, i.e. ones that start with CONFIG_. Avoid the whinage. Signed-off-by: Peter Bigot <[email protected]>
1 parent 5f493c6 commit 9e5b50a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/unit/cbprintf/main.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787

8888
#endif /* VIA_TWISTER */
8989

90+
/* Can't use IS_ENABLED on symbols that don't start with CONFIG_
91+
* without checkpatch complaints, so do something else.
92+
*/
93+
#if USE_LIBC
94+
#define ENABLED_USE_LIBC true
95+
#else
96+
#define ENABLED_USE_LIBC false
97+
#endif
98+
9099
#include "../../../lib/os/cbprintf.c"
91100

92101
#if defined(CONFIG_CBPRINTF_COMPLETE)
@@ -297,7 +306,7 @@ static void test_c(void)
297306
}
298307

299308
rc = TEST_PRF("%lc", (wint_t)'a');
300-
if (IS_ENABLED(USE_LIBC)) {
309+
if (ENABLED_USE_LIBC) {
301310
PRF_CHECK("a", rc);
302311
} else {
303312
PRF_CHECK("%lc", rc);
@@ -345,7 +354,7 @@ static void test_s(void)
345354
PRF_CHECK("/123/12//", rc);
346355

347356
rc = TEST_PRF("%ls", ws);
348-
if (IS_ENABLED(USE_LIBC)) {
357+
if (ENABLED_USE_LIBC) {
349358
PRF_CHECK("abc", rc);
350359
} else {
351360
PRF_CHECK("%ls", rc);
@@ -361,7 +370,7 @@ static void test_v_c(void)
361370
rc = rawprf("%c", 'a');
362371
zassert_equal(rc, 1, NULL);
363372
zassert_equal(buf[0], 'a', NULL);
364-
if (!IS_ENABLED(USE_LIBC)) {
373+
if (!ENABLED_USE_LIBC) {
365374
zassert_equal(buf[1], 'b', "wth %x", buf[1]);
366375
}
367376
}
@@ -830,7 +839,7 @@ static void test_fp_length(void)
830839
}
831840

832841
rc = TEST_PRF("/%Lg/", (long double)dv);
833-
if (IS_ENABLED(USE_LIBC)) {
842+
if (ENABLED_USE_LIBC) {
834843
PRF_CHECK("/1.2345/", rc);
835844
} else {
836845
PRF_CHECK("/%Lg/", rc);
@@ -1007,7 +1016,7 @@ static void test_arglen(void)
10071016

10081017
static void test_p(void)
10091018
{
1010-
if (IS_ENABLED(USE_LIBC)) {
1019+
if (ENABLED_USE_LIBC) {
10111020
TC_PRINT("skipping on libc\n");
10121021
return;
10131022
}
@@ -1124,7 +1133,7 @@ void test_main(void)
11241133
}
11251134

11261135
TC_PRINT("Opts: " COND_CODE_1(M64_MODE, ("m64"), ("m32")) "\n");
1127-
if (IS_ENABLED(USE_LIBC)) {
1136+
if (ENABLED_USE_LIBC) {
11281137
TC_PRINT(" LIBC");
11291138
}
11301139
if (IS_ENABLED(CONFIG_CBPRINTF_COMPLETE)) {

0 commit comments

Comments
 (0)