user-util: avoid double evaluation in STRERROR_USER/GROUP()

Follow-up for 6e6e96f628.
This commit is contained in:
Yu Watanabe
2025-11-20 09:07:57 +09:00
parent 459000e8c5
commit 5feb65c5b1
2 changed files with 25 additions and 5 deletions
+20
View File
@@ -28,6 +28,26 @@
#include "user-util.h"
#include "utf8.h"
#define DEFINE_STRERROR_ACCOUNT(type) \
const char* strerror_##type( \
int errnum, \
char *buf, \
size_t buflen) { \
\
errnum = ABS(errnum); \
switch (errnum) { \
case ESRCH: \
return "Unknown " STRINGIFY(type); \
case ENOEXEC: \
return "Not a system " STRINGIFY(type); \
default: \
return strerror_r(errnum, buf, buflen); \
} \
}
DEFINE_STRERROR_ACCOUNT(user);
DEFINE_STRERROR_ACCOUNT(group);
bool uid_is_valid(uid_t uid) {
/* Also see POSIX IEEE Std 1003.1-2008, 2016 Edition, 3.436. */