]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fincore: use size_t everywhere
authorKarel Zak <kzak@redhat.com>
Thu, 6 Apr 2017 10:40:01 +0000 (12:40 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 6 Apr 2017 10:40:01 +0000 (12:40 +0200)
It seems better to avoid "int" at all from sizes calculations to make
the code more robust for future changes.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/fincore.c

index 425f1bf42535ad6113613f54e2e9bd038cefaeb1..ffc02fc2c311bdbeaa1d01cacacc8cc89c96ae67 100644 (file)
@@ -40,7 +40,7 @@
 
    Window size depends on page size.
    e.g. 128MB on x86_64. ( = N_PAGES_IN_WINDOW * 4096 ). */
-#define N_PAGES_IN_WINDOW (32 * 1024)
+#define N_PAGES_IN_WINDOW ((size_t)(32 * 1024))
 
 
 struct colinfo {
@@ -68,7 +68,7 @@ static int columns[ARRAY_SIZE(infos) * 2] = {-1};
 static size_t ncolumns;
 
 struct fincore_control {
-       const int pagesize;
+       const size_t pagesize;
 
        struct libscols_table *tb;              /* output */
 
@@ -188,7 +188,7 @@ static int fincore_fd (struct fincore_control *ctl,
                       off_t file_size,
                       off_t *count_incore)
 {
-       size_t window_size = (size_t)N_PAGES_IN_WINDOW * ctl->pagesize;
+       size_t window_size = N_PAGES_IN_WINDOW * ctl->pagesize;
        off_t  file_offset;
        void  *window = NULL;
        int rc = 0;