Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libperfuse make this compile again, and simplify.
details: https://anonhg.NetBSD.org/src/rev/3f31767c0942
branches: trunk
changeset: 348435:3f31767c0942
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 18 17:56:31 2016 +0000
description:
make this compile again, and simplify.
diffstat:
lib/libperfuse/fuse.h | 6 +++---
lib/libperfuse/perfuse.c | 41 ++++++++++++++++-------------------------
lib/libperfuse/perfuse_if.h | 11 +++++++++--
3 files changed, 28 insertions(+), 30 deletions(-)
diffs (139 lines):
diff -r 89be41c6abc7 -r 3f31767c0942 lib/libperfuse/fuse.h
--- a/lib/libperfuse/fuse.h Tue Oct 18 15:10:35 2016 +0000
+++ b/lib/libperfuse/fuse.h Tue Oct 18 17:56:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.6 2014/10/31 15:12:15 manu Exp $ */
+/* $NetBSD: fuse.h,v 1.7 2016/10/18 17:56:31 christos Exp $ */
/*-
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -34,8 +34,8 @@
#define FUSE_UNKNOWN_FH (uint64_t)0
#ifndef FUSE_BUFSIZE
-#define FUSE_MIN_BUFSIZE 0x21000
-#define FUSE_PREF_BUFSIZE (sysconf(_SC_PAGESIZE) + 0x1000)
+#define FUSE_MIN_BUFSIZE ((size_t)0x21000)
+#define FUSE_PREF_BUFSIZE ((size_t)(sysconf(_SC_PAGESIZE) + 0x1000))
#define FUSE_BUFSIZE MAX(FUSE_PREF_BUFSIZE /* CONSTCOND */, FUSE_MIN_BUFSIZE)
#endif /* FUSE_BUFSIZE */
diff -r 89be41c6abc7 -r 3f31767c0942 lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c Tue Oct 18 15:10:35 2016 +0000
+++ b/lib/libperfuse/perfuse.c Tue Oct 18 17:56:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse.c,v 1.38 2016/10/18 15:06:17 manu Exp $ */
+/* $NetBSD: perfuse.c,v 1.39 2016/10/18 17:56:31 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -32,6 +32,7 @@
#include <string.h>
#include <errno.h>
#include <puffs.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/resource.h>
@@ -51,7 +52,7 @@
static struct perfuse_state *init_state(void);
static int get_fd(const char *);
-static uint32_t bufvar_from_env(const char *, const uint32_t);
+static uint32_t bufvar_from_env(const char *, uint32_t);
static struct perfuse_state *
@@ -148,32 +149,22 @@
}
static uint32_t
-bufvar_from_env(name, defval)
- const char *name;
- const uint32_t defval;
+bufvar_from_env(const char *name, uint32_t defval)
{
char valstr[1024];
- uint32_t retval = defval;
+ int e;
+ uint32_t retval;
- if (getenv_r(name, valstr, sizeof(valstr)) != -1) {
- long int val;
- char *ep;
+ if (getenv_r(name, valstr, sizeof(valstr)) == -1)
+ return defval;
- errno = 0;
- val = (int)strtol(valstr, &ep, 10);
- if (*valstr == '\0' || *ep != '\0')
- DWARNX("bad %s value \"%s\"", name, valstr);
- else if (errno != 0)
- DWARN("bad %s value \"%s\"", name, valstr);
- else if (val <= 0L ||
- (unsigned long int)val > (unsigned long int)UINT32_MAX)
- DWARNX("%s value %ld out of "
- "uint32_t bounds", name, val);
- else
- retval = val;
- }
+ retval = (uint32_t)strtoi(valstr, NULL, 0, 0, UINT32_MAX, &e);
+ if (!e)
+ return retval;
- return retval;
+ DWARNC(e, "conversion from `%s' to uint32_t failed, using %u",
+ valstr, defval);
+ return defval;
}
int
@@ -213,7 +204,7 @@
* Set a buffer lentgh large enough so that enough FUSE packets
* will fit.
*/
- opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE);
+ opt = bufvar_from_env("PERFUSE_BUFSIZE", (uint32_t)(16 * FUSE_BUFSIZE));
optlen = sizeof(opt);
if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) != 0)
DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt);
@@ -244,7 +235,7 @@
* Set a buffer lentgh large enough so that enough FUSE packets
* will fit.
*/
- opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE);
+ opt = bufvar_from_env("PERFUSE_BUFSIZE", (uint32_t)(16 * FUSE_BUFSIZE));
optlen = sizeof(opt);
if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &opt, optlen) != 0)
DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt);
diff -r 89be41c6abc7 -r 3f31767c0942 lib/libperfuse/perfuse_if.h
--- a/lib/libperfuse/perfuse_if.h Tue Oct 18 15:10:35 2016 +0000
+++ b/lib/libperfuse/perfuse_if.h Tue Oct 18 17:56:31 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse_if.h,v 1.20 2012/07/21 05:49:42 manu Exp $ */
+/* $NetBSD: perfuse_if.h,v 1.21 2016/10/18 17:56:31 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -103,13 +103,20 @@
} while (0 /* CONSTCOND */)
#define DWARN(fmt, ...) do { \
- \
if (perfuse_diagflags & PDF_SYSLOG) \
syslog(LOG_WARNING, fmt ": %m", ## __VA_ARGS__); \
\
warn(fmt, ## __VA_ARGS__); \
} while (0 /* CONSTCOND */)
+#define DWARNC(e, fmt, ...) do { \
+ if (perfuse_diagflags & PDF_SYSLOG) { \
+ errno = e; \
+ syslog(LOG_WARNING, fmt ": %m", ## __VA_ARGS__); \
+ } \
+ warnc(e, fmt, ## __VA_ARGS__); \
+} while (0 /* CONSTCOND */)
+
/*
* frame handling callbacks
*/
Home |
Main Index |
Thread Index |
Old Index