From 1801c172a336b2d01f9e4bf3befaca188a6c0d0f Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 10 Feb 2022 16:14:11 +0900 Subject: [PATCH] lsfd: fix the way to print stat.st_nlink The type used for casting the member was too small; for the "%ju" format spec, we should use uintmax_t for the purpose. This change may fix the bug reported in https://github.com/util-linux/util-linux/issues/1511#issuecomment-1033697617 in GitHub#1511 by Anatoly Pugachev . Signed-off-by: Masatake YAMATO --- misc-utils/lsfd-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index 9c320e9493..39a5b92174 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -292,7 +292,7 @@ static bool file_fill_column(struct proc *proc, xasprintf(&str, "%jd", (intmax_t)file->stat.st_size); break; case COL_NLINK: - xasprintf(&str, "%ju", (unsigned long int)file->stat.st_nlink); + xasprintf(&str, "%ju", (uintmax_t)file->stat.st_nlink); break; case COL_DELETED: xasprintf(&str, "%d", file->stat.st_nlink == 0); -- 2.47.2