misc: Fix a small pile of warnings found with diagnostics turned way up

* possible null pointer dereferences
 * non-annotated fallthroughs in case statements

Change-Id: I2332e0e0a4203ceca0999291ead112b8ab94c613
This commit is contained in:
Solomon Peachy 2025-09-06 21:31:58 -04:00
parent d51d49550c
commit 34f34bb7f1
9 changed files with 46 additions and 43 deletions

View file

@ -1735,6 +1735,7 @@ static void typingProcess(void){
clearOperand(); clearOperand();
calStatus = cal_typing; calStatus = cal_typing;
/* go on typing, no break */ /* go on typing, no break */
/* Intentional fallthrough */
case cal_typing: case cal_typing:
case cal_dotted: case cal_dotted:
switch(CAL_BUTTON){ switch(CAL_BUTTON){

View file

@ -1304,7 +1304,7 @@ read_comment_sgf (char *buffer, size_t buffer_size)
{ {
break; break;
} }
/* Intentional fallthrough */
default: default:
*buffer = temp; *buffer = temp;
++buffer; ++buffer;

View file

@ -152,6 +152,7 @@ free_tree_sgf (void)
{ {
rb->splash (5 * HZ, rb->splash (5 * HZ,
"Error allocating first node! Please exit immediately."); "Error allocating first node! Please exit immediately.");
return;
} }
get_node (tree_head)->props = NO_PROP; get_node (tree_head)->props = NO_PROP;
@ -498,4 +499,3 @@ get_prop (int handle)
} }
return &(storage_buffer[index][handle].prop); return &(storage_buffer[index][handle].prop);
} }

View file

@ -406,6 +406,7 @@ static int ask_and_get_audio_buffer(const char *filename)
break; break;
#endif #endif
#endif #endif
/* Intentional fallthrough */
case IMGVIEW_MENU: case IMGVIEW_MENU:
return PLUGIN_OK; return PLUGIN_OK;

View file

@ -809,8 +809,7 @@ static int scrobbler_context_menu(struct printcell_data_t *pc_data)
if (find_type == FIND_ALL) if (find_type == FIND_ALL)
find_type = FIND_INCLUDE; find_type = FIND_INCLUDE;
/* fallthrough */ } /* fall-through */
}
case 3: /*Custom Filter / Settings */ case 3: /*Custom Filter / Settings */
{ {
if (col == -1)/*Settings*/ if (col == -1)/*Settings*/

View file

@ -12,7 +12,7 @@
*/ */
/* hacked to run subpatches with different samplerates /* hacked to run subpatches with different samplerates
* only samplerates that are a power_of_2-multiple of the * only samplerates that are a power_of_2-multiple of the
* *
* mfg.gfd.uil * mfg.gfd.uil
* IOhannes * IOhannes
@ -53,7 +53,7 @@ t_int *zero_perform(t_int *w) /* zero out a vector */
{ {
t_float *out = (t_float *)(w[1]); t_float *out = (t_float *)(w[1]);
int n = (int)(w[2]); int n = (int)(w[2]);
while (n--) *out++ = 0; while (n--) *out++ = 0;
return (w+3); return (w+3);
} }
@ -61,7 +61,7 @@ t_int *zero_perf8(t_int *w)
{ {
t_float *out = (t_float *)(w[1]); t_float *out = (t_float *)(w[1]);
int n = (int)(w[2]); int n = (int)(w[2]);
for (; n; n -= 8, out += 8) for (; n; n -= 8, out += 8)
{ {
out[0] = 0; out[0] = 0;
@ -80,7 +80,7 @@ void dsp_add_zero(t_sample *out, int n)
{ {
if (n&7) if (n&7)
dsp_add(zero_perform, 2, out, n); dsp_add(zero_perform, 2, out, n);
else else
dsp_add(zero_perf8, 2, out, n); dsp_add(zero_perf8, 2, out, n);
} }
@ -296,7 +296,7 @@ void dsp_add(t_perfroutine f, int n, ...)
void dsp_addv(t_perfroutine f, int n, t_int *vec) void dsp_addv(t_perfroutine f, int n, t_int *vec)
{ {
int newsize = dsp_chainsize + n+1, i; int newsize = dsp_chainsize + n+1, i;
dsp_chain = t_resizebytes(dsp_chain, dsp_chainsize * sizeof (t_int), dsp_chain = t_resizebytes(dsp_chain, dsp_chainsize * sizeof (t_int),
newsize * sizeof (t_int)); newsize * sizeof (t_int));
dsp_chain[dsp_chainsize-1] = (t_int)f; dsp_chain[dsp_chainsize-1] = (t_int)f;
@ -530,7 +530,7 @@ struct _dspcontext
char dc_toplevel; /* true if "iosigs" is invalid. */ char dc_toplevel; /* true if "iosigs" is invalid. */
char dc_reblock; /* true if we have to reblock inlets/outlets */ char dc_reblock; /* true if we have to reblock inlets/outlets */
char dc_switched; /* true if we're switched */ char dc_switched; /* true if we're switched */
}; };
#define t_dspcontext struct _dspcontext #define t_dspcontext struct _dspcontext
@ -550,7 +550,7 @@ void ugen_stop(void)
dsp_chain = 0; dsp_chain = 0;
} }
signal_cleanup(); signal_cleanup();
} }
void ugen_start(void) void ugen_start(void)
@ -590,7 +590,7 @@ void glob_foo(void *dummy, t_symbol *s, int argc, t_atom *argv)
; ;
post("free borrowed %d", count); post("free borrowed %d", count);
ugen_loud = argc; ugen_loud = argc;
} }
#endif #endif
@ -623,7 +623,7 @@ void ugen_add(t_dspcontext *dc, t_object *obj)
int i; int i;
t_sigoutlet *uout; t_sigoutlet *uout;
t_siginlet *uin; t_siginlet *uin;
x->u_next = dc->dc_ugenlist; x->u_next = dc->dc_ugenlist;
dc->dc_ugenlist = x; dc->dc_ugenlist = x;
x->u_obj = obj; x->u_obj = obj;
@ -655,7 +655,7 @@ void ugen_connect(t_dspcontext *dc, t_object *x1, int outno, t_object *x2,
for (u2 = dc->dc_ugenlist; u2 && u2->u_obj != x2; u2 = u2->u_next); for (u2 = dc->dc_ugenlist; u2 && u2->u_obj != x2; u2 = u2->u_next);
if (!u1 || !u2 || siginno < 0) if (!u1 || !u2 || siginno < 0)
{ {
pd_error(u1->u_obj, pd_error((u1 ? u1->u_obj : NULL),
"signal outlet connect to nonsignal inlet (ignored)"); "signal outlet connect to nonsignal inlet (ignored)");
return; return;
} }
@ -708,17 +708,17 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
is set. We don't yet know if a subcanvas will be "blocking" so there is set. We don't yet know if a subcanvas will be "blocking" so there
we delay new signal creation, which will be handled by calling we delay new signal creation, which will be handled by calling
signal_setborrowed in the ugen_done_graph routine below. */ signal_setborrowed in the ugen_done_graph routine below. */
int nonewsigs = (class == canvas_class || int nonewsigs = (class == canvas_class ||
((class == vinlet_class) && !(dc->dc_reblock))); ((class == vinlet_class) && !(dc->dc_reblock)));
/* when we encounter a subcanvas or a signal outlet, suppress freeing /* when we encounter a subcanvas or a signal outlet, suppress freeing
the input signals as they may be "borrowed" for the super or sub the input signals as they may be "borrowed" for the super or sub
patch; same exception as above, but also if we're "switched" we patch; same exception as above, but also if we're "switched" we
have to do a copy rather than a borrow. */ have to do a copy rather than a borrow. */
int nofreesigs = (class == canvas_class || int nofreesigs = (class == canvas_class ||
((class == voutlet_class) && !(dc->dc_reblock || dc->dc_switched))); ((class == voutlet_class) && !(dc->dc_reblock || dc->dc_switched)));
t_signal **insig, **outsig, **sig, *s1, *s2, *s3; t_signal **insig, **outsig, **sig, *s1, *s2, *s3;
t_ugenbox *u2; t_ugenbox *u2;
if (ugen_loud) post("doit %s %d %d", class_getname(class), nofreesigs, if (ugen_loud) post("doit %s %d %d", class_getname(class), nofreesigs,
nonewsigs); nonewsigs);
for (i = 0, uin = u->u_in; i < u->u_nin; i++, uin++) for (i = 0, uin = u->u_in; i < u->u_nin; i++, uin++)
@ -776,7 +776,7 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
routine must fill in "borrowed" signal outputs in case it's either routine must fill in "borrowed" signal outputs in case it's either
a subcanvas or a signal inlet. */ a subcanvas or a signal inlet. */
mess1(&u->u_obj->ob_pd, gensym("dsp"), insig); mess1(&u->u_obj->ob_pd, gensym("dsp"), insig);
/* if any output signals aren't connected to anyone, free them /* if any output signals aren't connected to anyone, free them
now; otherwise they'll either get freed when the reference count now; otherwise they'll either get freed when the reference count
goes back to zero, or even later as explained above. */ goes back to zero, or even later as explained above. */
@ -788,14 +788,14 @@ static void ugen_doit(t_dspcontext *dc, t_ugenbox *u)
} }
if (ugen_loud) if (ugen_loud)
{ {
if (u->u_nin + u->u_nout == 0) post("put %s %d", if (u->u_nin + u->u_nout == 0) post("put %s %d",
class_getname(u->u_obj->ob_pd), ugen_index(dc, u)); class_getname(u->u_obj->ob_pd), ugen_index(dc, u));
else if (u->u_nin + u->u_nout == 1) post("put %s %d (%x)", else if (u->u_nin + u->u_nout == 1) post("put %s %d (%x)",
class_getname(u->u_obj->ob_pd), ugen_index(dc, u), sig[0]); class_getname(u->u_obj->ob_pd), ugen_index(dc, u), sig[0]);
else if (u->u_nin + u->u_nout == 2) post("put %s %d (%x %x)", else if (u->u_nin + u->u_nout == 2) post("put %s %d (%x %x)",
class_getname(u->u_obj->ob_pd), ugen_index(dc, u), class_getname(u->u_obj->ob_pd), ugen_index(dc, u),
sig[0], sig[1]); sig[0], sig[1]);
else post("put %s %d (%x %x %x ...)", else post("put %s %d (%x %x %x ...)",
class_getname(u->u_obj->ob_pd), ugen_index(dc, u), class_getname(u->u_obj->ob_pd), ugen_index(dc, u),
sig[0], sig[1], sig[2]); sig[0], sig[1], sig[2]);
} }
@ -874,7 +874,7 @@ void ugen_done_graph(t_dspcontext *dc)
int reblock = 0, switched; int reblock = 0, switched;
int downsample = 1, upsample = 1; /* IOhannes */ int downsample = 1, upsample = 1; /* IOhannes */
/* debugging printout */ /* debugging printout */
if (ugen_loud) if (ugen_loud)
{ {
post("ugen_done_graph..."); post("ugen_done_graph...");
@ -890,7 +890,7 @@ void ugen_done_graph(t_dspcontext *dc)
} }
} }
} }
/* search for an object of class "block~" */ /* search for an object of class "block~" */
for (u = dc->dc_ugenlist, blk = 0; u; u = u->u_next) for (u = dc->dc_ugenlist, blk = 0; u; u = u->u_next)
{ {
@ -940,7 +940,7 @@ void ugen_done_graph(t_dspcontext *dc)
blk->x_period = period; blk->x_period = period;
blk->x_phase = dsp_phase & (period - 1); blk->x_phase = dsp_phase & (period - 1);
if (! parent_context || (realoverlap != 1) || if (! parent_context || (realoverlap != 1) ||
(vecsize != parent_vecsize) || (vecsize != parent_vecsize) ||
(downsample != 1) || (upsample != 1)) /* IOhannes */ (downsample != 1) || (upsample != 1)) /* IOhannes */
reblock = 1; reblock = 1;
switched = blk->x_switched; switched = blk->x_switched;
@ -959,7 +959,7 @@ void ugen_done_graph(t_dspcontext *dc)
dc->dc_switched = switched; dc->dc_switched = switched;
dc->dc_srate = srate; dc->dc_srate = srate;
dc->dc_vecsize = vecsize; dc->dc_vecsize = vecsize;
/* if we're reblocking or switched, we now have to create output /* if we're reblocking or switched, we now have to create output
signals to fill in for the "borrowed" ones we have now. This signals to fill in for the "borrowed" ones we have now. This
is also possibly true even if we're not blocked/switched, in is also possibly true even if we're not blocked/switched, in
@ -994,7 +994,7 @@ void ugen_done_graph(t_dspcontext *dc)
pointers to their corresponding inlets/outlets on the box we're inside, pointers to their corresponding inlets/outlets on the box we're inside,
if any. Outlets will also need pointers, unless we're switched, in if any. Outlets will also need pointers, unless we're switched, in
which case outlet epilog code will kick in. */ which case outlet epilog code will kick in. */
for (u = dc->dc_ugenlist; u; u = u->u_next) for (u = dc->dc_ugenlist; u; u = u->u_next)
{ {
t_pd *zz = &u->u_obj->ob_pd; t_pd *zz = &u->u_obj->ob_pd;
@ -1006,16 +1006,16 @@ void ugen_done_graph(t_dspcontext *dc)
if (outsigs) outsigs += dc->dc_ninlets; if (outsigs) outsigs += dc->dc_ninlets;
if (pd_class(zz) == vinlet_class) if (pd_class(zz) == vinlet_class)
vinlet_dspprolog((struct _vinlet *)zz, vinlet_dspprolog((struct _vinlet *)zz,
dc->dc_iosigs, vecsize, dsp_phase, period, frequency, dc->dc_iosigs, vecsize, dsp_phase, period, frequency,
downsample, upsample, /* IOhannes */ downsample, upsample, /* IOhannes */
reblock, switched); reblock, switched);
else if (pd_class(zz) == voutlet_class) else if (pd_class(zz) == voutlet_class)
voutlet_dspprolog((struct _voutlet *)zz, voutlet_dspprolog((struct _voutlet *)zz,
outsigs, vecsize, dsp_phase, period, frequency, outsigs, vecsize, dsp_phase, period, frequency,
downsample, upsample, /* IOhannes */ downsample, upsample, /* IOhannes */
reblock, switched); reblock, switched);
} }
chainblockbegin = dsp_chainsize; chainblockbegin = dsp_chainsize;
if (blk && (reblock || switched)) /* add the block DSP prolog */ if (blk && (reblock || switched)) /* add the block DSP prolog */
@ -1030,7 +1030,7 @@ void ugen_done_graph(t_dspcontext *dc)
for (uin = u->u_in, i = u->u_nin; i--; uin++) for (uin = u->u_in, i = u->u_nin; i--; uin++)
uin->i_ngot = 0, uin->i_signal = 0; uin->i_ngot = 0, uin->i_signal = 0;
} }
/* Do the sort */ /* Do the sort */
for (u = dc->dc_ugenlist; u; u = u->u_next) for (u = dc->dc_ugenlist; u; u = u->u_next)
@ -1046,9 +1046,9 @@ void ugen_done_graph(t_dspcontext *dc)
/* check for a DSP loop, which is evidenced here by the presence /* check for a DSP loop, which is evidenced here by the presence
of ugens not yet scheduled. */ of ugens not yet scheduled. */
for (u = dc->dc_ugenlist; u; u = u->u_next) for (u = dc->dc_ugenlist; u; u = u->u_next)
if (!u->u_done) if (!u->u_done)
{ {
t_signal **sigp; t_signal **sigp;
pd_error(u->u_obj, pd_error(u->u_obj,
@ -1085,7 +1085,7 @@ void ugen_done_graph(t_dspcontext *dc)
{ {
t_signal **iosigs = dc->dc_iosigs; t_signal **iosigs = dc->dc_iosigs;
if (iosigs) iosigs += dc->dc_ninlets; if (iosigs) iosigs += dc->dc_ninlets;
voutlet_dspepilog((struct _voutlet *)zz, voutlet_dspepilog((struct _voutlet *)zz,
iosigs, vecsize, dsp_phase, period, frequency, iosigs, vecsize, dsp_phase, period, frequency,
downsample, upsample, /* IOhannes */ downsample, upsample, /* IOhannes */
reblock, switched); reblock, switched);
@ -1154,9 +1154,8 @@ void d_ugen_setup(void) /* really just block_setup */
sizeof(t_block), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0); sizeof(t_block), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0);
class_addcreator((t_newmethod)switch_new, gensym("switch~"), class_addcreator((t_newmethod)switch_new, gensym("switch~"),
A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0); A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT/*IOhannes*/, 0);
class_addmethod(block_class, (t_method)block_set, gensym("set"), class_addmethod(block_class, (t_method)block_set, gensym("set"),
A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0); class_addmethod(block_class, (t_method)block_dsp, gensym("dsp"), 0);
class_addfloat(block_class, block_float); class_addfloat(block_class, block_float);
} }

View file

@ -226,7 +226,7 @@ t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod,
c->c_floatsignalin = 0; c->c_floatsignalin = 0;
c->c_externdir = class_extern_dir; c->c_externdir = class_extern_dir;
c->c_savefn = (typeflag == CLASS_PATCHABLE ? text_save : class_nosavefn); c->c_savefn = (typeflag == CLASS_PATCHABLE ? text_save : class_nosavefn);
#if 0 #if 0
post("class: %s", c->c_name->s_name); post("class: %s", c->c_name->s_name);
#endif #endif
return (c); return (c);
@ -237,7 +237,7 @@ t_class *class_new(t_symbol *s, t_newmethod newmethod, t_method freemethod,
can belong to, but this won't be used until the newmethod is actually can belong to, but this won't be used until the newmethod is actually
called back (and the new method explicitly takes care of this.) */ called back (and the new method explicitly takes care of this.) */
void class_addcreator(t_newmethod newmethod, t_symbol *s, void class_addcreator(t_newmethod newmethod, t_symbol *s,
t_atomtype type1, ...) t_atomtype type1, ...)
{ {
va_list ap; va_list ap;
@ -257,7 +257,7 @@ void class_addcreator(t_newmethod newmethod, t_symbol *s,
vp++; vp++;
count++; count++;
*vp = va_arg(ap, t_atomtype); *vp = va_arg(ap, t_atomtype);
} }
va_end(ap); va_end(ap);
class_addmethod(pd_objectmaker, (t_method)newmethod, s, class_addmethod(pd_objectmaker, (t_method)newmethod, s,
vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]); vec[0], vec[1], vec[2], vec[3], vec[4], vec[5]);
@ -270,7 +270,7 @@ void class_addmethod(t_class *c, t_method fn, t_symbol *sel,
t_methodentry *m; t_methodentry *m;
t_atomtype argtype = arg1; t_atomtype argtype = arg1;
int nargs; int nargs;
va_start(ap, arg1); va_start(ap, arg1);
/* "signal" method specifies that we take audio signals but /* "signal" method specifies that we take audio signals but
that we don't want automatic float to signal conversion. This that we don't want automatic float to signal conversion. This
@ -597,7 +597,7 @@ void mess_init(void)
t_symbol **sp; t_symbol **sp;
int i; int i;
if (pd_objectmaker) return; if (pd_objectmaker) return;
for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++) for (i = sizeof(symlist)/sizeof(*symlist), sp = symlist; i--; sp++)
(void) dogensym((*sp)->s_name, *sp); (void) dogensym((*sp)->s_name, *sp);
pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd), pd_objectmaker = class_new(gensym("objectmaker"), 0, 0, sizeof(t_pd),
@ -713,6 +713,7 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
break; break;
case A_FLOAT: case A_FLOAT:
if (!argc) goto badarg; if (!argc) goto badarg;
/* Intentional fallthrough */
case A_DEFFLOAT: case A_DEFFLOAT:
if (!argc) *dp = 0; if (!argc) *dp = 0;
else else
@ -727,6 +728,7 @@ void pd_typedmess(t_pd *x, t_symbol *s, int argc, t_atom *argv)
break; break;
case A_SYMBOL: case A_SYMBOL:
if (!argc) goto badarg; if (!argc) goto badarg;
/* Intentional fallthrough */
case A_DEFSYM: case A_DEFSYM:
if (!argc) *ap = (t_int)(&s_); if (!argc) *ap = (t_int)(&s_);
else else
@ -804,7 +806,7 @@ void pd_vmess(t_pd *x, t_symbol *sel, char *fmt, ...)
{ {
case 'f': SETFLOAT(at, va_arg(ap, double)); break; case 'f': SETFLOAT(at, va_arg(ap, double)); break;
case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break; case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
case 'i': SETFLOAT(at, va_arg(ap, t_int)); break; case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
case 'p': SETPOINTER(at, va_arg(ap, t_gpointer *)); break; case 'p': SETPOINTER(at, va_arg(ap, t_gpointer *)); break;
default: goto done; default: goto done;
} }
@ -861,4 +863,3 @@ t_gotfn zgetfn(t_pd *x, t_symbol *s)
if (m->me_name == s) return(m->me_fun); if (m->me_name == s) return(m->me_fun);
return(0); return(0);
} }

View file

@ -269,6 +269,7 @@ static byte ioreg_read(byte r)
case RI_HDMA4: case RI_HDMA4:
case RI_HDMA5: case RI_HDMA5:
if (hw.cgb) return REG(r); if (hw.cgb) return REG(r);
/* Intentional fallthrough */
default: default:
return 0xff; return 0xff;
} }

View file

@ -88,6 +88,7 @@ void audio_input_mux(int source, unsigned flags)
{ {
default: /* playback - no recording */ default: /* playback - no recording */
source = AUDIO_SRC_PLAYBACK; source = AUDIO_SRC_PLAYBACK;
/* Intentional fallthrough */
case AUDIO_SRC_PLAYBACK: case AUDIO_SRC_PLAYBACK:
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
if (source != last_source) if (source != last_source)