Whamcloud - gitweb
LU-17000 utils: Use ssize_t to store return from sysconf() 36/53936/2
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Tue, 6 Feb 2024 10:11:57 +0000 (15:41 +0530)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Feb 2024 07:16:31 +0000 (07:16 +0000)
Use ssize_t instead of size_t to capture return
from sysconf() as it can return a negative value

Test-Parameters: trivial testlist=sanity-flr
CoverityID: 414674 ("Unsigned compared against 0")
CoverityID: 414673 ("Unsigned compared against 0")
CoverityID: 414672 ("Unsigned compared against 0")
CoverityID: 414671 ("Unsigned compared against 0")
CoverityID: 414670 ("Unsigned compared against 0")
CoverityID: 414669 ("Unsigned compared against 0")
CoverityID: 414668 ("Unsigned compared against 0")
CoverityID: 414667 ("Unsigned compared against 0")
Fixes: b02a9bc1 (LU-17000 utils: Add check after calling sysconf(_SC_PAGESIZE))
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I03f280f25beb7b6b8b41888c379b0709a6195d9c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53936
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c
lustre/utils/liblustreapi_mirror.c

index 0c0fb62..ae0d049 100644 (file)
@@ -796,7 +796,7 @@ static int migrate_copy_data(int fd_src, int fd_dst, int (*check_file)(int),
        void *buf = NULL;
        off_t pos = 0;
        off_t data_end = 0;
-       size_t page_size;
+       ssize_t page_size;
        bool sparse;
        int rc;
        size_t write_bytes = 0;
@@ -11941,7 +11941,7 @@ static inline int lfs_mirror_read(int argc, char **argv)
        int c;
        void *buf;
        const size_t buflen = 4 << 20;
-       size_t page_size;
+       ssize_t page_size;
        off_t pos;
        struct option long_opts[] = {
        { .val = 'h',   .name = "help",         .has_arg = no_argument },
@@ -12112,7 +12112,7 @@ static inline int lfs_mirror_write(int argc, char **argv)
        void *buf;
        const size_t buflen = 4 << 20;
        off_t pos;
-       size_t page_size = sysconf(_SC_PAGESIZE);
+       ssize_t page_size = sysconf(_SC_PAGESIZE);
        struct ll_ioc_lease_id ioc;
        struct option long_opts[] = {
        { .val = 'h',   .name = "help",         .has_arg = no_argument },
index 84c6379..5291869 100644 (file)
@@ -3009,7 +3009,7 @@ int llapi_mirror_resync_many_params(int fd, struct llapi_layout *layout,
                                    unsigned long bandwidth_bytes_sec)
 {
        size_t buflen = 64 << 20; /* 64M */
-       size_t page_size;
+       ssize_t page_size;
        void *buf;
        uint64_t pos = start;
        uint64_t data_off = pos, data_end = pos;
index 3988c33..36e02fe 100644 (file)
@@ -114,7 +114,7 @@ ssize_t llapi_mirror_read(int fd, unsigned int id, void *buf, size_t count,
                          off_t pos)
 {
        ssize_t result = 0;
-       size_t page_size;
+       ssize_t page_size;
        int rc;
 
        page_size = sysconf(_SC_PAGESIZE);
@@ -157,7 +157,7 @@ ssize_t llapi_mirror_write(int fd, unsigned int id, const void *buf,
                           size_t count, off_t pos)
 {
        ssize_t result = 0;
-       size_t page_size;
+       ssize_t page_size;
        int rc;
 
        page_size = sysconf(_SC_PAGESIZE);
@@ -288,7 +288,7 @@ ssize_t llapi_mirror_copy_many(int fd, __u16 src, __u16 *dst, size_t count)
        void *buf;
        off_t pos = 0;
        off_t data_end = 0;
-       size_t page_size;
+       ssize_t page_size;
        ssize_t result = 0;
        bool eof = false;
        bool sparse;
@@ -434,7 +434,7 @@ int llapi_mirror_copy(int fd, unsigned int src, unsigned int dst, off_t pos,
 {
        const size_t buflen = 4 * 1024 * 1024; /* 4M */
        ssize_t result = 0;
-       size_t page_size;
+       ssize_t page_size;
        void *buf;
        int rc;