]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]
authorKarel Zak <kzak@redhat.com>
Thu, 2 May 2019 10:48:05 +0000 (12:48 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 2 May 2019 10:48:05 +0000 (12:48 +0200)
misc-utils/hardlink.c: In function ‘process_path’:
misc-utils/hardlink.c:287:30: warning: operand of ?: changes signedness from ‘off_t’ {aka ‘long int’} to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]

misc-utils/hardlink.c: In function ‘main’:
misc-utils/hardlink.c:455:5: warning: ‘exclude_pattern’ may be used uninitialized in this function [-Wmaybe-uninitialized]

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

index 3354273cbda4b518741defd6628e77ebcaec12be..4acd8d7e6a8b93bb228553dc2a85526f383bf51f 100644 (file)
@@ -283,8 +283,8 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
                                for (fsize = st.st_size; fsize > 0;
                                     fsize -= (off_t)sizeof(ctl->iobuf1)) {
                                        ssize_t xsz;
-                                       ssize_t rsize = fsize > (ssize_t)sizeof(ctl->iobuf1) ?
-                                                       sizeof(ctl->iobuf1) : fsize;
+                                       ssize_t rsize = fsize > (ssize_t) sizeof(ctl->iobuf1) ?
+                                                       (ssize_t) sizeof(ctl->iobuf1) : fsize;
 
                                        if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize)
                                                warn(_("cannot read %s"), name);
@@ -393,7 +393,7 @@ int main(int argc, char **argv)
        int errornumber;
        PCRE2_SIZE erroroffset;
        pcre2_code *re;
-       PCRE2_SPTR exclude_pattern;
+       PCRE2_SPTR exclude_pattern = NULL;
        pcre2_match_data *match_data;
 #endif
        struct hardlink_dynstr nam1 = { NULL, 0 };