From 9d5427bbd49a6bf768c956b5d62ffcf280e1a36d Mon Sep 17 00:00:00 2001 From: crusader-mike Date: Wed, 9 Oct 2019 17:08:10 -0500 Subject: [PATCH] fixed few MSVC warnings; fixed missing exports --- CMakeLists.txt | 7 ++++++- include/nfsc/libnfs.h | 2 +- lib/init.c | 2 +- lib/libnfs.c | 2 +- win32/win32_compat.c | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a975e5..d16c639 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,11 @@ set(SYSTEM_LIBRARIES "") # list of core (static) libraries built in current configuration (used by lib/CMakeLists.txt) set(CORE_LIBRARIES "" CACHE INTERNAL "") +# make sure related functions are exported in final dll +if(WIN32 AND BUILD_SHARED_LIBS) + add_definitions(-Dlibnfs_EXPORTS) +endif() + if(CMAKE_SYSTEM_NAME STREQUAL Windows) add_definitions("-D_U_=" -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) list(APPEND SYSTEM_LIBRARIES ws2_32) @@ -58,7 +63,7 @@ add_subdirectory(nlm) add_subdirectory(nsm) add_subdirectory(portmap) add_subdirectory(rquota) -add_subdirectory(lib) +add_subdirectory(lib) # this has to be last (it links all static libs mentioned in CORE_LIBRARIES) if(ENABLE_DOCUMENTATION) add_subdirectory(doc) diff --git a/include/nfsc/libnfs.h b/include/nfsc/libnfs.h index 2bd0c7e..ebca945 100755 --- a/include/nfsc/libnfs.h +++ b/include/nfsc/libnfs.h @@ -52,7 +52,7 @@ struct nfs_url { char *file; }; -#if defined(WIN32) && defined(nfs_EXPORTS) +#if defined(WIN32) && defined(libnfs_EXPORTS) #define EXTERN __declspec( dllexport ) #else #ifndef EXTERN diff --git a/lib/init.c b/lib/init.c index 358d191..e45f6af 100644 --- a/lib/init.c +++ b/lib/init.c @@ -83,7 +83,7 @@ struct rpc_context *rpc_init_context(void) } // Add PID to rpc->xid for easier debugging, making sure to cast // pid to 32-bit type to avoid invalid left-shifts. - rpc->xid = salt + rpc_current_time() + ((uint32_t)getpid() << 16); + rpc->xid = salt + (uint32_t)rpc_current_time() + ((uint32_t)getpid() << 16); salt += 0x01000000; rpc->fd = -1; rpc->tcp_syncnt = RPC_PARAM_UNDEFINED; diff --git a/lib/libnfs.c b/lib/libnfs.c index ac53a40..93c2724 100755 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -889,7 +889,7 @@ int nfs_normalize_path(struct nfs_context *nfs, char *path) { char *str; - int len; + size_t len; /* // -> / */ while ((str = strstr(path, "//"))) { diff --git a/win32/win32_compat.c b/win32/win32_compat.c index bedeeb4..d1066e3 100644 --- a/win32/win32_compat.c +++ b/win32/win32_compat.c @@ -50,7 +50,7 @@ int win32_inet_pton(int af, const char * src, void * dst) struct sockaddr_in sa; int len = sizeof(SOCKADDR); int ret = -1; - int strLen = strlen(src) + 1; + size_t strLen = strlen(src) + 1; #ifdef UNICODE wchar_t *srcNonConst = (wchar_t *)malloc(strLen*sizeof(wchar_t)); memset(srcNonConst, 0, strLen);