From ea98629aef9428ca270a76b77e8de49e523be0e4 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 3 Sep 2011 14:11:22 +1000 Subject: [PATCH] memset() is posix, bzero() is not change bzero into memset --- lib/init.c | 2 +- lib/libnfs.c | 46 +++++++++++++++++++++++----------------------- lib/pdu.c | 10 +++++----- nfs/nfs.c | 18 +++++++++--------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/init.c b/lib/init.c index 464f88a..7ef3292 100644 --- a/lib/init.c +++ b/lib/init.c @@ -40,7 +40,7 @@ struct rpc_context *rpc_init_context(void) if (rpc == NULL) { return NULL; } - bzero((char *)rpc, sizeof(struct rpc_context)); + memset(rpc, 0, sizeof(struct rpc_context)); rpc->encodebuflen = 65536; rpc->encodebuf = malloc(rpc->encodebuflen); diff --git a/lib/libnfs.c b/lib/libnfs.c index a70e6ac..d924c29 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -493,7 +493,7 @@ int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exp rpc_set_error(nfs->rpc, "out of memory. failed to allocate memory for nfs mount data"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); new_server = strdup(server); new_export = strdup(export); if (nfs->server != NULL) { @@ -614,7 +614,7 @@ static int nfs_lookuppath_async(struct nfs_context *nfs, const char *path, nfs_c rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->continue_cb = continue_cb; @@ -779,7 +779,7 @@ static void nfs_open_cb(struct rpc_context *rpc _U_, int status, void *command_d free_nfs_cb_data(data); return; } - bzero((char *)nfsfh, sizeof(struct nfsfh)); + memset(nfsfh, 0, sizeof(struct nfsfh)); if (data->continue_int & O_SYNC) { nfsfh->is_sync = 1; @@ -933,7 +933,7 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -979,7 +979,7 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_mcb_data structure"); return -1; } - bzero((char *)mdata, sizeof(struct nfs_mcb_data)); + memset(mdata, 0, sizeof(struct nfs_mcb_data)); mdata->data = data; mdata->offset = offset; mdata->count = readcount; @@ -1050,7 +1050,7 @@ int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -1109,7 +1109,7 @@ int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -1166,7 +1166,7 @@ int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -1225,12 +1225,12 @@ int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t leng rpc_set_error(nfs->rpc, "out of memory: failed to allocate nfs_cb_data structure"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; - bzero((char *)&args, sizeof(SETATTR3args)); + memset(&args, 0, sizeof(SETATTR3args)); args.object.data.data_len = nfsfh->fh.data.data_len; args.object.data.data_val = nfsfh->fh.data.data_val; args.new_attributes.size.set_it = 1; @@ -1483,7 +1483,7 @@ static void nfs_create_2_cb(struct rpc_context *rpc _U_, int status, void *comma free_nfs_cb_data(data); return; } - bzero((char *)nfsfh, sizeof(struct nfsfh)); + memset(nfsfh, 0, sizeof(struct nfsfh)); /* steal the filehandle */ nfsfh->fh.data.data_len = data->fh.data.data_len; @@ -1707,7 +1707,7 @@ static void nfs_opendir_cb(struct rpc_context *rpc _U_, int status, void *comman free_nfs_cb_data(data); return; } - bzero((char *)nfsdirent, sizeof(struct nfsdirent)); + memset(nfsdirent, 0, sizeof(struct nfsdirent)); nfsdirent->name = strdup(entry->name); if (nfsdirent->name == NULL) { data->cb(-ENOMEM, nfs, "Failed to allocate dirent->name", data->private_data); @@ -1761,7 +1761,7 @@ static int nfs_opendir_continue_internal(struct nfs_context *nfs, struct nfs_cb_ { cookieverf3 cv; - bzero((char *)cv, sizeof(cookieverf3)); + memset(cv, 0, sizeof(cookieverf3)); if (rpc_nfs_readdirplus_async(nfs->rpc, nfs_opendir_cb, &data->fh, 0, (char *)&cv, 8192, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send READDIRPLUS call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); @@ -1780,7 +1780,7 @@ int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void rpc_set_error(nfs->rpc, "failed to allocate buffer for nfsdir"); return -1; } - bzero((char *)nfsdir, sizeof(struct nfsdir)); + memset(nfsdir, 0, sizeof(struct nfsdir)); if (nfs_lookuppath_async(nfs, path, cb, private_data, nfs_opendir_continue_internal, nfsdir, free, 0) != 0) { rpc_set_error(nfs->rpc, "Out of memory: failed to start parsing the path components"); @@ -2054,7 +2054,7 @@ static int nfs_chmod_continue_internal(struct nfs_context *nfs, struct nfs_cb_da { SETATTR3args args; - bzero((char *)&args, sizeof(SETATTR3args)); + memset(&args, 0, sizeof(SETATTR3args)); args.object.data.data_len = data->fh.data.data_len; args.object.data.data_val = data->fh.data.data_val; args.new_attributes.mode.set_it = 1; @@ -2092,7 +2092,7 @@ int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs rpc_set_error(nfs->rpc, "out of memory. failed to allocate memory for nfs mount data"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -2158,7 +2158,7 @@ static int nfs_chown_continue_internal(struct nfs_context *nfs, struct nfs_cb_da SETATTR3args args; struct nfs_chown_data *chown_data = data->continue_data; - bzero((char *)&args, sizeof(SETATTR3args)); + memset(&args, 0, sizeof(SETATTR3args)); args.object.data.data_len = data->fh.data.data_len; args.object.data.data_val = data->fh.data.data_val; if (chown_data->uid != (uid_t)-1) { @@ -2225,7 +2225,7 @@ int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int rpc_set_error(nfs->rpc, "out of memory. failed to allocate memory for fchown data"); return -1; } - bzero((char *)data, sizeof(struct nfs_cb_data)); + memset(data, 0, sizeof(struct nfs_cb_data)); data->nfs = nfs; data->cb = cb; data->private_data = private_data; @@ -2289,7 +2289,7 @@ static int nfs_utimes_continue_internal(struct nfs_context *nfs, struct nfs_cb_d SETATTR3args args; struct timeval *utimes_data = data->continue_data; - bzero((char *)&args, sizeof(SETATTR3args)); + memset(&args, 0, sizeof(SETATTR3args)); args.object.data.data_len = data->fh.data.data_len; args.object.data.data_val = data->fh.data.data_val; if (utimes_data != NULL) { @@ -2537,7 +2537,7 @@ int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char * rpc_set_error(nfs->rpc, "Out of memory, failed to allocate buffer for symlink data"); return -1; } - bzero((char *)symlink_data, sizeof(struct nfs_symlink_data)); + memset(symlink_data, 0, sizeof(struct nfs_symlink_data)); symlink_data->oldpath = strdup(oldpath); if (symlink_data->oldpath == NULL) { @@ -2691,7 +2691,7 @@ int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *n rpc_set_error(nfs->rpc, "Out of memory, failed to allocate buffer for rename data"); return -1; } - bzero((char *)rename_data, sizeof(struct nfs_rename_data)); + memset(rename_data, 0, sizeof(struct nfs_rename_data)); rename_data->oldpath = strdup(oldpath); if (rename_data->oldpath == NULL) { @@ -2847,7 +2847,7 @@ int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *new rpc_set_error(nfs->rpc, "Out of memory, failed to allocate buffer for link data"); return -1; } - bzero((char *)link_data, sizeof(struct nfs_link_data)); + memset(link_data, 0, sizeof(struct nfs_link_data)); link_data->oldpath = strdup(oldpath); if (link_data->oldpath == NULL) { @@ -3067,7 +3067,7 @@ int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb c if (data == NULL) { return -1; } - bzero((char *)data, sizeof(struct mount_cb_data)); + memset(data, 0, sizeof(struct mount_cb_data)); data->cb = cb; data->private_data = private_data; data->server = strdup(server); diff --git a/lib/pdu.c b/lib/pdu.c index 135efcb..64a4af8 100644 --- a/lib/pdu.c +++ b/lib/pdu.c @@ -47,7 +47,7 @@ struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int versi rpc_set_error(rpc, "Out of memory: Failed to allocate pdu structure"); return NULL; } - bzero((char *)pdu, sizeof(struct rpc_pdu)); + memset(pdu, 0, sizeof(struct rpc_pdu)); pdu->xid = rpc->xid++; pdu->cb = cb; pdu->private_data = private_data; @@ -59,7 +59,7 @@ struct rpc_pdu *rpc_allocate_pdu(struct rpc_context *rpc, int program, int versi xdr_setpos(&pdu->xdr, 4); /* skip past the record marker */ } - bzero((char *)&msg, sizeof(struct rpc_msg)); + memset(&msg, 0, sizeof(struct rpc_msg)); msg.rm_xid = pdu->xid; msg.rm_direction = CALL; msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; @@ -152,7 +152,7 @@ static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR * { struct rpc_msg msg; - bzero((char *)&msg, sizeof(struct rpc_msg)); + memset(&msg, 0, sizeof(struct rpc_msg)); msg.acpted_rply.ar_verf = _null_auth; if (pdu->xdr_decode_bufsize > 0) { if (pdu->xdr_decode_buf != NULL) { @@ -164,7 +164,7 @@ static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR * pdu->cb(rpc, RPC_STATUS_ERROR, "Failed to allocate buffer for decoding of XDR reply", pdu->private_data); return 0; } - bzero((char *)pdu->xdr_decode_buf, pdu->xdr_decode_bufsize); + memset(pdu->xdr_decode_buf, 0, pdu->xdr_decode_bufsize); } msg.acpted_rply.ar_results.where = pdu->xdr_decode_buf; msg.acpted_rply.ar_results.proc = pdu->xdr_decode_fn; @@ -216,7 +216,7 @@ int rpc_process_pdu(struct rpc_context *rpc, char *buf, int size) int pos, recordmarker; unsigned int xid; - bzero((char *)&xdr, sizeof(XDR)); + memset(&xdr, 0, sizeof(XDR)); xdrmem_create(&xdr, buf, size, XDR_DECODE); if (rpc->is_udp == 0) { diff --git a/nfs/nfs.c b/nfs/nfs.c index 015c6df..8e8baf4 100644 --- a/nfs/nfs.c +++ b/nfs/nfs.c @@ -363,7 +363,7 @@ int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return -1; } - bzero((char *)&args, sizeof(MKDIR3args)); + memset(&args, 0, sizeof(MKDIR3args)); args.where.dir.data.data_len = fh->data.data_len; args.where.dir.data.data_val = fh->data.data_val; args.where.name = dir; @@ -399,7 +399,7 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return -1; } - bzero((char *)&args, sizeof(RMDIR3args)); + memset(&args, 0, sizeof(RMDIR3args)); args.object.dir.data.data_len = fh->data.data_len; args.object.dir.data.data_val = fh->data.data_val; args.object.name = dir; @@ -432,7 +432,7 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return -1; } - bzero((char *)&args, sizeof(CREATE3args)); + memset(&args, 0, sizeof(CREATE3args)); args.where.dir.data.data_len = fh->data.data_len; args.where.dir.data.data_val = fh->data.data_val; args.where.name = file; @@ -469,7 +469,7 @@ int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return -1; } - bzero((char *)&args, sizeof(REMOVE3args)); + memset(&args, 0, sizeof(REMOVE3args)); args.object.dir.data.data_len = fh->data.data_len; args.object.dir.data.data_val = fh->data.data_val; args.object.name = file; @@ -500,7 +500,7 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh return -1; } - bzero((char *)&args, sizeof(READDIR3args)); + memset(&args, 0, sizeof(READDIR3args)); args.dir.data.data_len = fh->data.data_len; args.dir.data.data_val = fh->data.data_val; args.cookie = cookie; @@ -533,7 +533,7 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 return -1; } - bzero((char *)&args, sizeof(READDIRPLUS3args)); + memset(&args, 0, sizeof(READDIRPLUS3args)); args.dir.data.data_len = fh->data.data_len; args.dir.data.data_val = fh->data.data_val; args.cookie = cookie; @@ -655,7 +655,7 @@ int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh return -1; } - bzero((char *)&args, sizeof(SYMLINK3args)); + memset(&args, 0, sizeof(SYMLINK3args)); args.where.dir.data.data_len = fh->data.data_len; args.where.dir.data.data_val = fh->data.data_val; args.where.name = newname; @@ -692,7 +692,7 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old return -1; } - bzero((char *)&args, sizeof(RENAME3args)); + memset(&args, 0, sizeof(RENAME3args)); args.from.dir.data.data_len = olddir->data.data_len; args.from.dir.data.data_val = olddir->data.data_val; args.from.name = oldname; @@ -729,7 +729,7 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, return -1; } - bzero((char *)&args, sizeof(LINK3args)); + memset(&args, 0, sizeof(LINK3args)); args.file.data.data_len = file->data.data_len; args.file.data.data_val = file->data.data_val; args.link.dir.data.data_len = newdir->data.data_len; -- 2.34.1