加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
From 8083944484f2cdf6c9b737642567bcdb54db784d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Sun, 6 Oct 2024 22:19:51 -0700
Subject: [PATCH] chroot,whoami: use uintmax_t for printing uids
Reference:https://github.com/coreutils/coreutils/commit/8083944484f2cdf6c9b737642567bcdb54db784d
* src/chroot.c (main): Cast the uid to uintmax_t instead of int.
* src/whoami.c (main): Cast the uid to uintmax_t instead of unsigned
long int.
---
src/chroot.c | 3 ++-
src/whoami.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/chroot.c b/src/chroot.c
index e12454c..dd1ec62 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -375,7 +375,8 @@ main (int argc, char **argv)
else if (gid_unset (gid))
{
error (EXIT_CANCELED, errno,
- _("no group specified for unknown uid: %d"), (int) uid);
+ _("no group specified for unknown uid: %ju"),
+ (uintmax_t) uid);
}
}
diff --git a/src/whoami.c b/src/whoami.c
index f64171d..834ca9f 100644
--- a/src/whoami.c
+++ b/src/whoami.c
@@ -81,8 +81,8 @@ main (int argc, char **argv)
uid = geteuid ();
pw = uid == NO_UID && errno ? nullptr : getpwuid (uid);
if (!pw)
- error (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"),
- (unsigned long int) uid);
+ error (EXIT_FAILURE, errno, _("cannot find name for user ID %ju"),
+ (uintmax_t) uid);
puts (pw->pw_name);
return EXIT_SUCCESS;
}
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化