fix cppcheck warnings

This commit is contained in:
Sebastian Krzyszkowiak 2018-12-11 00:26:51 +01:00
parent d17a927a82
commit 5fcb55591c
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
3 changed files with 11 additions and 10 deletions

View file

@ -187,13 +187,14 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
game->joystick = al_install_joystick(); game->joystick = al_install_joystick();
} }
int windowMode = ALLEGRO_FULLSCREEN_WINDOW;
#ifdef ALLEGRO_ANDROID #ifdef ALLEGRO_ANDROID
windowMode |= ALLEGRO_FRAMELESS; int windowMode = ALLEGRO_FULLSCREEN_WINDOW | ALLEGRO_FRAMELESS;
#endif #elif defined(__EMSCRIPTEN__)
#ifdef __EMSCRIPTEN__ int windowMode = ALLEGRO_WINDOWED;
windowMode = ALLEGRO_WINDOWED; #else
int windowMode = ALLEGRO_FULLSCREEN_WINDOW;
#endif #endif
if (!game->config.fullscreen) { if (!game->config.fullscreen) {
windowMode = ALLEGRO_WINDOWED; windowMode = ALLEGRO_WINDOWED;
} }
@ -282,9 +283,10 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
} }
int samplerate = strtol(GetConfigOptionDefault(game, "SuperDerpy", "samplerate", "44100"), NULL, 10); int samplerate = strtol(GetConfigOptionDefault(game, "SuperDerpy", "samplerate", "44100"), NULL, 10);
ALLEGRO_AUDIO_DEPTH depth = ALLEGRO_AUDIO_DEPTH_FLOAT32;
#ifdef ALLEGRO_ANDROID #ifdef ALLEGRO_ANDROID
depth = ALLEGRO_AUDIO_DEPTH_INT16; ALLEGRO_AUDIO_DEPTH depth = ALLEGRO_AUDIO_DEPTH_INT16;
#else
ALLEGRO_AUDIO_DEPTH depth = ALLEGRO_AUDIO_DEPTH_FLOAT32;
#endif #endif
game->audio.v = al_create_voice(samplerate, depth, ALLEGRO_CHANNEL_CONF_2); game->audio.v = al_create_voice(samplerate, depth, ALLEGRO_CHANNEL_CONF_2);
if (!game->audio.v) { if (!game->audio.v) {
@ -510,7 +512,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
wchar_t* wargv[game->_priv.argc]; wchar_t* wargv[game->_priv.argc];
for (int i = 0; i < game->_priv.argc; i++) { for (int i = 0; i < game->_priv.argc; i++) {
size_t size = MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, NULL, 0); size_t size = MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, NULL, 0);
wargv[i] = alloca(sizeof(wchar_t) * size); wargv[i] = malloc(sizeof(wchar_t) * size);
MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, wargv[i], size); MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, wargv[i], size);
} }
_wexecv(wargv[0], (const wchar_t* const*)wargv); _wexecv(wargv[0], (const wchar_t* const*)wargv);

View file

@ -40,7 +40,7 @@ static ALLEGRO_USTR* GetShaderSource(struct Game* game, const char* filename) {
ALLEGRO_USTR_INFO info; ALLEGRO_USTR_INFO info;
n = al_fread(fp, buf, sizeof(buf)); n = al_fread(fp, buf, sizeof(buf));
if (n <= 0) { if (n == 0) {
break; break;
} }
al_ustr_append(str, al_ref_buffer(&info, buf, n)); al_ustr_append(str, al_ref_buffer(&info, buf, n));

View file

@ -74,7 +74,6 @@ SYMBOL_EXPORT int DrawWrappedText(ALLEGRO_FONT* font, ALLEGRO_COLOR color, float
pch = strtok_r(stext, " ", &context); // Get the first word. pch = strtok_r(stext, " ", &context); // Get the first word.
do { do {
strncpy(word, "", 255); // Truncate the string, to ensure there's no crazy stuff in there from memory.
snprintf(word, 255, "%s ", pch); snprintf(word, 255, "%s ", pch);
strncat(temp, word, 255); // Append the word to the end of TempLine strncat(temp, word, 255); // Append the word to the end of TempLine
// This code checks for the new line character. // This code checks for the new line character.