lkml.org 
[lkml]   [2024]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v3 4/4] selftests/nolibc: Add tests for strlcat() and strlcpy()
    From
    On 4/23/24 10:18 AM, Thomas Weißschuh wrote:
    >> +#define EXPECT_STRBUFEQ(cond, expr, buf, val, cmp) \
    >> + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_str_buf_eq(expr, buf, val, llen, cmp); } while (0)
    >> +
    >> +static __attribute__((unused))
    >> +int expect_str_buf_eq(size_t expr, const char *buf, size_t val, int llen, const char *cmp)
    >> +{
    >> + llen += printf(" = %lu <%s> ", expr, buf);
    >
    > This introduces a compiler warning on 32bit:
    >
    > i386-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra -fno-stack-protector -m32 -mstack-protector-guard=global -fstack-protector-all -o nolibc-test \
    > -nostdlib -nostdinc -static -Isysroot/i386/include nolibc-test.c nolibc-test-linkage.c -lgcc
    > nolibc-test.c: In function 'expect_str_buf_eq':
    > nolibc-test.c:610:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
    > 610 | llen += printf(" = %lu <%s> ", expr, buf);
    > | ~~^ ~~~~
    > | | |
    > | | size_t {aka unsigned int}
    > | long unsigned int
    > | %u
    >
    >
    > It is easy enough to fix through a cast to "unsigned long".

    Thanks for fixing it! Of course, don't hesitate to let me know if there
    is something I can help with :)



    Best,
    Rodrigo

    \
     
     \ /
      Last update: 2024-05-27 18:05    [W:5.871 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site