diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c index f7af9d2..5a41d99 100644 --- a/daemon/nfs41_ops.c +++ b/daemon/nfs41_ops.c @@ -764,13 +764,13 @@ int nfs41_write( nfs41_putfh_res putfh_res; nfs41_write_args write_args; nfs41_write_res write_res; - nfs41_getattr_args getattr_args; - nfs41_getattr_res getattr_res = {0}; - bitmap4 attr_request; - nfs41_file_info info = { 0 }, *pinfo; - - nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request); - + nfs41_getattr_args getattr_args; + nfs41_getattr_res getattr_res = {0}; + bitmap4 attr_request; + nfs41_file_info info, *pinfo; + + nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request); + compound_init(&compound, argops, resops, stateid->stateid.seqid == 0 ? "ds write" : "write"); @@ -786,14 +786,19 @@ int nfs41_write( write_args.offset = offset; write_args.stable = stable; write_args.data_len = data_len; - write_args.data = data; - write_res.resok4.verf = verf; - - if (cinfo) pinfo = cinfo; - else pinfo = &info; - - if (stable != UNSTABLE4) { - /* if the write is stable, we can't rely on COMMIT to update + write_args.data = data; + write_res.resok4.verf = verf; + + if (cinfo) { + pinfo = cinfo; + } + else { + (void)memset(&info, 0, sizeof(info)); + pinfo = &info; + } + + if (stable != UNSTABLE4) { + /* if the write is stable, we can't rely on COMMIT to update * the attribute cache, so we do the GETATTR here */ compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res); getattr_args.attr_request = &attr_request; @@ -1839,10 +1844,10 @@ enum nfsstat4 nfs41_fs_locations( nfs41_lookup_res lookup_res; nfs41_getattr_args getattr_args; nfs41_getattr_res getattr_res NDSH(= { 0 }); - bitmap4 attr_request = { 1, { FATTR4_WORD0_FS_LOCATIONS } }; + bitmap4 attr_request = { .count=1, .arr[0]=FATTR4_WORD0_FS_LOCATIONS }; nfs41_file_info info; - compound_init(&compound, argops, resops, "fs_locations"); + compound_init(&compound, argops, resops, "fs_locations"); compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res); nfs41_session_sequence(&sequence_args, session, 0); diff --git a/daemon/readwrite.c b/daemon/readwrite.c index bdfb902..14e4bcb 100644 --- a/daemon/readwrite.c +++ b/daemon/readwrite.c @@ -183,13 +183,15 @@ static int write_to_mds( unsigned char *p; const uint32_t maxwritesize = max_write_size(session, &file->fh); uint32_t to_send, reloffset, len; - int status = 0; - /* on write verifier mismatch, retry N times before failing */ - uint32_t retries = MAX_WRITE_RETRIES; - nfs41_file_info info = { 0 }; - -retry_write: - p = args->buffer; + int status = 0; + /* on write verifier mismatch, retry N times before failing */ + uint32_t retries = MAX_WRITE_RETRIES; + nfs41_file_info info; + + (void)memset(&info, 0, sizeof(info)); + +retry_write: + p = args->buffer; to_send = args->len; reloffset = 0; len = 0; @@ -258,13 +260,15 @@ static int write_to_pnfs( IN nfs41_upcall *upcall, IN stateid_arg *stateid) { - readwrite_upcall_args *args = &upcall->args.rw; - pnfs_layout_state *layout; - int status = NO_ERROR; - nfs41_file_info info = { 0 }; - - if (pnfs_layout_state_open(upcall->state_ref, &layout)) { - status = ERROR_NOT_SUPPORTED; + readwrite_upcall_args *args = &upcall->args.rw; + pnfs_layout_state *layout; + int status = NO_ERROR; + nfs41_file_info info; + + (void)memset(&info, 0, sizeof(info)); + + if (pnfs_layout_state_open(upcall->state_ref, &layout)) { + status = ERROR_NOT_SUPPORTED; goto out; } diff --git a/daemon/setattr.c b/daemon/setattr.c index e01e962..5e401a8 100644 --- a/daemon/setattr.c +++ b/daemon/setattr.c @@ -62,10 +62,13 @@ static int handle_nfs41_setattr_basicinfo(void *daemon_context, setattr_upcall_a nfs41_open_state *state = args->state; nfs41_superblock *superblock = state->file.fh.superblock; stateid_arg stateid; - nfs41_file_info info = { 0 }, old_info = { 0 }; + nfs41_file_info info, old_info; int status = NO_ERROR; int getattr_status; + (void)memset(&info, 0, sizeof(info)); + (void)memset(&old_info, 0, sizeof(old_info)); + getattr_status = nfs41_cached_getattr(state->session, &state->file, &old_info); if (getattr_status) { @@ -370,14 +373,16 @@ static int handle_nfs41_rename(void *daemon_context, setattr_upcall_args *args) static int handle_nfs41_set_size(void *daemon_context, setattr_upcall_args *args) { - nfs41_file_info info = { 0 }; + nfs41_file_info info; 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 */ + /* note: this is called with either FILE_END_OF_FILE_INFO or + * FILE_ALLOCATION_INFO, both of which contain a single LARGE_INTEGER */ PLARGE_INTEGER size = (PLARGE_INTEGER)args->buf; nfs41_open_state *state = args->state; int status; + (void)memset(&info, 0, sizeof(info)); + EASSERT_MSG(args->buf_len == sizeof(size->QuadPart), ("args->buf_len=%ld\n", (long)args->buf_len)); @@ -420,15 +425,17 @@ static int handle_nfs41_link(void *daemon_context, setattr_upcall_args *args) PFILE_LINK_INFORMATION link = (PFILE_LINK_INFORMATION)args->buf; nfs41_session *dst_session; nfs41_abs_path dst_path = { 0 }; - nfs41_path_fh dst_dir, dst; - nfs41_component dst_name; - uint32_t depth = 0; - nfs41_file_info info = { 0 }; - int status; - - dst_path.len = (unsigned short)WideCharToMultiByte(CP_UTF8, 0, - link->FileName, link->FileNameLength/sizeof(WCHAR), - dst_path.path, NFS41_MAX_PATH_LEN, NULL, NULL); + nfs41_path_fh dst_dir, dst; + nfs41_component dst_name; + uint32_t depth = 0; + nfs41_file_info info; + int status; + + (void)memset(&info, 0, sizeof(info)); + + dst_path.len = (unsigned short)WideCharToMultiByte(CP_UTF8, 0, + link->FileName, link->FileNameLength/sizeof(WCHAR), + dst_path.path, NFS41_MAX_PATH_LEN, NULL, NULL); if (dst_path.len == 0) { eprintf("WideCharToMultiByte failed to convert destination " "filename %S.\n", link->FileName); diff --git a/daemon/util.h b/daemon/util.h index 37d50a7..cbc82cc 100644 --- a/daemon/util.h +++ b/daemon/util.h @@ -250,13 +250,13 @@ static __inline void nfstime_diff( } static __inline void nfstime_abs( IN const nfstime4 *nt, - OUT nfstime4 *result) -{ - if (nt->seconds < 0) { - const nfstime4 zero = { 0, 0 }; - nfstime_diff(&zero, nt, result); /* result = 0 - nt */ - } else if (result != nt) - memcpy(result, nt, sizeof(nfstime4)); + OUT nfstime4 *result) +{ + if (nt->seconds < 0) { + const nfstime4 zero = { .seconds=0LL, .nseconds=0UL }; + nfstime_diff(&zero, nt, result); /* result = 0 - nt */ + } else if (result != nt) + memcpy(result, nt, sizeof(nfstime4)); }