BOOL Sm::IsShilohClustered(LPSTR szInstance) { BidxScopeAutoSNI1( SNIAPI_TAG _T("szInstance: \"%hs\"\n"), szInstance ); char szRegLocation[MAX_PATH+128] = ""; szRegLocation[ sizeof(szRegLocation) -1] = 0; // If its MSSQLSERVER (default instance), append another MSSQLServer to the path if(!_stricmp_l("MSSQLSERVER", szInstance, GetDefaultLocale()) ) { if(FAILED(StringCchPrintf_lA( szRegLocation, CCH_ANSI_STRING(szRegLocation), "SOFTWARE\\Microsoft\\MSSQLServer\\Cluster", GetDefaultLocale()))) { goto ErrorExit; } } // Else, its a named instance else { if(FAILED(StringCchPrintf_lA( szRegLocation, CCH_ANSI_STRING(szRegLocation), "SOFTWARE\\Microsoft\\Microsoft SQL Server\\%s\\Cluster", GetDefaultLocale(), szInstance))) { goto ErrorExit; } } HKEY hKey; LONG lReturn = RegOpenKeyEx( HKEY_LOCAL_MACHINE, // handle to open key szRegLocation, // subkey name 0, // reserved KEY_QUERY_VALUE, // security access mask &hKey ); // handle to open key if( ERROR_SUCCESS != lReturn ) { goto ErrorExit; } RegCloseKey( hKey ); BidTraceU1( SNI_BID_TRACE_ON, RETURN_TAG _T("%d{BOOL}\n"), TRUE); return TRUE; ErrorExit: BidTraceU1( SNI_BID_TRACE_ON, RETURN_TAG _T("%d{BOOL}\n"), FALSE); return FALSE; }
extern "C" int __cdecl _mbsicmp_l( const unsigned char *s1, const unsigned char *s2, _locale_t plocinfo ) { unsigned short c1, c2; _LocaleUpdate _loc_update(plocinfo); int retval; unsigned char szResult[4]; /* validation section */ _VALIDATE_RETURN(s1 != NULL, EINVAL, _NLSCMPERROR); _VALIDATE_RETURN(s2 != NULL, EINVAL, _NLSCMPERROR); if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0) return _stricmp_l((const char *)s1, (const char *)s2, _loc_update.GetLocaleT()); for (;;) { c1 = *s1++; if ( _ismbblead_l(c1, _loc_update.GetLocaleT()) ) { if (*s1 == '\0') c1 = 0; else { retval = __crtLCMapStringA( _loc_update.GetLocaleT(), _loc_update.GetLocaleT()->mbcinfo->mblocalename, LCMAP_UPPERCASE, (LPCSTR)s1 - 1, 2, (LPSTR)szResult, 2, _loc_update.GetLocaleT()->mbcinfo->mbcodepage, TRUE ); if (retval == 1) c1 = szResult[0]; else if (retval == 2) c1 = (szResult[0] << 8) + szResult[1]; else { errno = EINVAL; return _NLSCMPERROR; } s1++; } } else c1 = _mbbtolower_l(c1, _loc_update.GetLocaleT()); c2 = *s2++; if ( _ismbblead_l(c2, _loc_update.GetLocaleT()) ) { if (*s2 == '\0') c2 = 0; else { retval = __crtLCMapStringA( _loc_update.GetLocaleT(), _loc_update.GetLocaleT()->mbcinfo->mblocalename, LCMAP_UPPERCASE, (LPCSTR)s2 - 1, 2, (LPSTR)szResult, 2, _loc_update.GetLocaleT()->mbcinfo->mbcodepage, TRUE ); if (retval == 1) c2 = szResult[0]; else if (retval == 2) c2 = (szResult[0] << 8) + szResult[1]; else { errno = EINVAL; return _NLSCMPERROR; } s2++; } } else c2 = _mbbtolower_l(c2, _loc_update.GetLocaleT()); if (c1 != c2) return( (c1 > c2) ? 1 : -1 ); if (c1 == 0) return(0); } }
int test_implicit_compare_with_functions() { if (memcmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memcmp' is called without explicitly comparing result // CHECK-FIXES: memcmp(A, "a", 1) != 0) if (wmemcmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wmemcmp' is called without explicitly comparing result // CHECK-FIXES: wmemcmp(W, L"a", 1) != 0) if (memicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memicmp' is called without explicitly comparing result // CHECK-FIXES: memicmp(A, "a", 1) != 0) if (_memicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp' is called without explicitly comparing result // CHECK-FIXES: _memicmp(A, "a", 1) != 0) if (_memicmp_l(A, "a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp_l' is called without explicitly comparing result // CHECK-FIXES: _memicmp_l(A, "a", 1, locale) != 0) if (strcmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result // CHECK-FIXES: strcmp(A, "a") != 0) if (strncmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncmp' is called without explicitly comparing result // CHECK-FIXES: strncmp(A, "a", 1) != 0) if (strcasecmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcasecmp' is called without explicitly comparing result // CHECK-FIXES: strcasecmp(A, "a") != 0) if (strncasecmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncasecmp' is called without explicitly comparing result // CHECK-FIXES: strncasecmp(A, "a", 1) != 0) if (stricmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'stricmp' is called without explicitly comparing result // CHECK-FIXES: stricmp(A, "a") != 0) if (strcmpi(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmpi' is called without explicitly comparing result // CHECK-FIXES: strcmpi(A, "a") != 0) if (_stricmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp' is called without explicitly comparing result // CHECK-FIXES: _stricmp(A, "a") != 0) if (strnicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strnicmp' is called without explicitly comparing result // CHECK-FIXES: strnicmp(A, "a", 1) != 0) if (_strnicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp' is called without explicitly comparing result // CHECK-FIXES: _strnicmp(A, "a", 1) != 0) if (_stricmp_l(A, "a", locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp_l' is called without explicitly comparing result // CHECK-FIXES: _stricmp_l(A, "a", locale) != 0) if (_strnicmp_l(A, "a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp_l' is called without explicitly comparing result // CHECK-FIXES: _strnicmp_l(A, "a", 1, locale) != 0) if (wcscmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscmp' is called without explicitly comparing result // CHECK-FIXES: wcscmp(W, L"a") != 0) if (wcsncmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsncmp' is called without explicitly comparing result // CHECK-FIXES: wcsncmp(W, L"a", 1) != 0) if (wcscasecmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscasecmp' is called without explicitly comparing result // CHECK-FIXES: wcscasecmp(W, L"a") != 0) if (wcsicmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsicmp' is called without explicitly comparing result // CHECK-FIXES: wcsicmp(W, L"a") != 0) if (_wcsicmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp' is called without explicitly comparing result // CHECK-FIXES: _wcsicmp(W, L"a") != 0) if (_wcsicmp_l(W, L"a", locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp_l' is called without explicitly comparing result // CHECK-FIXES: _wcsicmp_l(W, L"a", locale) != 0) if (wcsnicmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsnicmp' is called without explicitly comparing result // CHECK-FIXES: wcsnicmp(W, L"a", 1) != 0) if (_wcsnicmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp' is called without explicitly comparing result // CHECK-FIXES: _wcsnicmp(W, L"a", 1) != 0) if (_wcsnicmp_l(W, L"a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp_l' is called without explicitly comparing result // CHECK-FIXES: _wcsnicmp_l(W, L"a", 1, locale) != 0) if (_mbscmp(U, V)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp' is called without explicitly comparing result // CHECK-FIXES: _mbscmp(U, V) != 0) if (_mbsncmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp' is called without explicitly comparing result // CHECK-FIXES: _mbsncmp(U, V, 1) != 0) if (_mbsnbcmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp' is called without explicitly comparing result // CHECK-FIXES: _mbsnbcmp(U, V, 1) != 0) if (_mbsnbicmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp' is called without explicitly comparing result // CHECK-FIXES: _mbsnbicmp(U, V, 1) != 0) if (_mbsicmp(U, V)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp' is called without explicitly comparing result // CHECK-FIXES: _mbsicmp(U, V) != 0) if (_mbsnicmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp' is called without explicitly comparing result // CHECK-FIXES: _mbsnicmp(U, V, 1) != 0) if (_mbscmp_l(U, V, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbscmp_l(U, V, locale) != 0) if (_mbsncmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbsncmp_l(U, V, 1, locale) != 0) if (_mbsicmp_l(U, V, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbsicmp_l(U, V, locale) != 0) if (_mbsnicmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbsnicmp_l(U, V, 1, locale) != 0) if (_mbsnbcmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbsnbcmp_l(U, V, 1, locale) != 0) if (_mbsnbicmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp_l' is called without explicitly comparing result // CHECK-FIXES: _mbsnbicmp_l(U, V, 1, locale) != 0) return 1; }