diff --git a/configure.ac b/configure.ac index 8eac470..b030135 100644 --- a/configure.ac +++ b/configure.ac @@ -259,6 +259,12 @@ XMP_TRY_COMPILE(whether compiler understands -Wall, int main(){}], CFLAGS="${CFLAGS} -Wall") +XMP_TRY_COMPILE(whether compiler understands -Wwrite-strings, + ac_cv_c_flag_w_write_strings, + -Wwrite-strings,[ + int main(){}], + CFLAGS="${CFLAGS} -Wwrite-strings") + XMP_TRY_COMPILE(whether compiler understands -Wunused-result, ac_cv_c_flag_w_unused_result, -Wunused-result,[ diff --git a/src/common.h b/src/common.h index 9ee0c07..b3962aa 100644 --- a/src/common.h +++ b/src/common.h @@ -19,8 +19,8 @@ #define MAX_DRV_PARM 20 struct player_mode { - char *name; - char *desc; + const char *name; + const char *desc; int mode; }; @@ -53,8 +53,8 @@ struct options { int show_comment; /* show module comment text */ int player_mode; /* force tracker emulation */ int amiga_mixer; /* enable amiga mixer */ - char *driver_id; /* sound driver ID */ - char *out_file; /* output file name */ + const char *driver_id; /* sound driver ID */ + const char *out_file; /* output file name */ char *ins_path; /* instrument path */ char *driver_parm[MAX_DRV_PARM]; /* driver parameters */ char mute[XMP_MAX_CHANNELS]; @@ -82,7 +82,7 @@ void delay_ms(int msec); /* option */ void get_options(int, char **, struct options *); int read_config(struct options *); -void read_modconf(struct options *, unsigned char *); +void read_modconf(struct options *, const unsigned char *); /* terminal */ int set_tty(void); diff --git a/src/getopt_long.c b/src/getopt_long.c index a64d721..b7978c4 100644 --- a/src/getopt_long.c +++ b/src/getopt_long.c @@ -75,7 +75,7 @@ char *optarg = NULL; /* argument associated with option */ #define BADARG ((*options == ':') ? (int)':' : (int)'?') #define INORDER (int)1 -#define EMSG "" +static char EMSG[] = {0,0,0,0}; /* #define EMSG "" */ static int getopt_internal(int, char * const *, const char *, const struct option *, int *, int); diff --git a/src/main.c b/src/main.c index 22e6738..2a16ae7 100644 --- a/src/main.c +++ b/src/main.c @@ -178,13 +178,13 @@ static void check_pause(xmp_context xc, struct control *ctl, static void get_mixer_type(int t, struct options *opt, char *buf, size_t size) { - char *fmt; + const char *fmt; fmt = opt->format & XMP_FORMAT_MONO ? "mono" : "stereo"; switch (t) { case XMP_MIXER_STANDARD: { - char *itp; + const char *itp; switch (opt->interp) { case XMP_INTERP_NEAREST: itp = "non-interpolated"; @@ -211,9 +211,9 @@ static void get_mixer_type(int t, struct options *opt, char *buf, size_t size) } } -static void load_error(char *name, char *filename, int val) +static void load_error(const char *name, const char *filename, int val) { - char *msg; + const char *msg; val = -val; switch (val) { diff --git a/src/read_config.c b/src/read_config.c index 81d2e87..e34d51c 100644 --- a/src/read_config.c +++ b/src/read_config.c @@ -174,7 +174,7 @@ int read_config(struct options *o) } -static int compare_md5(unsigned char *d, char *digest) +static int compare_md5(const unsigned char *d, const char *digest) { int i; @@ -191,7 +191,7 @@ static int compare_md5(unsigned char *d, char *digest) return 0; } -static void parse_modconf(struct options *o, char *confname, unsigned char *md5) +static void parse_modconf(struct options *o, const char *confname, const unsigned char *md5) { FILE *rc; char *hash, *var, *val, line[256]; @@ -281,7 +281,7 @@ static void parse_modconf(struct options *o, char *confname, unsigned char *md5) } -void read_modconf(struct options *o, unsigned char *md5) +void read_modconf(struct options *o, const unsigned char *md5) { #if defined(__OS2__) || defined(__EMX__) char myrc[PATH_MAX]; diff --git a/src/sound.c b/src/sound.c index ee61262..290a129 100644 --- a/src/sound.c +++ b/src/sound.c @@ -102,7 +102,7 @@ struct sound_driver *select_sound_driver(struct options *options) { struct list_head *head; struct sound_driver *sd; - char *pref = options->driver_id; + const char *pref = options->driver_id; if (pref) { list_for_each(head, &sound_driver_list) { diff --git a/src/sound.h b/src/sound.h index bae3cd6..494d8d2 100644 --- a/src/sound.h +++ b/src/sound.h @@ -8,7 +8,7 @@ struct sound_driver { const char *id; - char *description; + const char *description; const char *const *help; int (*init)(struct options *); void (*deinit)(void); diff --git a/src/sound_file.c b/src/sound_file.c index a4404ec..8ed58c3 100644 --- a/src/sound_file.c +++ b/src/sound_file.c @@ -75,7 +75,7 @@ static void play(void *b, int len) static void deinit(void) { - free(sound_file.description); + free((void *)sound_file.description); } static void flush(void) @@ -107,4 +107,3 @@ struct sound_driver sound_file = { onpause, onresume }; - diff --git a/src/sound_wav.c b/src/sound_wav.c index 7510553..2e44f14 100644 --- a/src/sound_wav.c +++ b/src/sound_wav.c @@ -148,7 +148,7 @@ static void deinit(void) close(fd); } - free(sound_wav.description); + free((void *)sound_wav.description); } static void flush(void) @@ -175,4 +175,3 @@ struct sound_driver sound_wav = { onpause, onresume }; -