Merge pull request #1798 from bmiklautz/fix/misc

Cleanup and fix compiler warnings
This commit is contained in:
Marc-André Moreau 2014-04-17 16:29:45 -04:00
commit 4da5cc9f9a
12 changed files with 60 additions and 27 deletions

View File

@ -94,7 +94,7 @@ void tf_end_paint(rdpContext* context)
return;
}
int tf_receive_channel_data(freerdp* instance, int channelId, BYTE* data, int size, int flags, int total_size)
int tf_receive_channel_data(freerdp* instance, UINT16 channelId, BYTE* data, int size, int flags, int total_size)
{
return freerdp_channels_data(instance, channelId, data, size, flags, total_size);
}

View File

@ -910,7 +910,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
BYTE* pDstData = NULL;
UINT32 compressionFlags = 0;
BYTE pad = 0;
BYTE* pSignature;
BYTE* pSignature = NULL;
fpUpdatePduHeader.action = 0;
fpUpdatePduHeader.secFlags = 0;

View File

@ -988,6 +988,7 @@ int transport_check_fds(rdpTransport* transport)
return status;
Stream_SetPosition(transport->ReceiveBuffer, 0);
length = 0;
if (transport->NlaMode)
{

View File

@ -443,7 +443,7 @@ static void* tf_debug_channel_thread_func(void* arg)
Stream_SetPosition(s, BytesReturned);
printf("got %d bytes\n", BytesReturned);
printf("got %lu bytes\n", BytesReturned);
}
Stream_Free(s, TRUE);

View File

@ -335,6 +335,8 @@ WINPR_API char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName);
WINPR_API char* GetNamedPipeUnixDomainSocketBaseFilePathA(void);
WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName);
WINPR_API int GetNamePipeFileDescriptor(HANDLE hNamedPipe);
#ifdef __cplusplus
}
#endif

View File

@ -280,7 +280,7 @@ extern "C" {
#endif
WINPR_API char* GetKnownPath(int id);
WINPR_API char* GetKnownSubPath(int id, char* path);
WINPR_API char* GetKnownSubPath(int id, const char* path);
WINPR_API char* GetCombinedPath(const char* basePath, const char* subPath);
//#ifndef _WIN32

View File

@ -106,16 +106,6 @@ WINPR_API BOOL GetNamedPipeClientComputerNameW(HANDLE Pipe, LPCWSTR ClientComput
#define GetNamedPipeClientComputerName GetNamedPipeClientComputerNameA
#endif
/**
* Extended API
*/
WINPR_API char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName);
WINPR_API char* GetNamedPipeUnixDomainSocketBaseFilePathA();
WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName);
WINPR_API int GetNamePipeFileDescriptor(HANDLE hNamedPipe);
#ifdef __cplusplus
}
#endif

View File

@ -31,9 +31,15 @@ add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT"
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
MODULE winpr
MODULES winpr-error)
if(MONOLITHIC_BUILD)
else()
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT WinPRTargets)
endif()

View File

@ -24,6 +24,7 @@
#endif
#include <winpr/environment.h>
#include <winpr/error.h>
#ifndef _WIN32
@ -151,7 +152,10 @@ DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
env = getenv(lpName);
if (!env)
{
SetLastError(ERROR_ENVVAR_NOT_FOUND);
return 0;
}
length = strlen(env);
@ -227,19 +231,18 @@ DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize)
BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue)
{
int length;
char* envstr;
if (!lpName)
return FALSE;
if (lpValue)
{
setenv(lpName,lpValue,1);
if (0 != setenv(lpName,lpValue,1))
return FALSE;
}
else
{
unsetenv(lpName);
if (0 != unsetenv(lpName))
return FALSE;
}
return TRUE;

View File

@ -3,28 +3,59 @@
#include <winpr/crt.h>
#include <winpr/tchar.h>
#include <winpr/environment.h>
#include <winpr/error.h>
#define TEST_NAME "WINPR_TEST_VARIABLE"
#define TEST_VALUE "WINPR_TEST_VALUE"
int TestEnvironmentSetEnvironmentVariable(int argc, char* argv[])
{
DWORD nSize;
LPSTR lpBuffer;
DWORD error = 0;
SetEnvironmentVariableA("WINPR_TEST_VARIABLE", "WINPR_TEST_VALUE");
SetEnvironmentVariableA(TEST_NAME, TEST_VALUE);
nSize = GetEnvironmentVariableA("WINPR_TEST_VARIABLE", NULL, 0);
nSize = GetEnvironmentVariableA(TEST_NAME, NULL, 0);
/* check if value returned is len + 1 ) */
if (nSize != strlen(TEST_VALUE) + 1)
{
printf("GetEnvironmentVariableA not found error\n");
return -1;
}
lpBuffer = (LPSTR) malloc(nSize);
nSize = GetEnvironmentVariableA("WINPR_TEST_VARIABLE", lpBuffer, nSize);
nSize = GetEnvironmentVariableA(TEST_NAME, lpBuffer, nSize);
printf("GetEnvironmentVariableA(WINPR_TEST_VARIABLE) = %s\n" , lpBuffer);
if (strcmp(lpBuffer, "WINPR_TEST_VALUE") != 0)
if (nSize != strlen(TEST_VALUE))
{
printf("GetEnvironmentVariableA wrong size returned\n");
return -1;
}
if (strcmp(lpBuffer, TEST_VALUE) != 0)
{
printf("GetEnvironmentVariableA returned value doesn't match\n");
return -1;
}
nSize = GetEnvironmentVariableA("__xx__notset_",lpBuffer, nSize);
error = GetLastError();
if (0 != nSize || ERROR_ENVVAR_NOT_FOUND != error)
{
printf("GetEnvironmentVariableA not found error\n");
return -1;
}
free(lpBuffer);
/* clear variable */
SetEnvironmentVariableA(TEST_NAME, NULL);
nSize = GetEnvironmentVariableA(TEST_VALUE, NULL, 0);
if ( 0 != nSize)
{
printf("SetEnvironmentVariableA failed to clear variable\n");
return -1;
}
return 0;
}

View File

@ -258,7 +258,7 @@ char* GetKnownPath(int id)
return path;
}
char* GetKnownSubPath(int id, char* path)
char* GetKnownSubPath(int id, const char* path)
{
char* subPath;
char* knownPath;

View File

@ -308,7 +308,7 @@ BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName, DWORD nTimeOut)
BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
{
int fd;
unsigned long flags;
int flags;
WINPR_NAMED_PIPE* pNamedPipe;
pNamedPipe = (WINPR_NAMED_PIPE*) hNamedPipe;