]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: don't use 'long int' for file data
authorKarel Zak <kzak@redhat.com>
Mon, 20 Sep 2021 11:30:28 +0000 (13:30 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
Let's always assume positions, offsets, etc.. as 64-bit numbers.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsfd-file.c
misc-utils/lsfd-sock.c
misc-utils/lsfd.c
misc-utils/lsfd.h

index dab7edca119241066e54d4e8f80777ace03c3821..e609d670918ecf0f8b130594c2d6e25165276dc0 100644 (file)
@@ -175,9 +175,9 @@ static void file_fill_flags_buf(struct ul_buffer *buf, int flags)
         || (file)->association == -ASSOC_SHM   \
         || (file)->association == -ASSOC_MEM)
 
-static unsigned long get_map_length(struct file *file)
+static uint64_t get_map_length(struct file *file)
 {
-       unsigned long res = 0;
+       uint64_t res = 0;
 
        if (is_association(file, SHM) || is_association(file, MEM)) {
                static size_t pagesize = 0;
index 4ef82ba7853616cf56a5c9a01f23f7ff8ca0f2d8..0ed5663778dc430d9001f62f5cea78cb93625b63 100644 (file)
@@ -95,7 +95,7 @@ static void init_sock_content(struct file *file)
                if (fd >= 0)
                        sprintf(path, "/proc/%d/fd/%d", file->proc->pid, fd);
                else
-                       sprintf(path, "/proc/%d/map_files/%lx-%lx",
+                       sprintf(path, "/proc/%d/map_files/%"PRIx64 "-%" PRIx64,
                                file->proc->pid,
                                file->map_start,
                                file->map_end);
index 9e9fc0940adc0c7716599719bd3a3424a581696b..2b7b1608f11c37948259cf03b08975602a2ec4eb 100644 (file)
@@ -398,7 +398,7 @@ static struct file *collect_mem_file(struct proc *proc, int dd, struct dirent *d
        ssize_t len;
        char sym[PATH_MAX];
        struct file *f;
-       unsigned long start, end;
+       uint64_t start, end;
        struct map *map;
        enum association assoc;
        mode_t mode = 0;
@@ -412,7 +412,7 @@ static struct file *collect_mem_file(struct proc *proc, int dd, struct dirent *d
 
 
        map = NULL;
-       if (sscanf(dp->d_name, "%lx-%lx", &start, &end) == 2)
+       if (sscanf(dp->d_name, "%" SCNx64 "-%" SCNx64, &start, &end) == 2)
                map = find_map(maps, start);
 
        assoc = (map && map->shared)? ASSOC_SHM: ASSOC_MEM;
index 31783d71f78942be7bb61ae84634c52100004d83..80727d0aee2acca655b02b073dd4a1ccb1b6227f 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdbool.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <inttypes.h>
 
 #include "list.h"
 
@@ -111,10 +112,10 @@ struct file {
        struct stat stat;
        mode_t mode;
        struct proc *proc;
-       uint64_t pos;
 
-       unsigned long map_start;
-       unsigned long map_end;
+       uint64_t pos;
+       uint64_t map_start;
+       uint64_t map_end;
 
        unsigned int sys_flags;
        unsigned int mnt_id;