From: Lennart Poettering Date: Fri, 6 Sep 2024 11:22:32 +0000 (+0200) Subject: test-utmp: replace UT_LINESIZE/UT_NAMESIZE/UT_HOSTSIZE with sizeof_field() X-Git-Tag: v257-rc1~533^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98dc726902eed6755fd087eb9b18f60228293efb;p=thirdparty%2Fsystemd.git test-utmp: replace UT_LINESIZE/UT_NAMESIZE/UT_HOSTSIZE with sizeof_field() utmpx doesn't know these defines, hence fix them. --- diff --git a/src/test/test-utmp.c b/src/test/test-utmp.c index 06a0fce764a..e94ee03250e 100644 --- a/src/test/test-utmp.c +++ b/src/test/test-utmp.c @@ -7,15 +7,9 @@ #include "utmp-wtmp.h" #include "tests.h" -#ifndef UT_LINESIZE -# define UT_LINESIZE 32 -#endif -#ifndef UT_NAMESIZE -# define UT_NAMESIZE 32 -#endif -#ifndef UT_HOSTSIZE -# define UT_HOSTSIZE 256 -#endif +#define UTX_LINESIZE sizeof_field(struct utmpx, ut_line) +#define UTX_NAMESIZE sizeof_field(struct utmpx, ut_user) +#define UTX_HOSTSIZE sizeof_field(struct utmpx, ut_host) TEST(dump_run_utmp) { _unused_ _cleanup_(utxent_cleanup) bool utmpx = false; @@ -46,11 +40,11 @@ TEST(dump_run_utmp) { log_info("%14s %10"PID_PRI" line=%-7.*s id=%-4.4s name=%-8.*s session=%lu host=%.*s addr=%s", type, u->ut_pid, - UT_LINESIZE, u->ut_line, + (int) UTX_LINESIZE, u->ut_line, u->ut_id, - UT_NAMESIZE, u->ut_user, + (int) UTX_NAMESIZE, u->ut_user, (long unsigned) u->ut_session, - UT_HOSTSIZE, u->ut_host, + (int) UTX_HOSTSIZE, u->ut_host, IN_ADDR_TO_STRING(is_ipv4 ? AF_INET : AF_INET6, &addr)); } }