diff options
author | Werner Koch <[email protected]> | 2015-04-10 08:52:24 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-04-10 08:53:58 +0000 |
commit | eaec10f48803ee2232d1c1515fbe8f485c1e84b0 (patch) | |
tree | 3338689dfec07ceabdd2b36ba3f072765263bff6 /src/init.c | |
parent | Use assert to print diagnosicts before calling abort. (diff) | |
download | libgpg-error-eaec10f48803ee2232d1c1515fbe8f485c1e84b0.tar.gz libgpg-error-eaec10f48803ee2232d1c1515fbe8f485c1e84b0.zip |
w32: Remove compiler warnings.
* src/Makefile.am (pre_mkheader_cmds): Avoid make diagnostic about
failed but ignored command. This confuses Emacs' compiler job parser.
* tests/t-lock.c [W32]: Include time.h.
* src/init.c: Reorganize Windows only code.
(wchar_to_utf8, utf8_to_wchar): Remove unused functions.
(_gpg_err_set_errno): Use only one copy for all platforms.
--
Note that there is a still a problem for W64 pertaining to the use of
an int to store a HANDLE. This will be fixed when we add a full
abstraction layer for Windows file objects.
Diffstat (limited to '')
-rw-r--r-- | src/init.c | 93 |
1 files changed, 13 insertions, 80 deletions
@@ -202,70 +202,22 @@ _gpgrt_free (void *a) } - - -#ifdef HAVE_W32_SYSTEM - -/* Return a malloced string encoded in UTF-8 from the wide char input - string STRING. Caller must free this value. Returns NULL on - failure. Caller may use GetLastError to get the actual error - number. The result of calling this function with STRING set to - NULL is not defined. */ -static char * -wchar_to_utf8 (const wchar_t *string) +void +_gpg_err_set_errno (int err) { - int n; - char *result; - - /* Note, that CP_UTF8 is not defined in Windows versions earlier - than NT. */ - n = WideCharToMultiByte (CP_UTF8, 0, string, -1, NULL, 0, NULL, NULL); - if (n < 0) - return NULL; - - result = malloc (n+1); - if (result) - { - n = WideCharToMultiByte (CP_UTF8, 0, string, -1, result, n, NULL, NULL); - if (n < 0) - { - free (result); - result = NULL; - } - } - return result; +#ifdef HAVE_W32CE_SYSTEM + SetLastError (err); +#else /*!HAVE_W32CE_SYSTEM*/ + errno = err; +#endif /*!HAVE_W32CE_SYSTEM*/ } -/* Return a malloced wide char string from an UTF-8 encoded input - string STRING. Caller must free this value. Returns NULL on - failure. Caller may use GetLastError to get the actual error - number. The result of calling this function with STRING set to - NULL is not defined. */ -static wchar_t * -utf8_to_wchar (const char *string) -{ - int n; - wchar_t *result; - - n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0); - if (n < 0) - return NULL; - - result = malloc ((n+1) * sizeof *result); - if (result) - { - n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n); - if (n < 0) - { - free (result); - result = NULL; - } - return NULL; - } - return result; -} - + +#ifdef HAVE_W32_SYSTEM +/***************************************** + ******** Below is only Windows code. **** + *****************************************/ static char * get_locale_dir (void) @@ -419,17 +371,6 @@ _gpg_w32ce_strerror (int err) #endif /*HAVE_W32CE_SYSTEM*/ -void -_gpg_err_set_errno (int err) -{ -#ifdef HAVE_W32CE_SYSTEM - SetLastError (err); -#else /*!HAVE_W32CE_SYSTEM*/ - errno = err; -#endif /*!HAVE_W32CE_SYSTEM*/ -} - - /* Entry point called by the DLL loader. */ #ifdef DLL_EXPORT int WINAPI @@ -483,12 +424,4 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) } #endif /*DLL_EXPORT*/ -#else /*!HAVE_W32_SYSTEM*/ - -void -_gpg_err_set_errno (int err) -{ - errno = err; -} - -#endif /*!HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM*/ |