bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stat signed/unsigned


From: Jim Meyering
Subject: Re: stat signed/unsigned
Date: Fri, 02 Jan 2009 17:08:43 +0100

Michael Meskes <address@hidden> wrote:
> On Wed, Dec 31, 2008 at 03:18:44PM +0100, Jim Meyering wrote:
>> Thanks, but "man statfs" on linux-based systems shows it can be signed:
>> ...
>
> Sorry for the noise, I just used grep -r to find stuff like
>
> /usr/include/asm-generic/statfs.h:      __u32 f_files;
> /usr/include/asm-generic/statfs.h:      __u64 f_files;
> /usr/include/asm-generic/statfs.h:      __u64 f_files;

Have you seen ever stat print a negative number
corresponding to that field?  Actually, I'll bet that
*has* happened... and considering the semantics
of that variable, I see no reason to print a signed value.

So this patch has your name/email on it.
Tell me those are ok and I'll push it.

Thanks!

>From 907e1af5ddbfc208ab5a2f88da48a5c86340b183 Mon Sep 17 00:00:00 2001
From: Michael Meskes <address@hidden>
Date: Fri, 2 Jan 2009 16:40:52 +0100
Subject: [PATCH] stat: print file-system total inode count (%c) as an unsigned 
number

* src/stat.c (print_statfs): Print statfs.f_files, the total inode
count of a file system, as an unsigned number.
---
 src/stat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/stat.c b/src/stat.c
index f5bf8cd..feea4b7 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1,5 +1,5 @@
 /* stat.c -- display file or file system status
-   Copyright (C) 2001-2008 Free Software Foundation, Inc.
+   Copyright (C) 2001-2009 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -541,7 +541,7 @@ print_statfs (char *pformat, size_t prefix_len, char m, 
char const *filename,
       }
       break;
     case 'c':
-      out_int (pformat, prefix_len, statfsbuf->f_files);
+      out_uint (pformat, prefix_len, statfsbuf->f_files);
       break;
     case 'd':
       out_int (pformat, prefix_len, statfsbuf->f_ffree);
--
1.6.1.302.gccd4d




reply via email to

[Prev in Thread] Current Thread [Next in Thread]