Fix build with -Werror=format-security (default in Android NDK r9)

This commit is contained in:
Sergii Rudchenko 2013-07-27 01:17:13 +03:00
parent b06d34e090
commit 3ea77ec933
5 changed files with 6 additions and 9 deletions

View File

@ -74,7 +74,7 @@ SimpleAudioEngine::SimpleAudioEngine()
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL); const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
LOGD(deviceModel); LOGD("%s", deviceModel);
if (strcmp(I9100_MODEL, deviceModel) == 0) if (strcmp(I9100_MODEL, deviceModel) == 0)
{ {

View File

@ -331,7 +331,7 @@ void OpenSLEngine::createEngine(void* pHandle)
const char* errorInfo = dlerror(); const char* errorInfo = dlerror();
if (errorInfo) if (errorInfo)
{ {
LOGD(errorInfo); LOGD("%s", errorInfo);
return; return;
} }

View File

@ -38,7 +38,7 @@ bool SimpleAudioEngineOpenSL::initEngine()
const char* errorInfo = dlerror(); const char* errorInfo = dlerror();
if (errorInfo) if (errorInfo)
{ {
LOGD(errorInfo); LOGD("%s", errorInfo);
bRet = false; bRet = false;
break; break;
} }

View File

@ -34,14 +34,11 @@ NS_CC_BEGIN
void CCLog(const char * pszFormat, ...) void CCLog(const char * pszFormat, ...)
{ {
char buf[MAX_LEN];
va_list args; va_list args;
va_start(args, pszFormat); va_start(args, pszFormat);
vsnprintf(buf, MAX_LEN, pszFormat, args); __android_log_vprint(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat, args);
va_end(args); va_end(args);
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
} }
void CCMessageBox(const char * pszMsg, const char * pszTitle) void CCMessageBox(const char * pszMsg, const char * pszTitle)
@ -51,7 +48,7 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle)
void CCLuaLog(const char * pszFormat) void CCLuaLog(const char * pszFormat)
{ {
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat); __android_log_write(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat);
} }
NS_CC_END NS_CC_END

View File

@ -153,7 +153,7 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch
{ {
std::string msg = "Get data from file("; std::string msg = "Get data from file(";
msg.append(pszFileName).append(") failed!"); msg.append(pszFileName).append(") failed!");
CCLOG(msg.c_str()); CCLOG("%s", msg.c_str());
} }
return pData; return pData;