From 77e0277af0c00dae78c7a739b2ca70cc19fd041a Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 20 Feb 2018 00:41:22 +0200 Subject: [PATCH] fixed warnings --- GNUmakefile | 3 ++- Makefile.dj | 5 +++-- libs/imago/GNUmakefile | 2 +- libs/imago/Makefile.dj | 2 +- libs/mikmod/GNUmakefile | 3 ++- src/demo.c | 39 ++++++++++++++++++++++++--------------- src/dos/watdpmi.c | 2 ++ src/polytest.c | 3 ++- src/screen.c | 7 +++++++ src/screen.h | 3 +++ src/thunder.c | 8 +++----- 11 files changed, 50 insertions(+), 27 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 830297d..48805fa 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,8 +4,9 @@ dep = $(obj:.o=.d) bin = demo inc = -I/usr/local/include -Isrc -Isrc/sdl -Ilibs/imago/src -Ilibs/mikmod/include +warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function -CFLAGS = -pedantic -Wall -g $(inc) `sdl-config --cflags` +CFLAGS = $(warn) -g $(inc) `sdl-config --cflags` LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm $(bin): $(obj) imago mikmod diff --git a/Makefile.dj b/Makefile.dj index 575308c..2088717 100644 --- a/Makefile.dj +++ b/Makefile.dj @@ -12,12 +12,13 @@ else endif inc = -Isrc -Isrc/dos -Ilibs/imago/src -Ilibs/mikmod/include -opt = -O3 -ffast-math +opt = -O3 -ffast-math -fno-strict-aliasing dbg = -g +warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = -pedantic -Wall -march=pentium $(dbg) $(opt) $(inc) +CFLAGS = $(warn) -march=pentium $(dbg) $(opt) $(inc) LDFLAGS = libs/imago/imago.dja libs/mikmod/dos/libmikmod.a $(bin): $(obj) imago mikmod diff --git a/libs/imago/GNUmakefile b/libs/imago/GNUmakefile index c9154c2..2c73904 100644 --- a/libs/imago/GNUmakefile +++ b/libs/imago/GNUmakefile @@ -5,7 +5,7 @@ src = $(wildcard src/*.c) \ obj = $(src:.c=.o) alib = libimago.a -CFLAGS = -pedantic -Wall -Wno-main -g -Izlib -Ilibpng -Ijpeglib +CFLAGS = -Wno-main -g -Izlib -Ilibpng -Ijpeglib $(alib): $(obj) $(AR) rcs $@ $(obj) diff --git a/libs/imago/Makefile.dj b/libs/imago/Makefile.dj index 1f22386..637c4f3 100644 --- a/libs/imago/Makefile.dj +++ b/libs/imago/Makefile.dj @@ -14,7 +14,7 @@ endif CC = $(TOOLPREFIX)gcc AR = $(TOOLPREFIX)ar -CFLAGS = -pedantic -Wall -Wno-main -march=pentium -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib +CFLAGS = -Wno-main -march=pentium -g -O3 -ffast-math -Izlib -Ilibpng -Ijpeglib $(alib): $(obj) $(AR) rcs $@ $(obj) diff --git a/libs/mikmod/GNUmakefile b/libs/mikmod/GNUmakefile index 9a31d25..a6f162b 100644 --- a/libs/mikmod/GNUmakefile +++ b/libs/mikmod/GNUmakefile @@ -9,7 +9,8 @@ alib = libmikmod.a def = -DHAVE_CONFIG_H -DMIKMOD_BUILD inc = -I. -Iinclude -CFLAGS = -pedantic -Wall -g $(def) $(inc) `pkg-config --cflags sdl` +warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function +CFLAGS = $(warn) -g $(def) $(inc) `pkg-config --cflags sdl` $(alib): $(obj) $(AR) rcs $@ $(obj) diff --git a/src/demo.c b/src/demo.c index 45b889a..072b6ce 100644 --- a/src/demo.c +++ b/src/demo.c @@ -121,11 +121,11 @@ void demo_keyboard(int key, int press) switch(key) { case 27: demo_quit(); - break; + return; case 127: debug_break(); - break; + return; case '`': console_active = !console_active; @@ -135,13 +135,16 @@ void demo_keyboard(int key, int press) } else { putchar('\n'); } - break; + return; case '\b': - if(console_active && wr != rd) { - printf("\b \b"); - fflush(stdout); - wr = (wr + CBUF_SIZE - 1) & CBUF_MASK; + if(console_active) { + if(wr != rd) { + printf("\b \b"); + fflush(stdout); + wr = (wr + CBUF_SIZE - 1) & CBUF_MASK; + } + return; } break; @@ -165,6 +168,7 @@ void demo_keyboard(int key, int press) } } console_active = 0; + return; } break; @@ -175,18 +179,23 @@ void demo_keyboard(int key, int press) change_screen(9); } - if(console_active && key < 256 && isprint(key)) { - putchar(key); - fflush(stdout); - - cbuf[wr] = key; - wr = (wr + 1) & CBUF_MASK; - if(wr == rd) { /* overflow */ - rd = (rd + 1) & CBUF_MASK; + if(console_active) { + if(key < 256 && isprint(key)) { + putchar(key); + fflush(stdout); + + cbuf[wr] = key; + wr = (wr + 1) & CBUF_MASK; + if(wr == rd) { /* overflow */ + rd = (rd + 1) & CBUF_MASK; + } } + return; } break; } + + scr_keypress(key); } } diff --git a/src/dos/watdpmi.c b/src/dos/watdpmi.c index 12dcfde..04d7b94 100644 --- a/src/dos/watdpmi.c +++ b/src/dos/watdpmi.c @@ -54,4 +54,6 @@ void dpmi_munmap(void *addr) int 0x31 } } +#else +int stop_gcc_crying_about_empty_translation_units = 0; #endif /* __WATCOM__ */ diff --git a/src/polytest.c b/src/polytest.c index 2558389..afe2006 100644 --- a/src/polytest.c +++ b/src/polytest.c @@ -23,7 +23,8 @@ static struct screen scr = { init, destroy, start, 0, - draw + draw, + 0 }; static float cam_theta, cam_phi = 25; diff --git a/src/screen.c b/src/screen.c index 5ba6d40..fa70413 100644 --- a/src/screen.c +++ b/src/screen.c @@ -97,6 +97,13 @@ void scr_draw(void) if(cur) cur->draw(); } +void scr_keypress(int key) +{ + if(cur && cur->keypress) { + cur->keypress(key); + } +} + struct screen *scr_lookup(const char *name) { int i; diff --git a/src/screen.h b/src/screen.h index efb43f7..c2e4974 100644 --- a/src/screen.h +++ b/src/screen.h @@ -11,6 +11,8 @@ struct screen { void (*stop)(long trans_time); void (*draw)(void); + + void (*keypress)(int key); }; int scr_init(void); @@ -18,6 +20,7 @@ void scr_shutdown(void); void scr_update(void); void scr_draw(void); +void scr_keypress(int key); struct screen *scr_lookup(const char *name); struct screen *scr_screen(int idx); diff --git a/src/thunder.c b/src/thunder.c index 197d326..d8c3211 100644 --- a/src/thunder.c +++ b/src/thunder.c @@ -33,8 +33,6 @@ static unsigned char *blurBuffer, *blurBuffer2; #define CAMERA_DISTANCE 1.1f -#define PI 3.14159f - /* TODO: Load palette from file */ static unsigned short palette[256]; @@ -200,7 +198,7 @@ void blitEffect() { tl = *src1; tr = (*src1 + *(src1 + 1)) >> 1; bl = (*src1 + *src2) >> 1; - br = tr + ((*src2 + *(src2 + 1)) >> 1) >> 1; + br = (tr + ((*src2 + *(src2 + 1)) >> 1)) >> 1; /* Pack 2 pixels in each 32 bit word */ *dst1 = (palette[tr] << 16) | palette[tl]; @@ -290,9 +288,9 @@ void animateMesh() { by.y = 1.0f; by.z = 0.0f; - bz.x = cos(yRot + PI/2.0f); + bz.x = cos(yRot + M_PI/2.0f); bz.y = 0.0f; - bz.z = sin(yRot + PI/2.0f); + bz.z = sin(yRot + M_PI/2.0f); for (i = 0; i < VERTEX_COUNT; i++) { MyVertex v1, v2; -- 1.7.10.4