Commit c8418a58 authored by Jonathan Wilkes's avatar Jonathan Wilkes

Merge branch 'fix-warnings-in-core2'

parents 73fb5622 59724dc1
......@@ -398,7 +398,7 @@ void mayer_ifft(int n, REAL *real, REAL *imag)
void mayer_realfft(int n, REAL *real)
{
REAL a,b,c,d;
REAL a,b;
int i,j,k;
mayer_fht(real,n);
for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
......@@ -411,7 +411,7 @@ void mayer_realfft(int n, REAL *real)
void mayer_realifft(int n, REAL *real)
{
REAL a,b,c,d;
REAL a,b;
int i,j,k;
for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
a = real[i];
......
......@@ -48,7 +48,7 @@ typedef struct _scalehandle
t_symbol *h_bindsym;
int h_scale;
char h_pathname[37]; // max size for ".x%llx.h%llx" = 5+4*sizeof(long)
char h_outlinetag[18]; // max size for "h%llx" = 2+2*sizeof(long)
char h_outlinetag[25]; // "h%zux", (t_uint)h
int h_dragon; // bool
int h_dragx;
int h_dragy;
......
......@@ -132,7 +132,7 @@ static void bng__motionhook(t_scalehandle *sh,
{
if (mouse_y > y2)
d = mouse_y - y2;
else if (abs(mouse_y - y2) < abs(mouse_x - x2))
else if (abs((int)(mouse_y - y2)) < abs((int)(mouse_x - x2)))
d = mouse_y - y2;
else
d = mouse_x - x2;
......
......@@ -552,6 +552,7 @@ void canvas_writescalar(t_symbol *templatesym, t_word *w, t_binbuf *b,
}
}
/*
static void glist_writelist(t_gobj *y, t_binbuf *b)
{
for (; y; y = y->g_next)
......@@ -563,6 +564,7 @@ static void glist_writelist(t_gobj *y, t_binbuf *b)
}
}
}
*/
/* ------------ routines to write out templates for data ------- */
......@@ -637,6 +639,7 @@ static void canvas_addtemplatesforstruct(t_template *template,
}
}
/*
static void canvas_addtemplatesforlist(t_gobj *y,
int *p_ntemplates, t_symbol ***p_templatevec)
{
......@@ -649,6 +652,7 @@ static void canvas_addtemplatesforlist(t_gobj *y,
}
}
}
*/
/* write all "scalars" in a glist to a binbuf. */
t_binbuf *glist_writetobinbuf(t_glist *x, int wholething)
......
......@@ -2989,8 +2989,10 @@ static void svg_curvedim(t_float p1x, t_float p1y,
t_float a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x);
t_float b = 2 * (c1x - p1x) - 2 * (c2x - c1x),
c = p1x - c1x;
t_float t1 = (a ? ((-b + sqrt(abs(b * b - 4 * a * c))) / 2.0 / a) : 0),
t2 = (a ? ((-b - sqrt(abs(b * b - 4 * a * c))) / 2.0 / a) : 0);
t_float t1 = (a ?
((-b + sqrt(fabs(b * b - 4 * a * c))) / 2.0 / a) : 0);
t_float t2 = (a ?
((-b - sqrt(fabs(b * b - 4 * a * c))) / 2.0 / a) : 0);
t_float xy[12];
xy[0] = p1x; xy[1] = p1y; xy[2] = p2x; xy[3] = p2y;
......@@ -3001,8 +3003,8 @@ static void svg_curvedim(t_float p1x, t_float p1y,
xy[0] = mtx2[0][0]; xy[1] = mtx2[1][0]; xy[2] = mtx2[0][1]; xy[3] = mtx2[1][1];
int xyc = 4;
t_float dotx, doty;
if (abs(t1) > 1e12) t1 = 0.5;
if (abs(t2) > 1e12) t2 = 0.5;
if (fabs(t1) > 1e12) t1 = 0.5;
if (fabs(t2) > 1e12) t2 = 0.5;
if (t1 > 0 && t1 < 1)
{
svg_findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1, &dotx, &doty);
......@@ -3028,10 +3030,10 @@ static void svg_curvedim(t_float p1x, t_float p1y,
a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);
b = 2 * (c1y - p1y) - 2 * (c2y - c1y);
c = p1y - c1y;
t1 = (a ? ((-b + sqrt(abs(b * b - 4 * a * c))) / 2.0 / a) : 0);
t2 = (a ? ((-b - sqrt(abs(b * b - 4 * a * c))) / 2.0 / a) : 0);
if (abs(t1) > 1e12) t1 = 0.5;
if (abs(t2) > 1e12) t2 = 0.5;
t1 = (a ? ((-b + sqrt(fabs(b * b - 4 * a * c))) / 2.0 / a) : 0);
t2 = (a ? ((-b - sqrt(fabs(b * b - 4 * a * c))) / 2.0 / a) : 0);
if (fabs(t1) > 1e12) t1 = 0.5;
if (fabs(t2) > 1e12) t2 = 0.5;
if (t1 > 0 && t1 < 1)
{
svg_findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1, &dotx, &doty);
......@@ -3364,7 +3366,7 @@ static void svg_getpathrect(t_svg *x, t_glist *glist,
}
else
{
yy = *(ia+j) = fielddesc_getcoord(fd+j, template, data, 1) + (rel? yy : 0);
yy = *(ia+j) = fielddesc_getcoord(fd+j, template, data, 1) + (rel? yy : 0);
}
}
break;
......@@ -3390,6 +3392,12 @@ static void svg_getpathrect(t_svg *x, t_glist *glist,
mx = *(ia);
my = *(ia+1);
}
if (x->x_nargs_per_cmd[i] > 1)
{
xx = *(ia+(x->x_nargs_per_cmd[i] - 2));
yy = *(ia+(x->x_nargs_per_cmd[i] - 1));
}
break;
default:
if (x->x_nargs_per_cmd[i] > 1)
{
......@@ -7189,7 +7197,6 @@ static void drawsymbol_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
{
t_drawsymbol *x = (t_drawsymbol *)z;
t_atom at;
int xloc, yloc, font, fontwidth, fontheight, width, height;
char buf[DRAWSYMBOL_BUFSIZE], *startline, *newline;
......@@ -7269,7 +7276,6 @@ static void drawsymbol_vis(t_gobj *z, t_glist *glist, t_glist *parentglist,
// return;
if (vis)
{
t_atom at;
int in_array = (sc->sc_vec == data) ? 0 : 1;
// Ico: why are we using scale here? For group transforms? I thought
// that drawsymbol was not eligible for group transforms since it is
......
......@@ -114,7 +114,7 @@ static void toggle__motionhook(t_scalehandle *sh, t_floatarg mouse_x, t_floatarg
{
if (mouse_y > y2)
d = mouse_y - y2;
else if (abs(mouse_y - y2) < abs(mouse_x - x2))
else if (abs((int)(mouse_y - y2)) < abs((int)(mouse_x - x2)))
d = mouse_y - y2;
else
d = mouse_x - x2;
......
......@@ -691,15 +691,13 @@ t_symbol *binbuf_realizedollsym(t_symbol *s, int ac, t_atom *av, int tonew)
t_pd *pd_mess_from_responder(t_pd *x);
static void binbuf_error(t_pd *x, const char *fmt, ...)
{
char buf[MAXPDSTRING];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, MAXPDSTRING-1, fmt, ap);
va_end(ap);
if (x)
pd_error(pd_mess_from_responder(x), buf);
pd_error(pd_mess_from_responder(x), fmt, ap);
else
error(buf);
error(fmt, ap);
va_end(ap);
}
void binbuf_eval(t_binbuf *x, t_pd *target, int argc, t_atom *argv)
......
......@@ -117,7 +117,7 @@ static int sys_do_load_lib(t_canvas *canvas, const char *objectname,
const char *path)
{
char symname[MAXPDSTRING], filename[MAXPDSTRING], dirbuf[MAXPDSTRING],
*nameptr, altsymname[MAXPDSTRING];
*nameptr;
const char *classname, *cnameptr;
void *dlobj;
t_xxx makeout = NULL;
......@@ -159,7 +159,7 @@ static int sys_do_load_lib(t_canvas *canvas, const char *objectname,
if (hexmunge)
{
memmove(symname+6, symname, strlen(symname)+1);
strncpy(symname, "setup_", 6);
memcpy(symname, "setup_", 6);
}
else strcat(symname, "_setup");
......
......@@ -368,7 +368,11 @@ int sys_main(int argc, char **argv)
if (getuid() != geteuid())
{
fprintf(stderr, "warning: canceling setuid privilege\n");
setuid(getuid());
if (setuid(getuid()) < 0)
{
fprintf(stderr, "error: couldn't cancel setuid privilege");
exit(1);
}
}
#endif /* _WIN32 */
pd_init(); /* start the message system */
......@@ -640,7 +644,7 @@ void sys_findprogdir(char *progname)
/* complicated layout: lib dir is the one we just stat-ed above */
sys_libdir = gensym(sbuf2);
/* gui lives in .../lib/pd-l2ork/bin */
strncpy(sbuf2, sbuf, FILENAME_MAX-30);
strncpy(sbuf2, sbuf, FILENAME_MAX);
sbuf[FILENAME_MAX-30] = 0;
strcat(sbuf2, "/lib/pd-l2ork/bin");
sys_guidir = gensym(sbuf2);
......@@ -649,8 +653,8 @@ void sys_findprogdir(char *progname)
{
/* simple layout: lib dir is the parent */
/* gui lives in .../bin */
strncpy(sbuf2, sbuf, FILENAME_MAX-30);
strncpy(appbuf, sbuf, FILENAME_MAX-30);
strncpy(sbuf2, sbuf, FILENAME_MAX);
strncpy(appbuf, sbuf, FILENAME_MAX);
sbuf[FILENAME_MAX-30] = 0;
sys_libdir = gensym(sbuf);
strcat(sbuf2, "/bin");
......
......@@ -822,7 +822,9 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{
int i, nindev, noutdev;
int newmidiindev[10], newmidioutdev[10];
#ifdef USEAPI_ALSA
int alsadevin, alsadevout;
#endif
for (i = 0; i < 10; i++)
{
......@@ -846,10 +848,9 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
noutdev++;
}
}
#ifdef USEAPI_ALSA
alsadevin = atom_getintarg(20, argc, argv);
alsadevout = atom_getintarg(21, argc, argv);
#ifdef USEAPI_ALSA
/* invent a story so that saving/recalling "settings" will
be able to restore the number of devices. ALSA MIDI handling
uses its own set of variables. LATER figure out how to get
......
......@@ -77,13 +77,23 @@ static void doerror(const void *object, const char *s)
static void dologpost(const void *object, const int level, const char *s)
{
char upbuf[MAXPDSTRING];
upbuf[MAXPDSTRING-1]=0;
/* 1. s is at most MAXPDSTRING, but we're prepending a stupid header
below. So for sanity, we first overallocate here to ensure the stupid
header doesn't end up overflowing the buffer. */
char upbuf[MAXPDSTRING * 2];
// what about sys_printhook_verbose ?
if (sys_printhook)
{
snprintf(upbuf, MAXPDSTRING-1, "verbose(%d): %s", level, s);
/* 2. The "n" in snprintf stands for "evil": we have to subtract one
from total size so the null doesn't get truncated */
snprintf(upbuf, MAXPDSTRING * 2 - 1, "verbose(%d): %s", level, s);
/* 3. Finally, we add a null at MAXPDSTRING-1 so that we end up with
a string that fits inside MAXPDSTRING for use with t_symbol, etc.
If anyone knows how I was *supposed* to do this safely within the
constraints of C's stupid stdlib, please teach me... */
upbuf[MAXPDSTRING-1]=0;
(*sys_printhook)(upbuf);
}
else if (sys_printtostderr)
......
......@@ -80,10 +80,15 @@ int u8_utf8toucs2(uint16_t *dest, int sz, char *src, int srcsz)
}
ch = 0;
switch (nb) {
/* these fall through deliberately */
/* these fall through deliberately, but commenting each explicitly
seems to quiet the compiler. If that's not future proof we
can just use copy/pasta and add the break statements */
case 3: ch += (unsigned char)*src++; ch <<= 6;
/* fall through */
case 2: ch += (unsigned char)*src++; ch <<= 6;
/* fall through */
case 1: ch += (unsigned char)*src++; ch <<= 6;
/* fall through */
case 0: ch += (unsigned char)*src++;
}
ch -= offsetsFromUTF8[nb];
......
......@@ -1655,10 +1655,10 @@ void *abinfo_new(void)
if(!abframe)
{
error("abinfo: only instantiable inside an ab object");
x = 0;
return (0);
}
else
x = pd_new(text_class);
return pd_new(text_class);
}
return (x);
}
......
......@@ -303,7 +303,7 @@ static int netsend_dosend(t_netsend *x, int sockfd,
bp += res;
}
}
done:
/* done: */
if (!x->x_bin)
{
t_freebytes(buf, length);
......
......@@ -348,6 +348,7 @@ t_binbuf *pointertobinbuf(t_pd *x, t_gpointer *gp, t_symbol *s,
/* these are unused; they copy text from this object to and from a text
field in a scalar. */
/*
static void text_define_frompointer(t_text_define *x, t_gpointer *gp,
t_symbol *s)
{
......@@ -359,7 +360,10 @@ static void text_define_frompointer(t_text_define *x, t_gpointer *gp,
binbuf_add(x->x_textbuf.b_binbuf, binbuf_getnatom(b), binbuf_getvec(b));
}
}
*/
/* This doesn't seem to be used, either... */
/*
static void text_define_topointer(t_text_define *x, t_gpointer *gp, t_symbol *s)
{
t_binbuf *b = pointertobinbuf(&x->x_textbuf.b_ob.ob_pd,
......@@ -382,6 +386,7 @@ static void text_define_topointer(t_text_define *x, t_gpointer *gp, t_symbol *s)
}
}
}
*/
/* bang: output a pointer to a struct containing this text */
void text_define_bang(t_text_define *x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment