Module Name:    src
Committed By:   pho
Date:           Sat Jan 22 07:58:32 UTC 2022

Modified Files:
        src/lib/librefuse: Makefile TODO refuse.c refuse_opt.c

Log Message:
Increase the warning level to spot more mistakes


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/librefuse/Makefile
cvs rdiff -u -r1.6 -r1.7 src/lib/librefuse/TODO
cvs rdiff -u -r1.105 -r1.106 src/lib/librefuse/refuse.c
cvs rdiff -u -r1.22 -r1.23 src/lib/librefuse/refuse_opt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librefuse/Makefile
diff -u src/lib/librefuse/Makefile:1.14 src/lib/librefuse/Makefile:1.15
--- src/lib/librefuse/Makefile:1.14	Sat Jan 22 07:53:06 2022
+++ src/lib/librefuse/Makefile	Sat Jan 22 07:58:32 2022
@@ -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 @@ CPPFLAGS+=	-I${.CURDIR}
 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
 

Index: src/lib/librefuse/TODO
diff -u src/lib/librefuse/TODO:1.6 src/lib/librefuse/TODO:1.7
--- src/lib/librefuse/TODO:1.6	Sat Jan 22 07:56:16 2022
+++ src/lib/librefuse/TODO	Sat Jan 22 07:58:32 2022
@@ -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 @@ Done
 ====
 statvfs
 sync
-WARNS=4
+WARNS=6
 address lint
 special directory handling in open()
 Finish off manual page

Index: src/lib/librefuse/refuse.c
diff -u src/lib/librefuse/refuse.c:1.105 src/lib/librefuse/refuse.c:1.106
--- src/lib/librefuse/refuse.c:1.105	Sat Jan 22 07:57:30 2022
+++ src/lib/librefuse/refuse.c	Sat Jan 22 07:58:32 2022
@@ -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 @@ puffs_fuse_fill_dir(void *buf, const cha
 		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 @@ puffs_fuse_node_readlink(struct puffs_us
 		if (!p)
 			return EINVAL;
 
-		*linklen = p - linkname;
+		*linklen = (size_t)(p - linkname);
 	}
 
 	return -ret;
@@ -948,9 +948,9 @@ puffs_fuse_node_read(struct puffs_usermo
 	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 @@ puffs_fuse_node_read(struct puffs_usermo
 	    &rn->file_info);
 
 	if (ret > 0) {
-		*resid -= ret;
+		*resid -= (size_t)ret;
 		ret = 0;
 	}
 
@@ -987,15 +987,15 @@ puffs_fuse_node_write(struct puffs_userm
 	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 @@ puffs_fuse_node_readdir(struct puffs_use
 			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 @@ fuse_new(struct fuse_args *args,
 	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)

Index: src/lib/librefuse/refuse_opt.c
diff -u src/lib/librefuse/refuse_opt.c:1.22 src/lib/librefuse/refuse_opt.c:1.23
--- src/lib/librefuse/refuse_opt.c:1.22	Sat Dec  4 06:42:39 2021
+++ src/lib/librefuse/refuse_opt.c	Sat Jan 22 07:58:32 2022
@@ -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 @@ fuse_opt_add_arg(struct fuse_args *args,
 	} 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 @@ fuse_opt_insert_arg(struct fuse_args *ar
 	} 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 @@ int fuse_opt_add_opt_escaped(char **opts
 	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 bool match_templ(const char *temp
 }
 
 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 @@ static int next_arg(const struct fuse_ar
 /* 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 @@ parse_matched_arg(const char* arg, struc
 #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 @@ parse_arg(struct fuse_args* args, int *a
 		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 @@ parse_arg(struct fuse_args* args, int *a
 
 				/* ...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);

Reply via email to