gcc 4.2 fixes to avoid use or function pointer casts in OpenSSL.
[openssl.git] / crypto / cryptlib.c
index 6f8b0ff4e5afb13dc307bddacd69e9762bf86ffa..8c686238286c7ecbbe7d5c773240fe932372f3fd 100644 (file)
@@ -125,7 +125,7 @@ DECLARE_STACK_OF(CRYPTO_dynlock)
 IMPLEMENT_STACK_OF(CRYPTO_dynlock)
 
 /* real #defines in crypto.h, keep these upto date */
-static const char* lock_names[CRYPTO_NUM_LOCKS] =
+static const char* const lock_names[CRYPTO_NUM_LOCKS] =
        {
        "<<ERROR>>",
        "err",
@@ -277,7 +277,7 @@ int CRYPTO_get_new_dynlockid(void)
        else
                /* If we found a place with a NULL pointer, put our pointer
                   in it.  */
-               sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
+               (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
 
        if (i == -1)
@@ -319,7 +319,7 @@ void CRYPTO_destroy_dynlockid(int i)
 #endif
                        if (pointer->references <= 0)
                                {
-                               sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
+                               (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
                                }
                        else
                                pointer = NULL;
@@ -545,7 +545,6 @@ const char *CRYPTO_get_lock_name(int type)
 
 unsigned long  OPENSSL_ia32cap_P=0;
 unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; }
-int OPENSSL_NONPIC_relocated=0;
 
 #if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
 #define OPENSSL_CPUID_SETUP
@@ -572,6 +571,7 @@ void OPENSSL_cpuid_setup(void)
 #else
 unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
 #endif
+int OPENSSL_NONPIC_relocated = 0;
 #if !defined(OPENSSL_CPUID_SETUP)
 void OPENSSL_cpuid_setup(void) {}
 #endif
@@ -624,7 +624,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
 #include <tchar.h>
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
-static int IsService(void)
+int OPENSSL_isservice(void)
 { HWINSTA h;
   DWORD len;
   WCHAR *name;
@@ -661,12 +661,15 @@ static int IsService(void)
 #endif
     else                               return 0;
 }
+#else
+int OPENSSL_isservice(void) { return 0; }
 #endif
 
 void OPENSSL_showfatal (const char *fmta,...)
 { va_list ap;
   TCHAR buf[256];
   const TCHAR *fmt;
+#ifdef STD_ERROR_HANDLE        /* what a dirty trick! */
   HANDLE h;
 
     if ((h=GetStdHandle(STD_ERROR_HANDLE)) != NULL &&
@@ -677,9 +680,10 @@ void OPENSSL_showfatal (const char *fmta,...)
        va_end (ap);
        return;
     }
+#endif
 
     if (sizeof(TCHAR)==sizeof(char))
-       fmt=fmta;
+       fmt=(const TCHAR *)fmta;
     else do
     { int    keepgoing;
       size_t len_0=strlen(fmta)+1,i;
@@ -722,7 +726,7 @@ void OPENSSL_showfatal (const char *fmta,...)
 
 #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333
     /* this -------------v--- guards NT-specific calls */
-    if (GetVersion() < 0x80000000 && IsService())
+    if (GetVersion() < 0x80000000 && OPENSSL_isservice())
     {  HANDLE h = RegisterEventSource(0,_T("OPENSSL"));
        const TCHAR *pmsg=buf;
        ReportEvent(h,EVENTLOG_ERROR_TYPE,0,0,0,1,0,&pmsg,0);
@@ -730,21 +734,7 @@ void OPENSSL_showfatal (const char *fmta,...)
     }
     else
 #endif
-    {  MSGBOXPARAMS         m;
-
-       m.cbSize             = sizeof(m);
-       m.hwndOwner          = NULL;
-       m.lpszCaption        = _T("OpenSSL: FATAL");
-       m.dwStyle            = MB_OK;
-       m.hInstance          = NULL;
-       m.lpszIcon           = IDI_ERROR;
-       m.dwContextHelpId    = 0;
-       m.lpfnMsgBoxCallback = NULL;
-       m.dwLanguageId       = MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US);
-       m.lpszText           = buf;
-
-       MessageBoxIndirect (&m);
-    }
+       MessageBox (NULL,buf,_T("OpenSSL: FATAL"),MB_OK|MB_ICONSTOP);
 }
 #else
 void OPENSSL_showfatal (const char *fmta,...)
@@ -754,6 +744,7 @@ void OPENSSL_showfatal (const char *fmta,...)
     vfprintf (stderr,fmta,ap);
     va_end (ap);
 }
+int OPENSSL_isservice (void) { return 0; }
 #endif
 
 void OpenSSLDie(const char *file,int line,const char *assertion)