[PATCH v2 05/10] selftests/nolibc: mark test helpers as potentially unused

From: Thomas Weißschuh
Date: Tue Aug 01 2023 - 01:30:58 EST


When warning about unused functions these would be reported by we want
to keep them for future use.

Suggested-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
Link: https://lore.kernel.org/lkml/20230731064826.16584-1-falcon@xxxxxxxxxxx/
Suggested-by: Willy Tarreau <w@xxxxxx>
Link: https://lore.kernel.org/lkml/20230731224929.GA18296@xxxxxx/
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
tools/testing/selftests/nolibc/nolibc-test.c | 75 ++++++++++++++++++----------
1 file changed, 50 insertions(+), 25 deletions(-)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 9a5a212ea55c..1555759bb164 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -164,7 +164,8 @@ static void result(int llen, enum RESULT r)
#define EXPECT_ZR(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_zr(expr, llen); } while (0)

-static int expect_zr(int expr, int llen)
+static __attribute__((unused))
+int expect_zr(int expr, int llen)
{
int ret = !(expr == 0);

@@ -177,7 +178,8 @@ static int expect_zr(int expr, int llen)
#define EXPECT_NZ(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_nz(expr, llen; } while (0)

-static int expect_nz(int expr, int llen)
+static __attribute__((unused))
+int expect_nz(int expr, int llen)
{
int ret = !(expr != 0);

@@ -190,7 +192,8 @@ static int expect_nz(int expr, int llen)
#define EXPECT_EQ(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_eq(expr, llen, val); } while (0)

-static int expect_eq(uint64_t expr, int llen, uint64_t val)
+static __attribute__((unused))
+int expect_eq(uint64_t expr, int llen, uint64_t val)
{
int ret = !(expr == val);

@@ -203,7 +206,8 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val)
#define EXPECT_NE(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ne(expr, llen, val); } while (0)

-static int expect_ne(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_ne(int expr, int llen, int val)
{
int ret = !(expr != val);

@@ -216,7 +220,8 @@ static int expect_ne(int expr, int llen, int val)
#define EXPECT_GE(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ge(expr, llen, val); } while (0)

-static int expect_ge(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_ge(int expr, int llen, int val)
{
int ret = !(expr >= val);

@@ -229,7 +234,8 @@ static int expect_ge(int expr, int llen, int val)
#define EXPECT_GT(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_gt(expr, llen, val); } while (0)

-static int expect_gt(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_gt(int expr, int llen, int val)
{
int ret = !(expr > val);

@@ -242,7 +248,8 @@ static int expect_gt(int expr, int llen, int val)
#define EXPECT_LE(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_le(expr, llen, val); } while (0)

-static int expect_le(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_le(int expr, int llen, int val)
{
int ret = !(expr <= val);

@@ -255,7 +262,8 @@ static int expect_le(int expr, int llen, int val)
#define EXPECT_LT(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_lt(expr, llen, val); } while (0)

-static int expect_lt(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_lt(int expr, int llen, int val)
{
int ret = !(expr < val);

@@ -268,7 +276,8 @@ static int expect_lt(int expr, int llen, int val)
#define EXPECT_SYSZR(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syszr(expr, llen); } while (0)

-static int expect_syszr(int expr, int llen)
+static __attribute__((unused))
+int expect_syszr(int expr, int llen)
{
int ret = 0;

@@ -287,7 +296,8 @@ static int expect_syszr(int expr, int llen)
#define EXPECT_SYSEQ(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syseq(expr, llen, val); } while (0)

-static int expect_syseq(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_syseq(int expr, int llen, int val)
{
int ret = 0;

@@ -306,7 +316,8 @@ static int expect_syseq(int expr, int llen, int val)
#define EXPECT_SYSNE(cond, expr, val) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_sysne(expr, llen, val); } while (0)

-static int expect_sysne(int expr, int llen, int val)
+static __attribute__((unused))
+int expect_sysne(int expr, int llen, int val)
{
int ret = 0;

@@ -328,7 +339,8 @@ static int expect_sysne(int expr, int llen, int val)
#define EXPECT_SYSER(cond, expr, expret, experr) \
EXPECT_SYSER2(cond, expr, expret, experr, 0)

-static int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen)
+static __attribute__((unused))
+int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen)
{
int ret = 0;
int _errno = errno;
@@ -351,7 +363,8 @@ static int expect_syserr2(int expr, int expret, int experr1, int experr2, int ll
#define EXPECT_PTRZR(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrzr(expr, llen); } while (0)

-static int expect_ptrzr(const void *expr, int llen)
+static __attribute__((unused))
+int expect_ptrzr(const void *expr, int llen)
{
int ret = 0;

@@ -369,7 +382,8 @@ static int expect_ptrzr(const void *expr, int llen)
#define EXPECT_PTRNZ(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrnz(expr, llen); } while (0)

-static int expect_ptrnz(const void *expr, int llen)
+static __attribute__((unused))
+int expect_ptrnz(const void *expr, int llen)
{
int ret = 0;

@@ -386,7 +400,8 @@ static int expect_ptrnz(const void *expr, int llen)
#define EXPECT_PTREQ(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptreq(expr, llen, cmp); } while (0)

-static int expect_ptreq(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptreq(const void *expr, int llen, const void *cmp)
{
int ret = 0;

@@ -403,7 +418,8 @@ static int expect_ptreq(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRNE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrne(expr, llen, cmp); } while (0)

-static int expect_ptrne(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptrne(const void *expr, int llen, const void *cmp)
{
int ret = 0;

@@ -420,7 +436,8 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRGE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrge(expr, llen, cmp); } while (0)

-static int expect_ptrge(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptrge(const void *expr, int llen, const void *cmp)
{
int ret = !(expr >= cmp);

@@ -432,7 +449,8 @@ static int expect_ptrge(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRGT(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrgt(expr, llen, cmp); } while (0)

-static int expect_ptrgt(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptrgt(const void *expr, int llen, const void *cmp)
{
int ret = !(expr > cmp);

@@ -445,7 +463,8 @@ static int expect_ptrgt(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRLE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrle(expr, llen, cmp); } while (0)

-static int expect_ptrle(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptrle(const void *expr, int llen, const void *cmp)
{
int ret = !(expr <= cmp);

@@ -458,7 +477,8 @@ static int expect_ptrle(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRLT(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrlt(expr, llen, cmp); } while (0)

-static int expect_ptrlt(const void *expr, int llen, const void *cmp)
+static __attribute__((unused))
+int expect_ptrlt(const void *expr, int llen, const void *cmp)
{
int ret = !(expr < cmp);

@@ -473,7 +493,8 @@ static int expect_ptrlt(const void *expr, int llen, const void *cmp)
#define EXPECT_PTRER(cond, expr, expret, experr) \
EXPECT_PTRER2(cond, expr, expret, experr, 0)

-static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int experr2, int llen)
+static __attribute__((unused))
+int expect_ptrerr2(const void *expr, const void *expret, int experr1, int experr2, int llen)
{
int ret = 0;
int _errno = errno;
@@ -495,7 +516,8 @@ static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int
#define EXPECT_STRZR(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strzr(expr, llen); } while (0)

-static int expect_strzr(const char *expr, int llen)
+static __attribute__((unused))
+int expect_strzr(const char *expr, int llen)
{
int ret = 0;

@@ -513,7 +535,8 @@ static int expect_strzr(const char *expr, int llen)
#define EXPECT_STRNZ(cond, expr) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strnz(expr, llen); } while (0)

-static int expect_strnz(const char *expr, int llen)
+static __attribute__((unused))
+int expect_strnz(const char *expr, int llen)
{
int ret = 0;

@@ -531,7 +554,8 @@ static int expect_strnz(const char *expr, int llen)
#define EXPECT_STREQ(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_streq(expr, llen, cmp); } while (0)

-static int expect_streq(const char *expr, int llen, const char *cmp)
+static __attribute__((unused))
+int expect_streq(const char *expr, int llen, const char *cmp)
{
int ret = 0;

@@ -549,7 +573,8 @@ static int expect_streq(const char *expr, int llen, const char *cmp)
#define EXPECT_STRNE(cond, expr, cmp) \
do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strne(expr, llen, cmp); } while (0)

-static int expect_strne(const char *expr, int llen, const char *cmp)
+static __attribute__((unused))
+int expect_strne(const char *expr, int llen, const char *cmp)
{
int ret = 0;


--
2.41.0