[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] getlogin, getlogin_r tests: Fix incorrect uid type
From: |
FantasqueX |
Subject: |
[PATCH] getlogin, getlogin_r tests: Fix incorrect uid type |
Date: |
Wed, 8 Jun 2022 19:41:27 +0800 |
* tests/test-getlogin.h (test_getlogin_result):
According to source code of glibc, the type of /proc/self/loginuid is
uid_t, which is unsigned int.
Signed-off-by: Letu Ren <fantasquex@gmail.com>
---
tests/test-getlogin.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test-getlogin.h b/tests/test-getlogin.h
index 3489e3e03..b5ed8b572 100644
--- a/tests/test-getlogin.h
+++ b/tests/test-getlogin.h
@@ -58,9 +58,9 @@ test_getlogin_result (const char *buf, int err)
FILE *fp = fopen ("/proc/self/loginuid", "r");
if (fp != NULL)
{
- char buf[3];
+ uid_t uid;
loginuid_undefined =
- (fread (buf, 1, 3, fp) == 2 && buf[0] == '-' && buf[1] == '1');
+ (fscanf (fp, "%u", &uid) == 1 && uid == (uid_t) -1);
fclose (fp);
}
if (loginuid_undefined)
--
2.36.1