From 2b5a5fb0719264bdee3091e35f5ed79ce4afe058 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 6 Jul 2011 10:53:39 -0400 Subject: [PATCH] daemon: cleaned up compiler warnings raised warning level to /Wall changed nfs41_file_info.owner, owner_group to char[] to avoid casting Signed-off-by: Casey Bodley --- build.vc10/daemon.vcxproj | 8 ++++---- daemon/acl.c | 24 ++++++++++++------------ daemon/nfs41_daemon.c | 3 +++ daemon/nfs41_types.h | 4 ++-- daemon/nfs41_xdr.c | 16 ++++++++-------- daemon/readdir.c | 2 +- daemon/setattr.c | 1 - 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/build.vc10/daemon.vcxproj b/build.vc10/daemon.vcxproj index c1070ee..68ddf97 100644 --- a/build.vc10/daemon.vcxproj +++ b/build.vc10/daemon.vcxproj @@ -100,7 +100,7 @@ EnableFastChecks MultiThreadedDebugDLL false - Level4 + EnableAllWarnings EditAndContinue CompileAsC @@ -126,7 +126,7 @@ EnableFastChecks MultiThreadedDebugDLL false - Level4 + EnableAllWarnings ProgramDatabase CompileAsC @@ -149,7 +149,7 @@ MultiThreadedDLL true false - Level4 + EnableAllWarnings ProgramDatabase CompileAsC @@ -177,7 +177,7 @@ MultiThreadedDLL true false - Level4 + EnableAllWarnings ProgramDatabase CompileAsC diff --git a/daemon/acl.c b/daemon/acl.c index ba3bfc3..4b7be5e 100644 --- a/daemon/acl.c +++ b/daemon/acl.c @@ -192,7 +192,7 @@ static int convert_nfs4acl_2_dacl(nfsacl41 *acl, int file_type, goto out; } for (i = 0; i < acl->count; i++) { - convert_nfs4name_2_user_domain((LPSTR)acl->aces[i].who, &domain); + convert_nfs4name_2_user_domain(acl->aces[i].who, &domain); dprintf(1, "handle_getacl: for user=%s domain=%s\n", acl->aces[i].who, domain?domain:""); status = check_4_special_identifiers(acl->aces[i].who, &sids[i], @@ -202,7 +202,7 @@ static int convert_nfs4acl_2_dacl(nfsacl41 *acl, int file_type, goto out; } if (!flag) { - status = map_name_2_sid(&sid_len, &sids[i], (LPSTR)acl->aces[i].who); + status = map_name_2_sid(&sid_len, &sids[i], acl->aces[i].who); if (status) { free_sids(sids, i); goto out; @@ -310,11 +310,11 @@ static int handle_getacl(nfs41_upcall *upcall) */ if (args->query & OWNER_SECURITY_INFORMATION) { // parse user@domain. currently ignoring domain part XX - convert_nfs4name_2_user_domain((LPSTR)info.owner, &domain); + convert_nfs4name_2_user_domain(info.owner, &domain); dprintf(1, "handle_getacl: OWNER_SECURITY_INFORMATION: for user=%s " "domain=%s\n", info.owner, domain?domain:""); sid_len = 0; - status = map_name_2_sid(&sid_len, &osid, (LPSTR)info.owner); + status = map_name_2_sid(&sid_len, &osid, info.owner); if (status) goto out; status = SetSecurityDescriptorOwner(&sec_desc, osid, TRUE); @@ -326,11 +326,11 @@ static int handle_getacl(nfs41_upcall *upcall) } } if (args->query & GROUP_SECURITY_INFORMATION) { - convert_nfs4name_2_user_domain((LPSTR)info.owner_group, &domain); + convert_nfs4name_2_user_domain(info.owner_group, &domain); dprintf(1, "handle_getacl: GROUP_SECURITY_INFORMATION: for %s " "domain=%s\n", info.owner_group, domain?domain:""); sid_len = 0; - status = map_name_2_sid(&sid_len, &gsid, (LPSTR)info.owner_group); + status = map_name_2_sid(&sid_len, &gsid, info.owner_group); if (status) goto out; status = SetSecurityDescriptorGroup(&sec_desc, gsid, TRUE); @@ -578,7 +578,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o status = is_well_known_sid(sid, who_out); if (status) { if (!strncmp(who_out, ACE4_NOBODY, strlen(ACE4_NOBODY))) { - size = strlen(ACE4_NOBODY); + size = (DWORD)strlen(ACE4_NOBODY); goto add_domain; } else @@ -708,7 +708,7 @@ static int handle_setacl(nfs41_upcall *upcall) nfs41_open_state *state = upcall->state_ref; nfs41_file_info info; stateid_arg stateid; - nfsacl41 nfs4_acl; + nfsacl41 nfs4_acl = { 0 }; PSID sid = NULL, gsid = NULL; BOOL sid_default, gsid_default; @@ -722,12 +722,12 @@ static int handle_setacl(nfs41_upcall *upcall) eprintf("GetSecurityDescriptorOwner failed with %d\n", status); goto out; } - status = map_nfs4ace_who(sid, NULL, NULL, (char *)info.owner, + status = map_nfs4ace_who(sid, NULL, NULL, info.owner, state->session->client->domain_name); if (status) goto out; else { - info.owner_len = strlen((const char *)info.owner); + info.owner_len = (uint32_t)strlen(info.owner); info.attrmask.arr[1] |= FATTR4_WORD1_OWNER; info.attrmask.count = 2; } @@ -740,12 +740,12 @@ static int handle_setacl(nfs41_upcall *upcall) eprintf("GetSecurityDescriptorOwner failed with %d\n", status); goto out; } - status = map_nfs4ace_who(sid, NULL, NULL, (char *)info.owner_group, + status = map_nfs4ace_who(sid, NULL, NULL, info.owner_group, state->session->client->domain_name); if (status) goto out; else { - info.owner_group_len = strlen((const char *)info.owner_group); + info.owner_group_len = (uint32_t)strlen(info.owner_group); info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP; info.attrmask.count = 2; } diff --git a/daemon/nfs41_daemon.c b/daemon/nfs41_daemon.c index 48d29bd..6f056a0 100644 --- a/daemon/nfs41_daemon.c +++ b/daemon/nfs41_daemon.c @@ -229,7 +229,10 @@ VOID ServiceStart(DWORD argc, LPTSTR *argv) /* available only when built in debug mode under visual studio -cbodley */ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); +#pragma warning (push) +#pragma warning (disable : 4306) /* conversion from 'int' to '_HFILE' of greater size */ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); +#pragma warning (pop) dprintf(1, "debug mode. dumping memory leaks to stderr on exit.\n"); #endif diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h index 6fa8d4d..88c0abf 100644 --- a/daemon/nfs41_types.h +++ b/daemon/nfs41_types.h @@ -219,9 +219,9 @@ typedef struct __nfs41_file_info { bool_t symlink_dir; bool_t symlink_support; bool_t link_support; - unsigned char owner[NFS4_OPAQUE_LIMIT]; + char owner[NFS4_OPAQUE_LIMIT]; uint32_t owner_len; - unsigned char owner_group[NFS4_OPAQUE_LIMIT]; + char owner_group[NFS4_OPAQUE_LIMIT]; uint32_t owner_group_len; uint32_t aclsupport; } nfs41_file_info; diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c index c81945c..5284ea8 100644 --- a/daemon/nfs41_xdr.c +++ b/daemon/nfs41_xdr.c @@ -1766,14 +1766,14 @@ static bool_t decode_file_attrs( return FALSE; } if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER) { - unsigned char *ptr = &info->owner[0]; - if (!xdr_bytes(xdr, &(char *)ptr, &info->owner_len, + char *ptr = &info->owner[0]; + if (!xdr_bytes(xdr, &ptr, &info->owner_len, NFS4_OPAQUE_LIMIT)) return FALSE; } if (attrs->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) { - unsigned char *ptr = &info->owner_group[0]; - if (!xdr_bytes(xdr, &(char *)ptr, &info->owner_group_len, + char *ptr = &info->owner_group[0]; + if (!xdr_bytes(xdr, &ptr, &info->owner_group_len, NFS4_OPAQUE_LIMIT)) return FALSE; } @@ -2562,15 +2562,15 @@ static bool_t encode_file_attrs( attrs->attrmask.arr[1] |= FATTR4_WORD1_TIME_MODIFY_SET; } if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) { - unsigned char *ptr = &info->owner[0]; - if (!xdr_bytes(&localxdr, &(char *)ptr, &info->owner_len, + char *ptr = &info->owner[0]; + if (!xdr_bytes(&localxdr, &ptr, &info->owner_len, NFS4_OPAQUE_LIMIT)) return FALSE; attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER; } if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) { - unsigned char *ptr = &info->owner_group[0]; - if (!xdr_bytes(&localxdr, &(char *)ptr, &info->owner_group_len, + char *ptr = &info->owner_group[0]; + if (!xdr_bytes(&localxdr, &ptr, &info->owner_group_len, NFS4_OPAQUE_LIMIT)) return FALSE; attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP; diff --git a/daemon/readdir.c b/daemon/readdir.c index b3f2cf4..e0d9262 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -140,7 +140,7 @@ static void readdir_copy_dir_info( IN nfs41_readdir_entry *entry, IN PFILE_DIR_INFO_UNION info) { - info->fdi.FileIndex = entry->attr_info.fileid; + info->fdi.FileIndex = (ULONG)entry->attr_info.fileid; nfs_time_to_file_time(&entry->attr_info.time_create, &info->fdi.CreationTime); nfs_time_to_file_time(&entry->attr_info.time_access, diff --git a/daemon/setattr.c b/daemon/setattr.c index 65d633c..ad0c57b 100644 --- a/daemon/setattr.c +++ b/daemon/setattr.c @@ -456,7 +456,6 @@ out: static int handle_setattr(nfs41_upcall *upcall) { setattr_upcall_args *args = &upcall->args.setattr; - nfs41_open_state *state = upcall->state_ref; int status; switch (args->set_class) {