From 7e93af70496ae1fb04481539dc4dca8fd3cab156 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Thu, 28 Jun 2018 09:16:39 +0800 Subject: [PATCH] Compile with -Wpedantic --- Makefile | 2 +- mixer.cpp | 4 ++-- sfxplayer.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 276356b..a8b7d5d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SDL_LIBS = `sdl2-config --libs` -lSDL2_mixer -lGL DEFINES = -DBYPASS_PROTECTION -CXXFLAGS := -g -O -MMD -Wall $(SDL_CFLAGS) $(DEFINES) +CXXFLAGS := -g -O -MMD -Wall -Wpedantic $(SDL_CFLAGS) $(DEFINES) SRCS = aifcplayer.cpp bitmap.cpp file.cpp engine.cpp graphics_gl.cpp graphics_soft.cpp \ script.cpp mixer.cpp pak.cpp resource.cpp resource_mac.cpp resource_nth.cpp \ diff --git a/mixer.cpp b/mixer.cpp index fc5e000..b8bcd2d 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -172,8 +172,8 @@ struct Mixer_impl { static void mixSfxPlayer(void *data, uint8_t *s16buf, int len) { len /= 2; - int8_t s8buf[len]; - memset(s8buf, 0, sizeof(s8buf)); + int8_t *s8buf = (int8_t *)alloca(len); + memset(s8buf, 0, len); ((SfxPlayer *)data)->readSamples(s8buf, len / 2); for (int i = 0; i < len; ++i) { *(int16_t *)&s16buf[i * 2] = 256 * (int16_t)s8buf[i]; diff --git a/sfxplayer.cpp b/sfxplayer.cpp index 46571d0..4b74d37 100644 --- a/sfxplayer.cpp +++ b/sfxplayer.cpp @@ -143,7 +143,7 @@ void SfxPlayer::readSamples(int8_t *buf, int len) { if (_delay == 0) { memset(buf, 0, len * 2); } else { - int8_t bufin[len * 2]; + int8_t *bufin = (int8_t *)alloca(len * 2); mixSamples(bufin, len); nr(bufin, len, buf); }