Minor cleanup - change uses of malloc, memset to calloc.

Use EXIT_FAILURE in preference to the less informational 1.
This commit is contained in:
agc 2007-06-12 18:54:36 +00:00
parent e4f18e1082
commit 8dda7dd1f3
1 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: refuse.c,v 1.64 2007/06/12 18:53:29 agc Exp $ */ /* $NetBSD: refuse.c,v 1.65 2007/06/12 18:54:36 agc Exp $ */
/* /*
* Copyright © 2007 Alistair Crooks. All rights reserved. * Copyright © 2007 Alistair Crooks. All rights reserved.
@ -30,7 +30,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if !defined(lint) #if !defined(lint)
__RCSID("$NetBSD: refuse.c,v 1.64 2007/06/12 18:53:29 agc Exp $"); __RCSID("$NetBSD: refuse.c,v 1.65 2007/06/12 18:54:36 agc Exp $");
#endif /* !lint */ #endif /* !lint */
#include <assert.h> #include <assert.h>
@ -167,10 +167,9 @@ fill_dirbuf(struct puffs_fuse_dirh *dh, const char *name, ino_t dino,
/* initial? */ /* initial? */
if (dh->bufsize == 0) { if (dh->bufsize == 0) {
if ((dh->dbuf = malloc(DIR_CHUNKSIZE)) == NULL) { if ((dh->dbuf = calloc(1, DIR_CHUNKSIZE)) == NULL) {
err(EXIT_FAILURE, "fill_dirbuf"); err(EXIT_FAILURE, "fill_dirbuf");
} }
(void) memset(dh->dbuf, 0x0, DIR_CHUNKSIZE);
dh->d = dh->dbuf; dh->d = dh->dbuf;
dh->reslen = dh->bufsize = DIR_CHUNKSIZE; dh->reslen = dh->bufsize = DIR_CHUNKSIZE;
} }
@ -1139,13 +1138,14 @@ fuse_mount(const char *dir, struct fuse_args *args)
struct fuse_chan *fc; struct fuse_chan *fc;
char name[64]; char name[64];
if ((fc = malloc(sizeof(*fc))) == NULL) if ((fc = calloc(1, sizeof(*fc))) == NULL) {
err(1, "fuse_mount"); err(EXIT_FAILURE, "fuse_mount");
(void) memset(fc, 0x0, sizeof(*fc)); }
fc->dead = 0; fc->dead = 0;
if ((fc->dir = strdup(dir)) == NULL) if ((fc->dir = strdup(dir)) == NULL) {
err(1, "fuse_mount"); err(EXIT_FAILURE, "fuse_mount");
}
/* /*
* we need to deep copy the args struct - some fuse file * we need to deep copy the args struct - some fuse file
@ -1180,9 +1180,9 @@ fuse_new(struct fuse_chan *fc, struct fuse_args *args,
char name[64]; char name[64];
char *argv0; char *argv0;
if ((fuse = malloc(sizeof(*fuse))) == NULL) if ((fuse = calloc(1, sizeof(*fuse))) == NULL) {
err(1, "fuse_new"); err(EXIT_FAILURE, "fuse_new");
(void) memset(fuse, 0x0, sizeof(*fuse)); }
/* copy fuse ops to their own stucture */ /* copy fuse ops to their own stucture */
(void) memcpy(&fuse->op, ops, sizeof(fuse->op)); (void) memcpy(&fuse->op, ops, sizeof(fuse->op));