Clean up GCC warnings (2019-08-29 edition)

Updated most parts of the code that were throwing warnings in GCC.
This commit is contained in:
Bill Kendrick 2019-08-30 00:00:18 -07:00
parent 1f2c6c3c4e
commit 7938480174
16 changed files with 110 additions and 141 deletions

View file

@ -4,7 +4,7 @@
For Tux Paint
Language-related functions
Copyright (c) 2002-2014 by Bill Kendrick and others
Copyright (c) 2002-2019 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -25,7 +25,7 @@
$Id$
June 14, 2002 - December 11, 2016
June 14, 2002 - August 29, 2019
*/
#include <stdio.h>
@ -986,7 +986,6 @@ static int set_current_language(const char *restrict locale_choice) MUST_CHECK;
static int set_current_language(const char *restrict loc)
{
int i;
int y_nudge = 0;
char *oldloc;
char *env_language;
@ -1104,7 +1103,6 @@ static int set_current_language(const char *restrict loc)
if (lang_y_nudge[i][0] == langint)
{
wished_langs[j].lang_y_nudge = lang_y_nudge[i][1];
//printf("y_nudge = %d\n", y_nudge);
break;
}
}
@ -1130,18 +1128,6 @@ static int set_current_language(const char *restrict loc)
need_right_to_left = wished_langs[0].need_right_to_left;
need_right_to_left_word = wished_langs[0].need_right_to_left_word;
#if 0
for (i = 0; lang_y_nudge[i][0] != -1; i++)
{
// printf("lang_y_nudge[%d][0] = %d\n", i, lang_y_nudge[i][0]);
if (lang_y_nudge[i][0] == langint)
{
y_nudge = lang_y_nudge[i][1];
//printf("y_nudge = %d\n", y_nudge);
break;
}
}
#endif
#ifdef DEBUG
fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n",
lang_prefix, langint, need_right_to_left ? "(RTL)" : "", need_right_to_left_word ? "(RTL words)" : "");

View file

@ -2,7 +2,7 @@
im.c
Input method handling
Copyright (c)2007 by Mark K. Kim and others
Copyright (c) 2007-2019 by Mark K. Kim and others
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -905,12 +905,12 @@ static int im_event_zh_tw(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm);
/* go onto full reset */
__attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */
__attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0';
@ -1124,12 +1124,12 @@ static int im_event_th(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm);
/* go onto full reset */
__attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */
__attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0';
@ -1343,12 +1343,12 @@ static int im_event_ja(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm);
/* go onto full reset */
__attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */
__attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0';
@ -1590,12 +1590,12 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm);
/* go onto full reset */
__attribute__ ((fallthrough)); /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH];
/* go onto soft reset */
__attribute__ ((fallthrough)); /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0';
@ -1681,7 +1681,7 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
im->redraw--;
ks.unicode = L'\0';
}
/* continue processing: */
__attribute__ ((fallthrough)); /* continue processing: */
/* Actual character processing */
default:

View file

@ -1,7 +1,9 @@
/*
* FIXME
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "macos.h"
#define MACOS_FONTS_PATH "%s/Library/Fonts"
@ -12,7 +14,7 @@
/**
* FIXME
*/
const char *macos_fontsPath()
const char *macos_fontsPath(void)
{
static char *p = NULL;
@ -35,7 +37,7 @@ const char *macos_fontsPath()
/**
* FIXME
*/
const char *macos_preferencesPath()
const char *macos_preferencesPath(void)
{
static char *p = NULL;
@ -58,7 +60,7 @@ const char *macos_preferencesPath()
/**
* FIXME
*/
const char *macos_globalPreferencesPath()
const char *macos_globalPreferencesPath(void)
{
return MACOS_GLOBAL_PREFERENCES_PATH;
}

View file

@ -1,9 +1,9 @@
#ifndef __MACOS_H__
#define __MACOS_H__
const char *macos_fontsPath();
const char *macos_preferencesPath();
const char *macos_globalPreferencesPath();
const char *macos_fontsPath(void);
const char *macos_preferencesPath(void);
const char *macos_globalPreferencesPath(void);
#endif /* __MACOS_H__ */

View file

@ -155,6 +155,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
char *filename;
char *key, *value;
osk_layout *layout;
char * __attribute__((unused)) tmp_ptr;
layout = malloc(sizeof(osk_layout));
layout->name = NULL;
@ -205,7 +206,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
while (!feof(fi))
{
fgets(line, 1023, fi);
tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line))
continue;
@ -277,6 +278,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
char *key, *fontpath;
char *plain_label, *top_label, *altgr_label, *shift_altgr_label;
FILE *fi;
char * __attribute__((unused)) tmp_ptr;
key_number = line_number = 0;
width = height = 0;
@ -342,7 +344,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
allocated = 1;
}
fgets(line, 1023, fi);
tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line))
continue;
@ -466,6 +468,7 @@ void load_keymap(osk_layout * layout, char *keymap_name)
char *ksname1, *ksname2, *ksname3, *ksname4;
char *line;
FILE *fi;
char * __attribute__((unused)) tmp_ptr;
filename = malloc(sizeof(char) * 255);
@ -502,7 +505,7 @@ void load_keymap(osk_layout * layout, char *keymap_name)
while (!feof(fi))
{
fgets(line, 1023, fi);
tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line))
continue;
@ -652,6 +655,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name)
char **pointer;
char *line;
FILE *fi;
char * __attribute__((unused)) tmp_ptr;
pointer = malloc(sizeof(wchar_t *));
filename = malloc(sizeof(char) * 255);
@ -684,7 +688,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name)
while (!feof(fi))
{
fgets(line, 1023, fi);
tmp_ptr = fgets(line, 1023, fi);
if (is_blank_or_comment(line))
continue;
@ -760,6 +764,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name)
char *filename;
char *line;
FILE *fi;
char * __attribute__((unused)) tmp_ptr;
filename = malloc(sizeof(char) * 255);
@ -789,7 +794,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name)
while (!feof(fi))
{
fgets(line, 1023, fi);
tmp_ptr = fgets(line, 1023, fi);
if (strncmp("#define XK_", line, 11) != 0)
continue;

View file

@ -37,6 +37,10 @@ struct cfg
#define NEGBOOL(x) (void*)(offsetof(struct cfginfo,x)|NEG)
#define IMM(x) imm_##x
/* Prototypes of what's in tuxpaint.c: */
void show_version(int details);
void show_usage(int exitcode);
static void imm_version(void)
{
show_version(0);

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - April 3, 2019
June 14, 2002 - August 29, 2019
*/
@ -457,9 +457,7 @@ static void mtw(wchar_t * wtok, char *tok)
#else
#include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h>
/* #include "rsvg.h" */
/* #include "rsvg-cairo.h" */
#if !defined(RSVG_H) || !defined(RSVG_CAIRO_H)
#error "---------------------------------------------------"
#error "If you installed libRSVG from packages, be sure"
@ -2040,17 +2038,19 @@ static char *debug_gettext(const char *str);
static int charsize(Uint16 c);
#endif
static SDL_Surface *load_kpx(char *file);
static SDL_Surface *load_kpx(const char *file);
#ifndef NOSVG
static SDL_Surface *load_svg(char *file);
static SDL_Surface *load_svg(const char *file);
static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h);
#endif
static SDL_Surface *myIMG_Load_RWops(char *file);
static SDL_Surface *myIMG_Load(char *file);
static SDL_Surface *myIMG_Load_RWops(const char *file);
static SDL_Surface *myIMG_Load(const char *file);
static int trash(char *path);
int file_exists(char *path);
int generate_fontconfig_cache_spinner(SDL_Surface * screen);
#define MAX_UTF8_CHAR_LENGTH 6
@ -7731,7 +7731,7 @@ static int generate_fontconfig_cache_real(void)
/**
* FIXME
*/
static int generate_fontconfig_cache(void *vp)
static int generate_fontconfig_cache(__attribute__((unused)) void *vp)
{
return generate_fontconfig_cache_real();
}
@ -9344,13 +9344,6 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
for (x = 0; x < max_x; x++)
{
#ifndef LOW_QUALITY_THUMBNAILS
#ifdef GAMMA_CORRECTED_THUMBNAILS
/* per: http://www.4p8.com/eric.brasseur/gamma.html */
float gamma = 2.2;
float gamma_invert = 1.0 / gamma;
#endif
tr = 0;
tg = 0;
tb = 0;
@ -9365,9 +9358,8 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
SDL_GetRGBA(getpixel(src, src_x, src_y), src->format, &r, &g, &b, &a);
#ifdef GAMMA_CORRECTED_THUMBNAILS
// tr = tr + pow((float)r, gamma);
// tb = tb + pow((float)b, gamma);
// tg = tg + pow((float)g, gamma);
/* per: http://www.4p8.com/eric.brasseur/gamma.html */
tr = tr + sRGB_to_linear_table[r];
tg = tg + sRGB_to_linear_table[g];
tb = tb + sRGB_to_linear_table[b];
@ -9390,9 +9382,6 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep
ta = ta / tmp;
#ifdef GAMMA_CORRECTED_THUMBNAILS
// tr = ceil(pow(tr, gamma_invert));
// tg = ceil(pow(tg, gamma_invert));
// tb = ceil(pow(tb, gamma_invert));
tr = linear_to_sRGB(tr);
tg = linear_to_sRGB(tg);
tb = linear_to_sRGB(tb);
@ -11285,7 +11274,8 @@ static void load_starter_id(char *saved_id, FILE * fil)
char fname[FILENAME_MAX];
FILE *fi;
char color_tag;
int r, g, b, tmp;
int r, g, b, __attribute__((unused))tmp;
char * __attribute__((unused)) tmp_ptr;
rname = NULL;
@ -11343,7 +11333,7 @@ static void load_starter_id(char *saved_id, FILE * fil)
if (!feof(fi) && color_tag == 'T')
{
tmp = fgets(template_id, sizeof(template_id), fi);
tmp_ptr = fgets(template_id, sizeof(template_id), fi);
template_id[strlen(template_id) - 1] = '\0';
tmp = fscanf(fi, "%d", &template_personal);
/* FIXME: Debug only? */
@ -11371,12 +11361,12 @@ static void load_starter_id(char *saved_id, FILE * fil)
/**
* FIXME
*/
static SDL_Surface *load_starter_helper(char *path_and_basename, char *extension, SDL_Surface * (*load_func) (char *))
static SDL_Surface *load_starter_helper(char *path_and_basename, const char *extension, SDL_Surface * (*load_func) (const char *))
{
char *ext;
char fname[256];
SDL_Surface *surf;
int i;
unsigned int i;
ext = strdup(extension);
snprintf(fname, sizeof(fname), "%s.%s", path_and_basename, ext);
@ -11890,7 +11880,7 @@ static int do_prompt_image_flash_snd(const char *const text,
int i;
SDL_Surface *alpha_surf;
#endif
int img1_w, img2_w, img3_w, max_img_w, img_x, img_y, offset;
int img1_w, img2_w, img3_w, max_img_w, img_y, offset;
SDL_Surface *img1b;
int free_img1b;
int txt_left, txt_right, img_left, btn_left, txt_btn_left, txt_btn_right;
@ -12071,7 +12061,6 @@ static int do_prompt_image_flash_snd(const char *const text,
/* Draw the images (if any, and if not animated): */
img_x = img_left;
img_y = 100 + PROMPTOFFSETY + 4;
if (img1b != NULL)
@ -13236,9 +13225,9 @@ static void set_chunk_data(unsigned char **chunk_data, size_t * chunk_data_len,
strcat(headers, "Tuxpaint\n");
strcat(headers, "Tuxpaint_" VER_VERSION "\n");
sprintf(line, "%d%s", uncompressed_size, "\n");
sprintf(line, "%lu%s", uncompressed_size, "\n");
strcat(headers, line);
sprintf(line, "%d%s", dataLen, "\n");
sprintf(line, "%lu%s", dataLen, "\n");
strcat(headers, line);
headersLen = strlen(headers);
@ -17210,7 +17199,7 @@ static void handle_active(SDL_Event * event)
SDL_Flip(screen);
}
}
if (event->active.state & SDL_APPINPUTFOCUS | SDL_APPACTIVE)
if (event->active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE))
{
if (event->active.gain == 1)
{
@ -17477,7 +17466,7 @@ static int paintsound(int size)
/* Old libcairo1, svg and svg-cairo based code
Based on cairo-demo/sdl/main.c from Cairo (GPL'd, (c) 2004 Eric Windisch):
*/
static SDL_Surface *load_svg(char *file)
static SDL_Surface *load_svg(const char *file)
{
svg_cairo_t *scr;
int bpp, btpp, stride;
@ -17636,7 +17625,7 @@ static SDL_Surface *load_svg(char *file)
* FIXME
*/
/* New libcairo2, rsvg and rsvg-cairo based code */
static SDL_Surface *load_svg(char *file)
static SDL_Surface *load_svg(const char *file)
{
cairo_surface_t *cairo_surf;
cairo_t *cr;
@ -17887,7 +17876,7 @@ static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned
*/
/* FIXME: we can remove this after SDL folks fix their bug at http://bugzilla.libsdl.org/show_bug.cgi?id=1485 */
/* Try to load an image with IMG_Load(), if it fails, then try with RWops() */
static SDL_Surface *myIMG_Load_RWops(char *file)
static SDL_Surface *myIMG_Load_RWops(const char *file)
{
SDL_Surface *surf;
FILE *fi;
@ -17921,7 +17910,7 @@ static SDL_Surface *myIMG_Load_RWops(char *file)
if we notice it's an SVG file (if available!);
call load_kpx() if we notice it's a KPX file (JPEG with wrapper);
otherwise call SDL_Image lib's IMG_Load() (for PNGs, JPEGs, BMPs, etc.) */
static SDL_Surface *myIMG_Load(char *file)
static SDL_Surface *myIMG_Load(const char *file)
{
if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".kpx") == 0)
{
@ -17942,7 +17931,7 @@ static SDL_Surface *myIMG_Load(char *file)
/**
* FIXME
*/
static SDL_Surface *load_kpx(char *file)
static SDL_Surface *load_kpx(const char *file)
{
SDL_RWops *data;
FILE *fi;
@ -19819,7 +19808,7 @@ static int do_color_sel(void)
int i, dx, dy;
int done, chose;
int back_left, back_top;
int color_sel_x, color_sel_y;
int color_sel_x = 0, color_sel_y = 0;
SDL_Surface *tmp_btn_up, *tmp_btn_down;
Uint32(*getpixel_tmp_btn_up) (SDL_Surface *, int, int);
@ -21130,7 +21119,7 @@ static void render_all_nodes_starting_at(struct label_node **node)
* FIXME
*/
/* FIXME: This should search for the top-down of the overlaping labels and only re-render from it */
static void derender_node(struct label_node **ref_head)
static void derender_node(__attribute__((unused)) struct label_node **ref_head)
{
SDL_Rect r_tmp_derender;
@ -22890,7 +22879,7 @@ static void setup_config(char *argv[])
{
char *token;
token = strtok(tmpcfg.joystick_buttons_ignore, ",");
token = strtok((char *) tmpcfg.joystick_buttons_ignore, ",");
while (token != NULL)
{
if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254)