Source-Changes-HG archive

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

[src/trunk]: src/lib/librefuse Increase the warning level to spot more mistakes



details:   https://anonhg.NetBSD.org/src/rev/b0c232442868
branches:  trunk
changeset: 359762:b0c232442868
user:      pho <pho%NetBSD.org@localhost>
date:      Sat Jan 22 07:58:32 2022 +0000

description:
Increase the warning level to spot more mistakes

diffstat:

 lib/librefuse/Makefile     |   4 ++--
 lib/librefuse/TODO         |   4 ++--
 lib/librefuse/refuse.c     |  24 ++++++++++++------------
 lib/librefuse/refuse_opt.c |  24 ++++++++++++------------
 4 files changed, 28 insertions(+), 28 deletions(-)

diffs (228 lines):

diff -r aa4b2c5ffcda -r b0c232442868 lib/librefuse/Makefile
--- a/lib/librefuse/Makefile    Sat Jan 22 07:57:30 2022 +0000
+++ b/lib/librefuse/Makefile    Sat Jan 22 07:58:32 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2022/01/22 07:53:06 pho Exp $
+# $NetBSD: Makefile,v 1.15 2022/01/22 07:58:32 pho Exp $
 
 USE_FORT?=     yes     # data driven bugs?
 
@@ -15,7 +15,7 @@
 SRCS=          refuse.c refuse_log.c refuse_lowlevel.c
 SRCS+=         refuse_opt.c refuse_signals.c
 MAN=           refuse.3
-WARNS?=                5
+WARNS?=                6
 INCS=           fuse.h fuse_opt.h fuse_log.h fuse_lowlevel.h
 INCSDIR=        /usr/include
 
diff -r aa4b2c5ffcda -r b0c232442868 lib/librefuse/TODO
--- a/lib/librefuse/TODO        Sat Jan 22 07:57:30 2022 +0000
+++ b/lib/librefuse/TODO        Sat Jan 22 07:58:32 2022 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: TODO,v 1.6 2022/01/22 07:56:16 pho Exp $
+       $NetBSD: TODO,v 1.7 2022/01/22 07:58:32 pho Exp $
 
 To Do
 =====
@@ -18,7 +18,7 @@
 ====
 statvfs
 sync
-WARNS=4
+WARNS=6
 address lint
 special directory handling in open()
 Finish off manual page
diff -r aa4b2c5ffcda -r b0c232442868 lib/librefuse/refuse.c
--- a/lib/librefuse/refuse.c    Sat Jan 22 07:57:30 2022 +0000
+++ b/lib/librefuse/refuse.c    Sat Jan 22 07:58:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refuse.c,v 1.105 2022/01/22 07:57:30 pho Exp $ */
+/*     $NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.105 2022/01/22 07:57:30 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.106 2022/01/22 07:58:32 pho Exp $");
 #endif /* !lint */
 
 /* We emit a compiler warning for anyone including <fuse.h> without
@@ -301,7 +301,7 @@
                dtype = DT_UNKNOWN;
                dino = fakeino++;
        } else {
-               dtype = puffs_vtype2dt(puffs_mode2vt(stbuf->st_mode));
+               dtype = (uint8_t)puffs_vtype2dt(puffs_mode2vt(stbuf->st_mode));
                dino = stbuf->st_ino;
 
                /*
@@ -571,7 +571,7 @@
                if (!p)
                        return EINVAL;
 
-               *linklen = p - linkname;
+               *linklen = (size_t)(p - linkname);
        }
 
        return -ret;
@@ -948,9 +948,9 @@
        set_fuse_context_uid_gid(pcr);
 
        maxread = *resid;
-       if (maxread > pn->pn_va.va_size - offset) {
+       if (maxread > (size_t)((off_t)pn->pn_va.va_size - offset)) {
                /*LINTED*/
-               maxread = pn->pn_va.va_size - offset;
+               maxread = (size_t)((off_t)pn->pn_va.va_size - offset);
        }
        if (maxread == 0)
                return 0;
@@ -959,7 +959,7 @@
            &rn->file_info);
 
        if (ret > 0) {
-               *resid -= ret;
+               *resid -= (size_t)ret;
                ret = 0;
        }
 
@@ -987,15 +987,15 @@
        set_fuse_context_uid_gid(pcr);
 
        if (ioflag & PUFFS_IO_APPEND)
-               offset = pn->pn_va.va_size;
+               offset = (off_t)pn->pn_va.va_size;
 
        ret = (*fuse->op.write)(path, (char *)buf, *resid, offset,
            &rn->file_info);
 
        if (ret >= 0) {
                if ((uint64_t)(offset + ret) > pn->pn_va.va_size)
-                       pn->pn_va.va_size = offset + ret;
-               *resid -= ret;
+                       pn->pn_va.va_size = (u_quad_t)(offset + ret);
+               *resid -= (size_t)ret;
                ret = (*resid == 0) ? 0 : ENOSPC;
        } else {
                ret = -ret;
@@ -1062,7 +1062,7 @@
                        break;
 
                memcpy(dent, fromdent, _DIRENT_SIZE(fromdent));
-               *readoff += _DIRENT_SIZE(fromdent);
+               *readoff += (off_t)_DIRENT_SIZE(fromdent);
                *reslen -= _DIRENT_SIZE(fromdent);
 
                dent = _DIRENT_NEXT(dent);
@@ -1255,7 +1255,7 @@
        struct fuse_context     *fusectx;
        struct puffs_ops        *pops;
        struct fuse             *fuse;
-       int                     puffs_flags;
+       uint32_t                puffs_flags;
 
        /* parse refuse options */
        if (fuse_opt_parse(args, &config, refuse_opts, NULL) == -1)
diff -r aa4b2c5ffcda -r b0c232442868 lib/librefuse/refuse_opt.c
--- a/lib/librefuse/refuse_opt.c        Sat Jan 22 07:57:30 2022 +0000
+++ b/lib/librefuse/refuse_opt.c        Sat Jan 22 07:58:32 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refuse_opt.c,v 1.22 2021/12/04 06:42:39 pho Exp $      */
+/*     $NetBSD: refuse_opt.c,v 1.23 2022/01/22 07:58:32 pho Exp $      */
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -60,7 +60,7 @@
        } else if (args->allocated == args->argc) {
                int na = args->allocated + 10;
 
-               if (reallocarr(&args->argv, na, sizeof(*args->argv)) != 0)
+               if (reallocarr(&args->argv, (size_t)na, sizeof(*args->argv)) != 0)
                        return -1;
 
                args->allocated = na;
@@ -125,7 +125,7 @@
        } else {
                na = args->allocated + 10;
        }
-       if (reallocarr(&args->argv, na, sizeof(*args->argv)) != 0) {
+       if (reallocarr(&args->argv, (size_t)na, sizeof(*args->argv)) != 0) {
                warn("fuse_opt_insert_arg");
                return -1;
        }
@@ -180,17 +180,17 @@
        return add_opt(opts, opt, true);
 }
 
-static bool match_templ(const char *templ, const char *opt, int *sep_idx)
+static bool match_templ(const char *templ, const char *opt, ssize_t *sep_idx)
 {
        const char *sep = strpbrk(templ, "= ");
 
        if (sep != NULL && (sep[1] == '\0' || sep[1] == '%')) {
                const size_t cmp_len =
-                       sep[0] == '=' ? sep - templ + 1 : sep - templ;
+                       (size_t)(sep[0] == '=' ? sep - templ + 1 : sep - templ);
 
                if (strlen(opt) >= cmp_len && strncmp(templ, opt, cmp_len) == 0) {
                        if (sep_idx != NULL)
-                               *sep_idx = sep - templ;
+                               *sep_idx = (ssize_t)(sep - templ);
                        return true;
                }
                else {
@@ -210,7 +210,7 @@
 }
 
 static const struct fuse_opt *
-find_opt(const struct fuse_opt *opts, const char *opt, int *sep_idx)
+find_opt(const struct fuse_opt *opts, const char *opt, ssize_t *sep_idx)
 {
        for (; opts != NULL && opts->templ != NULL; opts++) {
                if (match_templ(opts->templ, opt, sep_idx))
@@ -283,7 +283,7 @@
 /* Parse a single argument with a matched template. */
 static int
 parse_matched_arg(const char* arg, struct fuse_args *outargs,
-               const struct fuse_opt* opt, int sep_idx, void* data,
+               const struct fuse_opt* opt, ssize_t sep_idx, void* data,
                fuse_opt_proc_t proc, bool is_opt)
 {
        if (opt->offset == -1) {
@@ -317,7 +317,7 @@
 #pragma GCC diagnostic pop
                                        (void)fprintf(stderr, "fuse: '%s' is not a "
                                                                "valid parameter for option '%.*s'\n",
-                                                               param, sep_idx, opt->templ);
+                                                               param, (int)sep_idx, opt->templ);
                                        return -1;
                                }
                        }
@@ -336,7 +336,7 @@
                struct fuse_args *outargs, void *data,
                const struct fuse_opt *opts, fuse_opt_proc_t proc, bool is_opt)
 {
-       int sep_idx;
+       ssize_t sep_idx;
        const struct fuse_opt *opt = find_opt(opts, arg, &sep_idx);
 
        if (opt) {
@@ -357,11 +357,11 @@
 
                                /* ...but processor callbacks expect a concatenated
                                 * argument "-xfoo". */
-                               if ((new_arg = malloc(sep_idx +
+                               if ((new_arg = malloc((size_t)sep_idx +
                                                                        strlen(args->argv[*argi]) + 1)) == NULL)
                                        return -1;
 
-                               strncpy(new_arg, arg, sep_idx); /* -x */
+                               strncpy(new_arg, arg, (size_t)sep_idx); /* -x */
                                strcpy(new_arg + sep_idx, args->argv[*argi]); /* foo */
                                rv = parse_matched_arg(new_arg, outargs, opt, sep_idx,
                                                                        data, proc, is_opt);



Home | Main Index | Thread Index | Old Index