From 8036f46e2350f0208ae992aa15140c42277be2b4 Mon Sep 17 00:00:00 2001 From: Timo Korvola Date: Sat, 10 Mar 2018 19:10:22 +0200 Subject: [PATCH] Clean up compiler warnings. --- src/sdl/sf_font3.c | 4 +++- src/sdl/sf_fonts.c | 26 ++++++++++---------------- src/sdl/sf_ftype.c | 5 ++--- src/sdl/sf_osfdlg.c | 4 ++-- src/sdl/sf_sig.c | 3 +-- src/sdl/sf_sound.c | 4 ++-- src/sdl/sf_util.c | 23 ++++------------------- 7 files changed, 24 insertions(+), 45 deletions(-) diff --git a/src/sdl/sf_font3.c b/src/sdl/sf_font3.c index f04312e..2220993 100644 --- a/src/sdl/sf_font3.c +++ b/src/sdl/sf_font3.c @@ -113,7 +113,9 @@ static int mydescent(SFONT *s){ return 2;} static int myminchar(SFONT *s){ return 32;} static int mymaxchar(SFONT *s){ return 126;} static int myhasglyph(SFONT *s, word c, int allowdef) - { if (c >= 32 && c <= 126) return 1; if (allowdef) return 1;} +{ + return (c >= 32 && c <= 126) || allowdef; +} static SF_glyph * mygetglyph(SFONT *s, word c, int allowdef) { byte *src; diff --git a/src/sdl/sf_fonts.c b/src/sdl/sf_fonts.c index 4174ef7..832819d 100644 --- a/src/sdl/sf_fonts.c +++ b/src/sdl/sf_fonts.c @@ -740,9 +740,8 @@ SFONT *sf_VGA_SFONT; void sf_initfonts() { int i, j, size=0; - int w,h,nby,m,nocc; byte *cfont, *bmp; SF_glyph *g; - SF_bdffont *b, *norm, *emph, *bold, *bemp; + SF_bdffont *norm, *emph, *bold, *bemp; SFONT *Norm, *Emph=NULL, *Bold=NULL, *Bemp=NULL; norm = SF_defaultfont; @@ -763,13 +762,11 @@ void sf_initfonts() // emphasize (underline)... cfont = (byte *)emph; for (i = norm->minchar;i <= norm->maxchar;i++){ - m = norm->glyphs[i-norm->minchar]; + int m = norm->glyphs[i-norm->minchar]; if (!m) continue; g = (SF_glyph *)(cfont + m); - w = g->dx; - h = g->h; nby = (g->w+7)/8; bmp = (byte *)(&(g->bitmap[0])); - bmp[h-2] = 0xff; + bmp[g->h - 2] = 0xff; } // make a copy for bold bold = malloc(size); @@ -780,15 +777,13 @@ void sf_initfonts() // boldify... cfont = (byte *)bold; for (i = norm->minchar;i <= norm->maxchar;i++){ - int c; - m = norm->glyphs[i-norm->minchar]; + int h, m = norm->glyphs[i-norm->minchar]; if (!m) continue; g = (SF_glyph *)(cfont + m); - w = g->dx; - h = g->h; nby = (g->w+7)/8; + h = g->h; bmp = (byte *)(&(g->bitmap[0])); for (j=0;j> 1); } } @@ -801,13 +796,11 @@ void sf_initfonts() // emphasize (underline)... cfont = (byte *)bemp; for (i = norm->minchar;i <= norm->maxchar;i++){ - m = norm->glyphs[i-norm->minchar]; + int m = norm->glyphs[i-norm->minchar]; if (!m) continue; g = (SF_glyph *)(cfont + m); - w = g->dx; - h = g->h; nby = (g->w+7)/8; bmp = (byte *)(&(g->bitmap[0])); - bmp[h-2] = 0xff; + bmp[g->h - 2] = 0xff; } myfonts[0] = myfonts[4] = Norm; @@ -842,11 +835,12 @@ void sf_initfonts() if (ttfontsdone) ttfontsdone(); // now set the graphics font - if (!myfonts[8]) + if (!myfonts[8]) { if (myfonts[4]->height(myfonts[4]) < 16) myfonts[8] = SF_font3; else myfonts[8] = SF_font3double; + } //for (i=0;i<8;i++){ SFONT *s = myfonts[i]; printf("%d %p %d %d %d %d %d\n", //i,s,s->minchar(s),s->maxchar(s),s->ascent(s),s->descent(s),s->height(s));} diff --git a/src/sdl/sf_ftype.c b/src/sdl/sf_ftype.c index e074bef..46ed61e 100644 --- a/src/sdl/sf_ftype.c +++ b/src/sdl/sf_ftype.c @@ -96,7 +96,7 @@ static SF_glyph *getglyph( SFONT *s, word c, int allowdef) { if (s) { - int i; MYFONT *f = (MYFONT *)s; + MYFONT *f = (MYFONT *)s; if (c < f->minchar || c > f->maxchar) { if (allowdef) c = 0; @@ -164,8 +164,7 @@ static void setglyph( MYFONT *f, FT_Face face, int ch) int mode = FT_RENDER_MODE_MONO; SF_glyph *res; FT_GlyphSlot slot = face->glyph; - int i,j, nbypr, pitch; - unsigned char *s; + int i,j, nbypr; FT_Bitmap *bitmap; if (m_aafonts) mode = FT_RENDER_MODE_NORMAL; diff --git a/src/sdl/sf_osfdlg.c b/src/sdl/sf_osfdlg.c index 7e246d7..24bd009 100644 --- a/src/sdl/sf_osfdlg.c +++ b/src/sdl/sf_osfdlg.c @@ -653,7 +653,7 @@ static unsigned char docbmp[] = { STATIC void drawit( int x, int y, ENTRY *e, int w, int issub) { - int i,j,n,sw,dy,color; + int i, j, n, color; unsigned char *bmp; char *s = e->value; bmp = (issub ? folderbmp : docbmp); @@ -841,7 +841,7 @@ STATIC zword yesnoover( int xc, int yc) // (lib does not guarantee correct behaviour in that case) static void mystrcpy( char *d, const char *s) { - while (*d++ = *s++); + while ((*d++ = *s++)); } STATIC zword Zentry( int x, int y) diff --git a/src/sdl/sf_sig.c b/src/sdl/sf_sig.c index 9a50c50..31cd547 100644 --- a/src/sdl/sf_sig.c +++ b/src/sdl/sf_sig.c @@ -76,7 +76,6 @@ static void bt_sighandler(int sig, siginfo_t *info, void *secret) { void *trace[16]; - char **messages = (char **)NULL; char *nam; int i, trace_size = 0; ucontext_t *uc = (ucontext_t *)secret; @@ -88,7 +87,7 @@ static void bt_sighandler(int sig, siginfo_t *info, printf("\nInterpreter bug!\nSignal %d ", sig); if ((nam = getsigname(sig))) printf("[%s] ",nam); - printf("from %p", uc->uc_mcontext.gregs[_PROG_COUNTER]); + printf("from %p", (void *)uc->uc_mcontext.gregs[_PROG_COUNTER]); if (sig == SIGSEGV) printf(" [faulty address is %p]",info->si_addr); diff --git a/src/sdl/sf_sound.c b/src/sdl/sf_sound.c index ac9c0ed..504c00d 100644 --- a/src/sdl/sf_sound.c +++ b/src/sdl/sf_sound.c @@ -46,7 +46,7 @@ static int audio_rate, audio_channels; // the higher it is, the more FPS shown and CPU needed static int audio_buffers=512; static Uint16 audio_format; -static int volume = SDL_MIX_MAXVOLUME; +//static int volume = SDL_MIX_MAXVOLUME; static int bits; static void finishaudio() @@ -243,7 +243,7 @@ static EFFECT *getmodule( FILE *f, size_t pos, int len, int num) return res; } -static EFFECT *geteffect( num) +static EFFECT *geteffect(int num) { myresource res; EFFECT *result = NULL; diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index 162d3ef..175b703 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -177,11 +177,6 @@ static void usage() static const char *progname = NULL; -extern char script_name[]; -extern char command_name[]; -extern char save_name[]; -extern char auxilary_name[]; - char stripped_story_name[100]; extern char *optarg; @@ -334,14 +329,8 @@ static char *new_basename(const char *path) void os_process_arguments (int argc, char *argv[]) { char *p; - int i; - - // install signal handlers sf_installhandlers(); - - /* Parse command line options */ - parse_options(argc, argv); if (optind != argc - 1) @@ -349,13 +338,9 @@ void os_process_arguments (int argc, char *argv[]) usage(); exit (EXIT_FAILURE); } - - /* Set the story file name */ - f_setup.story_file = strdup(argv[optind]); - // load resources - // it's useless to test the retval, as in case of error it does not return + // it's useless to test the retval, as in case of error it does not return sf_load_resources( f_setup.story_file); /* Strip path and extension off the story file name */ @@ -553,7 +538,6 @@ int os_read_file_name (char *file_name, const char *default_name, int flag) { int st; const char *initname = default_name; - char *ext = ".aux"; if (newfile(flag)) { @@ -790,12 +774,13 @@ static char * findsect( const char *sect) if (strncmp(r,sect,ns)) continue; return (r+ns); } + return NULL; } static char * findid( const char *sect, const char *id) { int nid = strlen(id); - char *p, *r, *sav, *rq, *fnd = NULL; + char *r, *sav, *rq, *fnd = NULL; r = findsect(sect); //printf("findsect(%s) %p\n",sect,r); if (!r) return NULL; @@ -924,7 +909,7 @@ static int myunzip( int csize, byte *cdata, byte *udata) int sf_pkread( FILE *f, int foffs, void ** out, int *size) { - byte hd[30], *dest; + byte hd[30]; byte *data, *cdata; int csize, usize, cmet, skip, st; -- 2.34.1