removing unnecessary ZeroMemory calls
instead of calling ZeroMemory(foobar) to initialize the data structure,
during declaration do struct some_struct foobar = { 0 }
This commit is contained in:
parent
62c00bff40
commit
969783d46b
11 changed files with 25 additions and 55 deletions
|
|
@ -271,7 +271,7 @@ static int handle_getacl(nfs41_upcall *upcall)
|
|||
int status = ERROR_NOT_SUPPORTED;
|
||||
getacl_upcall_args *args = &upcall->args.getacl;
|
||||
nfs41_open_state *state = upcall->state_ref;
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
bitmap4 attr_request = { 0 };
|
||||
LPSTR domain = NULL;
|
||||
SECURITY_DESCRIPTOR sec_desc;
|
||||
|
|
@ -282,7 +282,6 @@ static int handle_getacl(nfs41_upcall *upcall)
|
|||
char owner[NFS4_OPAQUE_LIMIT], group[NFS4_OPAQUE_LIMIT];
|
||||
|
||||
// need to cache owner/group information XX
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
attr_request.count = 2;
|
||||
attr_request.arr[1] = FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP;
|
||||
if (args->query & DACL_SECURITY_INFORMATION) {
|
||||
|
|
@ -713,14 +712,12 @@ static int handle_setacl(nfs41_upcall *upcall)
|
|||
int status = ERROR_NOT_SUPPORTED;
|
||||
setacl_upcall_args *args = &upcall->args.setacl;
|
||||
nfs41_open_state *state = upcall->state_ref;
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
stateid_arg stateid;
|
||||
nfsacl41 nfs4_acl = { 0 };
|
||||
PSID sid = NULL, gsid = NULL;
|
||||
BOOL sid_default, gsid_default;
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
|
||||
if (args->query & OWNER_SECURITY_INFORMATION) {
|
||||
dprintf(1, "handle_setacl: OWNER_SECURITY_INFORMATION\n");
|
||||
status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,7 @@ static int handle_getattr(nfs41_upcall *upcall)
|
|||
int status;
|
||||
getattr_upcall_args *args = &upcall->args.getattr;
|
||||
nfs41_open_state *state = upcall->state_ref;
|
||||
nfs41_file_info info;
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
nfs41_file_info info = { 0 };
|
||||
|
||||
status = nfs41_cached_getattr(state->session, &state->file, &info);
|
||||
if (status) {
|
||||
|
|
|
|||
|
|
@ -92,9 +92,6 @@ static void init_component_args(
|
|||
{
|
||||
uint32_t i;
|
||||
|
||||
ZeroMemory(args, sizeof(nfs41_lookup_component_args));
|
||||
ZeroMemory(res, sizeof(nfs41_lookup_component_res));
|
||||
|
||||
args->attr_request.count = 2;
|
||||
args->attr_request.arr[0] = FATTR4_WORD0_TYPE
|
||||
| FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE
|
||||
|
|
@ -328,8 +325,8 @@ static int server_lookup_loop(
|
|||
OUT OPTIONAL nfs41_path_fh *target_out,
|
||||
OUT OPTIONAL nfs41_file_info *info_out)
|
||||
{
|
||||
nfs41_lookup_component_args args;
|
||||
nfs41_lookup_component_res res;
|
||||
nfs41_lookup_component_args args = { 0 };
|
||||
nfs41_lookup_component_res res = { 0 };
|
||||
nfs41_path_fh *dir, *parent, *target;
|
||||
const char *path_end;
|
||||
const uint32_t max_components = max_lookup_components(session);
|
||||
|
|
|
|||
|
|
@ -1207,9 +1207,9 @@ static int rpc_array_putfh(
|
|||
nfs_argop4 argops[1+MAX_PUTFH_PER_COMPOUND];
|
||||
nfs_resop4 resops[1+MAX_PUTFH_PER_COMPOUND];
|
||||
nfs41_sequence_args sequence_args;
|
||||
nfs41_sequence_res sequence_res;
|
||||
nfs41_sequence_res sequence_res = { 0 };
|
||||
nfs41_putfh_args putfh_args[MAX_PUTFH_PER_COMPOUND];
|
||||
nfs41_putfh_res putfh_res[MAX_PUTFH_PER_COMPOUND];
|
||||
nfs41_putfh_res putfh_res[MAX_PUTFH_PER_COMPOUND] = { 0 };
|
||||
uint32_t i;
|
||||
int status;
|
||||
|
||||
|
|
@ -1221,8 +1221,6 @@ static int rpc_array_putfh(
|
|||
status = nfs41_session_sequence(&sequence_args, session, 0);
|
||||
if (status)
|
||||
goto out;
|
||||
ZeroMemory(&sequence_res, sizeof(sequence_res));
|
||||
ZeroMemory(putfh_res, sizeof(putfh_res));
|
||||
|
||||
for (i = 0; i < count; i++){
|
||||
compound_add_op(&compound, OP_PUTFH, &putfh_args[i], &putfh_res[i]);
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ int nfs41_root_mount_addrs(
|
|||
IN OPTIONAL uint32_t lease_time,
|
||||
OUT nfs41_client **client_out)
|
||||
{
|
||||
nfs41_exchange_id_res exchangeid;
|
||||
nfs41_exchange_id_res exchangeid = { 0 };
|
||||
nfs41_rpc_clnt *rpc;
|
||||
nfs41_client *client, *existing;
|
||||
int status;
|
||||
|
|
@ -367,7 +367,6 @@ int nfs41_root_mount_addrs(
|
|||
}
|
||||
|
||||
/* get a clientid with exchangeid */
|
||||
ZeroMemory(&exchangeid, sizeof(exchangeid));
|
||||
status = nfs41_exchange_id(rpc, &root->client_owner,
|
||||
nfs41_exchange_id_flags(is_data), &exchangeid);
|
||||
if (status) {
|
||||
|
|
|
|||
|
|
@ -159,10 +159,9 @@ static int getdomainname(char *domain)
|
|||
}
|
||||
|
||||
if (net_info->DomainName[0] == '\0') {
|
||||
struct addrinfo *result = NULL, *ptr = NULL, hints;
|
||||
struct addrinfo *result = NULL, *ptr = NULL, hints = { 0 };
|
||||
char hostname[NI_MAXHOST], servInfo[NI_MAXSERV];
|
||||
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
|
|
@ -290,11 +289,9 @@ static void dprint_roles(
|
|||
int nfs41_client_renew(
|
||||
IN nfs41_client *client)
|
||||
{
|
||||
nfs41_exchange_id_res exchangeid;
|
||||
nfs41_exchange_id_res exchangeid = { 0 };
|
||||
int status;
|
||||
|
||||
ZeroMemory(&exchangeid, sizeof(exchangeid));
|
||||
|
||||
status = nfs41_exchange_id(client->rpc, &client->owner,
|
||||
nfs41_exchange_id_flags(client->is_data), &exchangeid);
|
||||
if (status) {
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ restart_recovery:
|
|||
saved_auth = session->client->rpc->rpc->cl_auth;
|
||||
if (op == OP_LOOKUP || op == OP_OPEN) {
|
||||
const nfs41_component *name;
|
||||
nfs41_path_fh *file = NULL, tmp;
|
||||
nfs41_path_fh *file = NULL, tmp = { 0 };
|
||||
if (compound->args.argarray[compound->res.resarray_count-2].op == OP_PUTFH) {
|
||||
nfs41_putfh_args *putfh = (nfs41_putfh_args*)
|
||||
compound->args.argarray[compound->res.resarray_count-2].arg;
|
||||
|
|
@ -390,7 +390,6 @@ restart_recovery:
|
|||
compound->args.argarray[compound->res.resarray_count-3].op == OP_GETFH) {
|
||||
nfs41_getfh_res *getfh = (nfs41_getfh_res *)
|
||||
compound->res.resarray[compound->res.resarray_count-3].res;
|
||||
ZeroMemory(&tmp, sizeof(nfs41_path_fh));
|
||||
memcpy(&tmp.fh, getfh->fh, sizeof(nfs41_fh));
|
||||
file = &tmp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,14 +112,13 @@ int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_
|
|||
nfs41_compound compound;
|
||||
nfs_argop4 argop;
|
||||
nfs_resop4 resop;
|
||||
nfs41_create_session_args req;
|
||||
nfs41_create_session_res reply;
|
||||
nfs41_create_session_args req = { 0 };
|
||||
nfs41_create_session_res reply = { 0 };
|
||||
|
||||
compound_init(&compound, &argop, &resop, "create_session");
|
||||
|
||||
compound_add_op(&compound, OP_CREATE_SESSION, &req, &reply);
|
||||
|
||||
ZeroMemory(&req, sizeof(req));
|
||||
AcquireSRWLockShared(&clnt->exid_lock);
|
||||
req.csa_clientid = clnt->clnt_id;
|
||||
req.csa_sequence = clnt->seq_id;
|
||||
|
|
@ -137,7 +136,6 @@ int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_
|
|||
set_back_channel_attrs(clnt->rpc,
|
||||
1, &req.csa_back_chan_attrs);
|
||||
|
||||
ZeroMemory(&reply, sizeof(nfs41_create_session_res));
|
||||
reply.csr_sessionid = session->session_id;
|
||||
reply.csr_fore_chan_attrs = &session->fore_chan_attrs;
|
||||
reply.csr_back_chan_attrs = &session->back_chan_attrs;
|
||||
|
|
@ -201,15 +199,14 @@ enum nfsstat4 nfs41_bind_conn_to_session(
|
|||
nfs41_compound compound;
|
||||
nfs_argop4 argop;
|
||||
nfs_resop4 resop;
|
||||
nfs41_bind_conn_to_session_args bind_args;
|
||||
nfs41_bind_conn_to_session_res bind_res;
|
||||
nfs41_bind_conn_to_session_args bind_args = { 0 };
|
||||
nfs41_bind_conn_to_session_res bind_res = { 0 };
|
||||
|
||||
compound_init(&compound, &argop, &resop, "bind_conn_to_session");
|
||||
|
||||
compound_add_op(&compound, OP_BIND_CONN_TO_SESSION, &bind_args, &bind_res);
|
||||
bind_args.sessionid = (unsigned char *)sessionid;
|
||||
bind_args.dir = dir;
|
||||
ZeroMemory(&bind_res, sizeof(bind_res));
|
||||
|
||||
status = nfs41_send_compound(rpc,
|
||||
(char*)&compound.args, (char*)&compound.res);
|
||||
|
|
@ -1379,13 +1376,12 @@ int nfs41_link(
|
|||
nfs41_getfh_res getfh_res;
|
||||
nfs41_getattr_args getattr_args[2];
|
||||
nfs41_getattr_res getattr_res[2];
|
||||
nfs41_file_info info[2];
|
||||
nfs41_file_info info[2] = { 0 };
|
||||
nfs41_path_fh file;
|
||||
|
||||
if (link_out == NULL)
|
||||
link_out = &file;
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
init_getattr_request(&info[0].attrmask);
|
||||
init_getattr_request(&info[1].attrmask);
|
||||
info[1].attrmask.arr[0] |= FATTR4_WORD0_FSID;
|
||||
|
|
@ -1862,7 +1858,7 @@ enum nfsstat4 pnfs_rpc_layoutget(
|
|||
nfs41_putfh_args putfh_args;
|
||||
nfs41_putfh_res putfh_res;
|
||||
pnfs_layoutget_args layoutget_args;
|
||||
pnfs_layoutget_res layoutget_res;
|
||||
pnfs_layoutget_res layoutget_res = { 0 };
|
||||
uint32_t i;
|
||||
struct list_entry *entry;
|
||||
|
||||
|
|
@ -1886,7 +1882,7 @@ enum nfsstat4 pnfs_rpc_layoutget(
|
|||
layoutget_args.length = length;
|
||||
layoutget_args.stateid = stateid;
|
||||
layoutget_args.maxcount = session->fore_chan_attrs.ca_maxresponsesize - READ_OVERHEAD;
|
||||
ZeroMemory(&layoutget_res, sizeof(layoutget_res));
|
||||
|
||||
layoutget_res.u.res_ok = layoutget_res_ok;
|
||||
|
||||
status = compound_encode_send_decode(session, &compound, TRUE);
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ int nfs41_server_resolve(
|
|||
{
|
||||
int status = ERROR_BAD_NET_NAME;
|
||||
char service[16];
|
||||
struct addrinfo hints, *res, *info;
|
||||
struct addrinfo hints = { 0 }, *res, *info;
|
||||
struct netconfig *nconf;
|
||||
struct netbuf addr;
|
||||
char *netid, *uaddr;
|
||||
|
|
@ -297,7 +297,6 @@ int nfs41_server_resolve(
|
|||
StringCchPrintfA(service, 16, "%u", port);
|
||||
|
||||
/* request a list of tcp addrs for the given hostname,port */
|
||||
ZeroMemory(&hints, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static int get_superblock_attrs(
|
|||
{
|
||||
int status;
|
||||
bitmap4 attr_request;
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
|
||||
attr_request.arr[0] = FATTR4_WORD0_SUPPORTED_ATTRS |
|
||||
FATTR4_WORD0_LINK_SUPPORT | FATTR4_WORD0_SYMLINK_SUPPORT |
|
||||
|
|
@ -93,7 +93,6 @@ static int get_superblock_attrs(
|
|||
FATTR4_WORD1_TIME_DELTA;
|
||||
attr_request.count = 2;
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
info.supported_attrs = &superblock->supported_attrs;
|
||||
info.time_delta = &superblock->time_delta;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,11 +74,9 @@ static int handle_nfs41_setattr(setattr_upcall_args *args)
|
|||
nfs41_open_state *state = args->state;
|
||||
nfs41_superblock *superblock = state->file.fh.superblock;
|
||||
stateid_arg stateid;
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
int status = NO_ERROR;
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
|
||||
/* hidden */
|
||||
info.hidden = basic_info->FileAttributes & FILE_ATTRIBUTE_HIDDEN ? 1 : 0;
|
||||
info.attrmask.arr[0] |= FATTR4_WORD0_HIDDEN;
|
||||
|
|
@ -205,13 +203,12 @@ static int handle_nfs41_rename(setattr_upcall_args *args)
|
|||
nfs41_open_state *state = args->state;
|
||||
nfs41_session *dst_session;
|
||||
PFILE_RENAME_INFO rename = (PFILE_RENAME_INFO)args->buf;
|
||||
nfs41_abs_path dst_path;
|
||||
nfs41_abs_path dst_path = { 0 };
|
||||
nfs41_path_fh dst_dir, dst;
|
||||
nfs41_component dst_name, *src_name;
|
||||
uint32_t depth = 0;
|
||||
int status;
|
||||
|
||||
ZeroMemory(&dst_path, sizeof(dst_path));
|
||||
src_name = &state->file.name;
|
||||
|
||||
if (rename->FileNameLength == 0) {
|
||||
|
|
@ -336,7 +333,7 @@ out:
|
|||
|
||||
static int handle_nfs41_set_size(setattr_upcall_args *args)
|
||||
{
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
stateid_arg stateid;
|
||||
/* note: this is called with either FILE_END_OF_FILE_INFO or
|
||||
* FILE_ALLOCATION_INFO, both of which contain a single LARGE_INTEGER */
|
||||
|
|
@ -350,9 +347,7 @@ static int handle_nfs41_set_size(setattr_upcall_args *args)
|
|||
|
||||
nfs41_open_stateid_arg(state, &stateid);
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
info.size = size->QuadPart;
|
||||
|
||||
info.attrmask.count = 1;
|
||||
info.attrmask.arr[0] = FATTR4_WORD0_SIZE;
|
||||
|
||||
|
|
@ -370,14 +365,12 @@ static int handle_nfs41_link(setattr_upcall_args *args)
|
|||
nfs41_open_state *state = args->state;
|
||||
PFILE_LINK_INFORMATION link = (PFILE_LINK_INFORMATION)args->buf;
|
||||
nfs41_session *dst_session;
|
||||
nfs41_abs_path dst_path;
|
||||
nfs41_abs_path dst_path = { 0 };
|
||||
nfs41_path_fh dst_dir, dst;
|
||||
nfs41_component dst_name;
|
||||
uint32_t depth = 0;
|
||||
int status;
|
||||
|
||||
ZeroMemory(&dst_path, sizeof(dst_path));
|
||||
|
||||
dst_path.len = (unsigned short)WideCharToMultiByte(CP_UTF8, 0,
|
||||
link->FileName, link->FileNameLength/sizeof(WCHAR),
|
||||
dst_path.path, NFS41_MAX_PATH_LEN, NULL, NULL);
|
||||
|
|
@ -520,7 +513,7 @@ static int handle_setexattr(nfs41_upcall *upcall)
|
|||
setexattr_upcall_args *args = &upcall->args.setexattr;
|
||||
nfs41_open_state *state = upcall->state_ref;
|
||||
stateid_arg stateid;
|
||||
nfs41_file_info info;
|
||||
nfs41_file_info info = { 0 };
|
||||
|
||||
/* break read delegations before SETATTR */
|
||||
nfs41_delegation_return(state->session, &state->file,
|
||||
|
|
@ -528,8 +521,6 @@ static int handle_setexattr(nfs41_upcall *upcall)
|
|||
|
||||
nfs41_open_stateid_arg(state, &stateid);
|
||||
|
||||
ZeroMemory(&info, sizeof(info));
|
||||
|
||||
/* mode */
|
||||
info.mode = args->mode;
|
||||
info.attrmask.arr[1] |= FATTR4_WORD1_MODE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue