- fix warn/err confusiog

- fix debugging printf
- add func arguments to simple formats
This commit is contained in:
christos 2011-08-13 23:12:15 +00:00
parent 753ff12090
commit dda15b03dd
5 changed files with 34 additions and 28 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2011/06/28 20:28:48 riz Exp $
# $NetBSD: Makefile,v 1.7 2011/08/13 23:12:15 christos Exp $
LIB= perfuse
LIBDPLIBS+= puffs ${.CURDIR}/../libpuffs
@ -16,4 +16,8 @@ WARNS= 4
INCS= perfuse.h
INCSDIR= /usr/include
COPTS.ops.c = -Wno-format-nonliteral
COPTS.perfuse.c = -Wno-format-nonliteral
COPTS.subr.c = -Wno-format-nonliteral
.include <bsd.lib.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ops.c,v 1.38 2011/08/09 09:06:52 manu Exp $ */
/* $NetBSD: ops.c,v 1.39 2011/08/13 23:12:15 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@ -343,7 +343,7 @@ node_lookup_dir_nodot(pu, opc, name, namelen, pnp)
namelen = PNPLEN(dpn) + 1 + namelen + 1;
if ((path = malloc(namelen)) == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
(void)snprintf(path, namelen, "%s/%s",
perfuse_node_path((puffs_cookie_t)dpn), name);
@ -609,7 +609,7 @@ fuse_to_dirent(pu, opc, fd, fd_len)
dents = PERFUSE_NODE_DATA(opc)->pnd_dirent;
if ((dents = realloc(dents, dents_len)) == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
PERFUSE_NODE_DATA(opc)->pnd_dirent = dents;
PERFUSE_NODE_DATA(opc)->pnd_dirent_len = dents_len;
@ -831,7 +831,7 @@ perfuse_fs_init(pu)
ps = puffs_getspecific(pu);
if (puffs_mount(pu, ps->ps_target, ps->ps_mountflags, ps->ps_root) != 0)
DERR(EX_OSERR, "puffs_mount failed");
DERR(EX_OSERR, "%s: puffs_mount failed", __func__);
/*
* Linux 2.6.34.1 sends theses flags:
@ -2388,7 +2388,7 @@ perfuse_node_readdir(pu, opc, dent, readoff,
pnd->pnd_all_fd = realloc(pnd->pnd_all_fd,
pnd->pnd_all_fd_len + fd_len);
if (pnd->pnd_all_fd == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
afdp = (char *)(void *)pnd->pnd_all_fd + pnd->pnd_all_fd_len;
(void)memcpy(afdp, fd, fd_len);

View File

@ -1,4 +1,4 @@
/* $NetBSD: perfuse.c,v 1.17 2011/08/09 06:58:33 manu Exp $ */
/* $NetBSD: perfuse.c,v 1.18 2011/08/13 23:12:15 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@ -57,7 +57,7 @@ init_state(void)
char opts[1024];
if ((ps = malloc(sizeof(*ps))) == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
(void)memset(ps, 0, sizeof(*ps));
ps->ps_max_write = UINT_MAX;
@ -164,7 +164,7 @@ perfuse_open(path, flags, mode)
if ((sv[0] = socket(PF_LOCAL, SOCK_DGRAM, 0)) == -1) {
#ifdef PERFUSE_DEBUG
DWARN("%s:%d socket failed: %s", __func__, __LINE__);
DWARN("%s: %d socket failed", __func__, __LINE__);
#endif
return -1;
}
@ -412,7 +412,7 @@ perfuse_init(pc, pmi)
if (pmi->pmi_source) {
if ((ps->ps_source = strdup(pmi->pmi_source)) == NULL)
DERR(EX_OSERR, "strdup failed");
DERR(EX_OSERR, "%s: strdup failed", __func__);
source = ps->ps_source;
}
@ -422,20 +422,20 @@ perfuse_init(pc, pmi)
ps->ps_filesystemtype = strdup(pmi->pmi_filesystemtype);
if (ps->ps_filesystemtype == NULL)
DERR(EX_OSERR, "strdup failed");
DERR(EX_OSERR, "%s: strdup failed", __func__);
len = sizeof("perfuse|") + strlen(ps->ps_filesystemtype) + 1;
if ((fstype = malloc(len)) == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
(void)sprintf(fstype, "perfuse|%s", ps->ps_filesystemtype);
} else {
if ((fstype = strdup("perfuse")) == NULL)
DERR(EX_OSERR, "strdup failed");
DERR(EX_OSERR, "%s: strdup failed", __func__);
}
if ((ps->ps_target = strdup(pmi->pmi_target)) == NULL)
DERR(EX_OSERR, "strdup failed");
DERR(EX_OSERR, "%s: strdup failed", __func__);
ps->ps_mountflags = pmi->pmi_mountflags;
@ -508,7 +508,7 @@ perfuse_init(pc, pmi)
puffs_flags |= PUFFS_FLAG_OPDUMP;
if ((pu = puffs_init(pops, source, fstype, ps, puffs_flags)) == NULL)
DERR(EX_OSERR, "puffs_init failed");
DERR(EX_OSERR, "%s: puffs_init failed", __func__);
ps->ps_pu = pu;
@ -594,7 +594,7 @@ perfuse_mainloop(pu)
ps->ps_flags |= PS_INLOOP;
if (puffs_mainloop(ps->ps_pu) != 0) {
DERR(EX_OSERR, "puffs_mainloop failed");
DERR(EX_OSERR, "%s: failed", __func__);
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: perfuse_if.h,v 1.13 2011/05/30 14:50:08 manu Exp $ */
/* $NetBSD: perfuse_if.h,v 1.14 2011/08/13 23:12:15 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@ -81,7 +81,8 @@ extern int perfuse_diagflags;
char strerrbuf[BUFSIZ]; \
\
(void)strerror_r(errno, strerrbuf, sizeof(strerrbuf)); \
(void)sprintf(fmterr, "%s: %s\n", fmt, strerrbuf); \
(void)snprintf(fmterr, sizeof(fmterr), "%s: %s\n", fmt, \
strerrbuf); \
\
if (perfuse_diagflags & PDF_SYSLOG) \
syslog(LOG_ERR, fmterr, ## __VA_ARGS__); \
@ -90,7 +91,7 @@ extern int perfuse_diagflags;
(void)fprintf(stderr, fmterr, ## __VA_ARGS__); \
abort(); \
} else { \
errx(status, fmt, ## __VA_ARGS__); \
err(status, fmt, ## __VA_ARGS__); \
} \
} while (0 /* CONSTCOND */)
@ -102,16 +103,17 @@ extern int perfuse_diagflags;
} while (0 /* CONSTCOND */)
#define DWARN(fmt, ...) do { \
char fmterr[BUFSIZ]; \
char strerrbuf[BUFSIZ]; \
\
(void)strerror_r(errno, strerrbuf, sizeof(strerrbuf)); \
(void)sprintf(fmterr, "%s: %s\n", fmt, strerrbuf); \
if (perfuse_diagflags & PDF_SYSLOG) { \
char fmterr[BUFSIZ]; \
char strerrbuf[BUFSIZ]; \
\
if (perfuse_diagflags & PDF_SYSLOG) \
(void)strerror_r(errno, strerrbuf, sizeof(strerrbuf)); \
(void)sprintf(fmterr, "%s: %s\n", fmt, strerrbuf); \
syslog(LOG_WARNING, fmterr, ## __VA_ARGS__); \
} \
\
warn(fmterr, ## __VA_ARGS__); \
warn(fmt, ## __VA_ARGS__); \
} while (0 /* CONSTCOND */)
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr.c,v 1.12 2011/06/28 16:19:16 manu Exp $ */
/* $NetBSD: subr.c,v 1.13 2011/08/13 23:12:15 christos Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@ -58,10 +58,10 @@ perfuse_new_pn(pu, name, parent)
struct perfuse_node_data *pnd;
if ((pnd = malloc(sizeof(*pnd))) == NULL)
DERR(EX_OSERR, "malloc failed");
DERR(EX_OSERR, "%s: malloc failed", __func__);
if ((pn = puffs_pn_new(pu, pnd)) == NULL)
DERR(EX_SOFTWARE, "puffs_pn_new failed");
DERR(EX_SOFTWARE, "%s: puffs_pn_new failed", __func__);
(void)memset(pnd, 0, sizeof(*pnd));
pnd->pnd_rfh = FUSE_UNKNOWN_FH;