Fixed lots of warnings and errors (on my system) by backporting a patch I had sent the FreeSCI folks some time ago (but apparently it never made it, or only made it to a branch not imported?)

svn-id: r38245
This commit is contained in:
Max Horn 2009-02-15 14:46:42 +00:00
parent 0082a84b8d
commit 9daed50e01
27 changed files with 59 additions and 149 deletions

View file

@ -647,7 +647,7 @@ script_free_breakpoints(state_t *s)
int
game_init(state_t *s)
{
#ifdef __GNUC__
#ifdef __GNUC__XX
# warning "Fixme: Use new VM instantiation code all over the place"
#endif
reg_t game_obj; /* Address of the game object */
@ -750,7 +750,7 @@ game_exit(state_t *s)
sciprintf("Freeing miscellaneous data...\n");
#ifdef __GNUC__
#ifdef __GNUC__XX
#warning "Free parser segment here"
#endif
if (send_calls_allocated) {
@ -758,7 +758,7 @@ game_exit(state_t *s)
send_calls_allocated = 0;
}
#ifdef __GNUC__
#ifdef __GNUC__XX
#warning "Free scripts here"
#endif

View file

@ -104,59 +104,6 @@ _vfree(parse_rule_t *rule)
rule = NULL;
}
#if 0
// Unreferenced - removed
static parse_rule_t *
_vbuild(int id, int argc, ...)
{
va_list args;
int i;
parse_rule_t *rule = (parse_rule_t*)sci_malloc(sizeof(int) * (argc + 4));
++_allocd_rules;
rule->id = id;
rule->first_special = 0;
rule->specials_nr = 0;
rule->length = argc;
va_start(args, argc);
for (i = 0; i < argc; i++) {
int v;
rule->data[i] = v = va_arg(args, int);
if ((v & TOKEN_TERMINAL)
|| !(v & TOKEN_NON_NT)) {
++rule->specials_nr;
if (!rule->first_special)
rule->first_special = i;
}
}
va_end(args);
return rule;
}
#endif
#if 0
// Unreferenced - removed
static parse_rule_t *
_vcat(int id, parse_rule_t *a, parse_rule_t *b)
{
parse_rule_t *rule = (parse_rule_t*)sci_malloc(sizeof(int) * (a->length + b->length + 4));
rule->id = id;
rule->length = a->length + b->length;
rule->specials_nr = a->specials_nr + b->specials_nr;
rule->first_special = a->first_special;
++_allocd_rules;
memcpy(rule->data, a->data, sizeof(int) * a->length);
memcpy(&(rule->data[a->length]), b->data, sizeof(int) * b->length);
return rule;
}
#endif
static parse_rule_t *
_vdup(parse_rule_t *a)
{
@ -204,24 +151,6 @@ _vinsert(parse_rule_t *turkey, parse_rule_t *stuffing)
return rule;
}
#if 0
// Unreferenced - removed
static int
_greibach_rule_p(parse_rule_t *rule)
{
int pos = rule->first_special;
while (pos < rule->length
&& (rule->data[pos] & TOKEN_NON_NT)
&& !(rule->data[pos] & TOKEN_TERMINAL))
++pos;
if (pos == rule->length)
return 0;
return (rule->data[pos] & TOKEN_TERMINAL);
}
#endif
static parse_rule_t *
_vbuild_rule(parse_tree_branch_t *branch)
{

View file

@ -29,7 +29,7 @@
#ifndef _SCI_KERNEL_COMPAT_
#define _SCI_KERNEL_COMPAT_
#ifdef __GNUC__
#ifdef __GNUC__XX
#warning "Old kernel compatibility crap"
#endif

View file

@ -577,7 +577,6 @@ kCheckFreeSpace(state_t *s, int funct_nr, int argc, reg_t *argv)
char *path = kernel_dereference_char_pointer(s, argv[0], 0);
char *testpath = (char*)sci_malloc(strlen(path) + 15);
char buf[1024];
int i;
int fd;
int failed = 0;
int pathlen;
@ -616,7 +615,7 @@ kCheckFreeSpace(state_t *s, int funct_nr, int argc, reg_t *argv)
}
memset(buf, 0, sizeof(buf));
for (i = 0; i < 1024; i++) /* Check for 1 MB */
for (int i = 0; i < 1024; i++) /* Check for 1 MB */
if (write(fd, buf, 1024) < 1024)
failed = 1;
@ -711,7 +710,7 @@ _savegame_index_struct_compare(const void *a, const void *b)
}
static void
update_savegame_indices(char *gfname)
update_savegame_indices(const char *gfname)
{
int i;

View file

@ -251,7 +251,7 @@ static enum {
UNINITIALIZED
} handle_movecnt = UNINITIALIZED;
int parse_reg_t(state_t *s, char *str, reg_t *dest); /* In scriptconsole.c */
int parse_reg_t(state_t *s, const char *str, reg_t *dest); /* In scriptconsole.c */
static int
checksum_bytes(byte *data, int size)

View file

@ -350,10 +350,10 @@ clone_is_used(clone_table_t *t, int idx)
}
int
parse_reg_t(state_t *s, char *str, reg_t *dest)
parse_reg_t(state_t *s, const char *str, reg_t *dest)
{ /* Returns 0 on success */
int rel_offsetting = 0;
char *offsetting = NULL;
const char *offsetting = NULL;
/* Non-NULL: Parse end of string for relative offsets */
char *endptr;
@ -415,26 +415,27 @@ parse_reg_t(state_t *s, char *str, reg_t *dest)
} else if (*str == '?') {
int index = -1;
int times_found = 0;
char *str_objname;
char *tmp;
const char *str_objname;
char *str_suffix;
char suffchar = 0; /* Supress spurious -Wall warning */
int i;
/* Parse obj by name */
str_objname = strchr(str, '+');
tmp = strchr(str, '+');
str_suffix = strchr(str, '-');
if (str_objname < str_suffix)
str_suffix = str_objname;
if (tmp < str_suffix)
str_suffix = tmp;
if (str_suffix) {
suffchar = (*str_suffix);
*str_suffix = 0;
}
str_objname = strchr(str, '.');
tmp = strchr(str, '.');
if (str_objname) {
*str_objname = 0;
index = strtol(str_objname+1, &endptr, 16);
if (tmp) {
*tmp = 0;
index = strtol(tmp+1, &endptr, 16);
if (*endptr)
return -1;
}
@ -1053,7 +1054,6 @@ c_list (state_t * s)
else if (!strcmp("words", cmd_params[0].str))
return c_list_words(s);
else if (strcmp ("restypes", cmd_params[0].str) == 0) {
int i;
for (i = 0; i < sci_invalid_resource; i++)
sciprintf ("%s\n", sci_resource_types[i]);
}
@ -1062,7 +1062,6 @@ c_list (state_t * s)
if (res == -1)
sciprintf ("Unknown resource type: '%s'\n", cmd_params[0].str);
else {
int i;
for (i = 0; i < sci_max_resource_nr[s->resmgr->sci_version]; i++)
if (scir_test_resource (s->resmgr, res, i))
sciprintf ("%s.%03d\n", sci_resource_types[res], i);

View file

@ -529,7 +529,6 @@ gfxr_draw_view11(int id, byte *resource, int size)
seeker = resource + header_size;
for (i = 0; i < view->loops_nr; i++)
{
static char *truth[2] = {"not ",""};
int loop_offset = get_uint_16(seeker + V2_LOOP_OFFSET);
int cels = seeker[V2_CELS_NUM];
int mirrored = seeker[V2_IS_MIRROR];

View file

@ -424,13 +424,13 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode);
static inline int
get_uint_16(byte *offset)
get_uint_16(const byte *offset)
{
return ((unsigned int) offset[0] | (((unsigned int) offset[1]) << 8));
}
static inline int
get_int_16(byte *offset)
get_int_16(const byte *offset)
{
return ((int) offset[0] | (((int) offset[1]) << 8));
}

View file

@ -67,7 +67,7 @@ struct _state;
#ifdef SCI_KERNEL_DEBUG
#ifdef __GNUC__
#ifdef __GNUC__XXX
#define SCIkdebug(arguments...) _SCIGNUkdebug(__PRETTY_FUNCTION__, ## arguments)
@ -85,7 +85,7 @@ struct _state;
#ifdef __GNUC__
#ifdef __GNUC__XXX
#define SCIkwarn(arguments...) _SCIGNUkdebug(__PRETTY_FUNCTION__, ## arguments)

View file

@ -32,6 +32,7 @@
#include "sci/include/kdebug.h"
#include "sci/include/uinput.h"
#include "sci/include/event.h"
#include "sci/include/vm.h"
#include "sci/include/console.h" /* sciprintf() */
#ifdef HAVE_FNMATCH_H

View file

@ -134,15 +134,15 @@ do {\
#define ALLOC_MEM(alloc_statement, size, filename, linenum, funcname)\
do {\
if (size < 0)\
if (size == 0)\
{\
PANIC_MEMORY(size, filename, linenum, funcname, "WARNING: allocating zero bytes of memory.")\
}\
else if (!(size > 0))\
{\
PANIC_MEMORY(size, filename, linenum, funcname, "Cannot allocate negative bytes of memory!")\
BREAKPOINT()\
}\
else if (size == 0)\
{\
PANIC_MEMORY(size, filename, linenum, funcname, "WARNING: allocating zero bytes of memory.")\
}\
\
alloc_statement; /* attempt to allocate the memory */\
\

View file

@ -441,7 +441,7 @@ scir_add_appropriate_sources(resource_mgr_t *mgr,
int allow_patches,
char *dir)
{
char *trailing_slash = "";
const char *trailing_slash = "";
//char path_separator;
sci_dir_t dirent;
char *name;

View file

@ -63,18 +63,10 @@ void usleep (long usec);
} while (0);
#endif
#if !defined(HAVE_FNMATCH) && !defined(_WIN32)
# include <beos/fnmatch.h>
#endif
#ifdef _DREAMCAST
# include <kos/thread.h>
#endif
#ifdef __BEOS__
# include <be/kernel/OS.h>
#endif
#ifdef HAVE_MEMFROB
void *memfrob(void *s, size_t n);
#endif

View file

@ -863,8 +863,6 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0,
static const song_handle_t midi_send_base = 0xffff0000;
static song_handle_t midi_send_handle = 0xffff0000;
int
sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
int command, int arg1, int arg2)
@ -875,7 +873,7 @@ sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
/* Yes, in that order. SCI channel mutes are actually done via
a counting semaphore. 0 means to decrement the counter, 1
to increment it. */
static char *channel_state[] = {"ON","OFF"};
static const char *channel_state[] = {"ON","OFF"};
if (command == 0xb0 &&
arg1 == SCI_MIDI_CHANNEL_MUTE)

View file

@ -52,6 +52,9 @@ struct _midi_device {
*/
};
// FIXME: This evil hack below is needed to create the
// decorated_midi_writer struct in instrumen-map.c -- in C++, this can
// be replaced by simple subclassing.
#define MIDI_WRITER_BODY \
char *name; /* Name description of the device */ \
\

View file

@ -250,17 +250,6 @@ _mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed)
BREAKPOINT();
}
#if 0
// Unreferenced - removed
static void
mix_unsubscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed)
{
ACQUIRE_LOCK();
_mix_unsubscribe(self, feed);
RELEASE_LOCK();
}
#endif
static void
mix_exit(sfx_pcm_mixer_t *self)
{

View file

@ -159,7 +159,7 @@ rt_timer_callback(void)
}
static resource_t *
find_patch(resource_mgr_t *resmgr, const char *seq, int patchfile)
find_patch(resource_mgr_t *resmgr, const char *seq_name, int patchfile)
{
resource_t *res = NULL;
@ -167,7 +167,7 @@ find_patch(resource_mgr_t *resmgr, const char *seq, int patchfile)
res = scir_find_resource(resmgr, sci_patch, patchfile, 0);
if (!res) {
fprintf(stderr, "[SFX] " __FILE__": patch.%03d requested by sequencer (%s), but not found\n",
patchfile, seq);
patchfile, seq_name);
}
}

View file

@ -219,6 +219,7 @@ sfx_instrument_map_load_sci(byte *data, size_t size)
/* Output with the instrument map */
#define MIDI_CHANNELS_NR 0x10
// FIXME: Replace this ugly hack with simple subclassing once converting to C++
typedef struct decorated_midi_writer {
MIDI_WRITER_BODY
@ -271,7 +272,7 @@ close_decorated(decorated_midi_writer_t *self)
sfx_instrument_map_free(self->map);
self->map = NULL;
self->writer->close(self->writer);
sci_free(self->name);
sci_free((void *)self->name);
self->name = NULL;
sci_free(self);
}
@ -279,7 +280,7 @@ close_decorated(decorated_midi_writer_t *self)
#define BOUND_127(x) (((x) < 0)? 0 : (((x) > 0x7f)? 0x7f : (x)))
static int
bound_hard_127(int i, char *descr)
bound_hard_127(int i, const char *descr)
{
int r = BOUND_127(i);
if (r != i)
@ -325,7 +326,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
assert (len >= 1);
if (op == 0xC0 && chan != MIDI_RHYTHM_CHANNEL) { /* Program change */
int patch = bound_hard_127(buf[1], "program change");
/*int*/ patch = bound_hard_127(buf[1], "program change");
int instrument = map->patch_map[patch].patch;
int bend_range = map->patch_bend_range[patch];

View file

@ -37,7 +37,7 @@
#define DEBUG_MT32_TO_GM
static char
static const char
*GM_Instrument_Names[] = {
/*000*/ "Acoustic Grand Piano",
/*001*/ "Bright Acoustic Piano",
@ -170,7 +170,7 @@ static char
};
/* The GM Percussion map is downwards compatible to the MT32 map, which is used in SCI */
static char
static const char
*GM_Percussion_Names[] = {
/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -232,7 +232,7 @@ static char
static struct {
char *name;
const char *name;
gint8 gm_instr;
gint8 gm_rhythm_key;
} MT32_PresetTimbreMaps[] = {
@ -367,7 +367,7 @@ static struct {
};
static struct {
char *name;
const char *name;
gint8 gm_instr;
gint8 gm_rhythmkey;
} MT32_RhythmTimbreMaps[] = {
@ -428,7 +428,7 @@ MT32_PresetRhythmKeymap[] = {
??? - I'm clueless?
R - Rhythm... */
static struct {
char *name;
const char *name;
gint8 gm_instr;
gint8 gm_rhythm_key;
} MT32_MemoryTimbreMaps[] = {
@ -562,11 +562,11 @@ static struct {
{"Wind2 MS", SFX_UNMAPPED, SFX_UNMAPPED}, /* ? (CoC) */
{"Woodpecker", 115, SFX_UNMAPPED}, /* ? (CB) */
{"WtrFall MS", SFX_UNMAPPED, SFX_UNMAPPED}, /* ? (CoC, HQ, iceMan) */
{0, 0}
{0, 0, 0}
};
static gint8
lookup_instrument(char *iname)
lookup_instrument(const char *iname)
{
int i = 0;
@ -579,7 +579,7 @@ lookup_instrument(char *iname)
}
static gint8
lookup_rhythm_key(char *iname)
lookup_rhythm_key(const char *iname)
{
int i = 0;

View file

@ -42,11 +42,11 @@ typedef struct sfx_softseq {
const char *version;
int
(*set_option)(struct sfx_softseq *self, char *name, char *value);
(*set_option)(struct sfx_softseq *self, const char *name, const char *value);
/* Sets an option for the sequencer
** Parameters: (sfx_softseq_t *) self: Self reference
** (char *) name: Name of the option to set
** (char *0 value: Value to set the option to
** (const char *) name: Name of the option to set
** (const char *) value: Value to set the option to
** Returns : (int) GFX_OK on success, or GFX_ERROR if not supported
*/
@ -125,9 +125,9 @@ typedef struct sfx_softseq {
sfx_softseq_t *
sfx_find_softseq(char *name);
sfx_find_softseq(const char *name);
/* Finds a given or default software sequencer
** Parameters: (char *) name: Name of the sequencer to look up, or NULL for default
** Parameters: (const char *) name: Name of the sequencer to look up, or NULL for default
** Returns : (sfx_softseq_t *) The requested sequencer, or NULL if not found
*/

View file

@ -48,7 +48,7 @@ extern sfx_softseq_t sfx_softseq_pcspeaker;
static int
SN76496_set_option(sfx_softseq_t *self, char *name, char *value)
SN76496_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -466,7 +466,7 @@ static instrument_t *read_instrument(FILE *file, int *id)
}
static int
ami_set_option(sfx_softseq_t *self, char *name, char *value)
ami_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -229,7 +229,7 @@ fluidsynth_volume(sfx_softseq_t *self, int volume)
}
static int
fluidsynth_set_option(sfx_softseq_t *self, char *name, char *value)
fluidsynth_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -197,7 +197,7 @@ mt32_volume(sfx_softseq_t *self, int volume)
}
static int
mt32_set_option(sfx_softseq_t *self, char *name, char *value)
mt32_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -682,7 +682,7 @@ opl2_volume(sfx_softseq_t *self, int volume)
}
int
opl2_set_option(sfx_softseq_t *self, char *name, char *value)
opl2_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -42,7 +42,7 @@ extern sfx_softseq_t sfx_softseq_pcspeaker;
static int
sps_set_option(sfx_softseq_t *self, char *name, char *value)
sps_set_option(sfx_softseq_t *self, const char *name, const char *value)
{
return SFX_ERROR;
}

View file

@ -54,7 +54,7 @@ static sfx_softseq_t *sw_sequencers[] = {
sfx_softseq_t *
sfx_find_softseq(char *name)
sfx_find_softseq(const char *name)
{
if (!name)
return sw_sequencers[0];