diff --git a/pd/src/d_fft_mayer.c b/pd/src/d_fft_mayer.c
index 8df7fb3ffa887dd563f87bd068693d581f0e1328..3e51d308618fd3c7f2360b698e118abf78799bdc 100644
--- a/pd/src/d_fft_mayer.c
+++ b/pd/src/d_fft_mayer.c
@@ -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];
diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h
index b7684019fe00dd5815513673e2b6da7a0500924e..39d88ebb51aa186c588d5cd7bd8b88cdf722664d 100644
--- a/pd/src/g_all_guis.h
+++ b/pd/src/g_all_guis.h
@@ -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;
diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c
index 00d2b0be80af02a479e9e97b5ff7694c2977eb3a..c32084841c68ebb2b5a57bc2d3f757b7825c7844 100644
--- a/pd/src/g_bang.c
+++ b/pd/src/g_bang.c
@@ -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;
diff --git a/pd/src/g_readwrite.c b/pd/src/g_readwrite.c
index 007dcc0ee3f156ce1a686233496b4a1154912ac8..ae4ee02abf9c5ebf17ed69add8a053982bd7d3d8 100644
--- a/pd/src/g_readwrite.c
+++ b/pd/src/g_readwrite.c
@@ -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)
diff --git a/pd/src/g_template.c b/pd/src/g_template.c
index a37957dfcce526db87f7c49a3d50ad927b248900..043760e2ad99ac00802bde6870a26ea435a52b7e 100644
--- a/pd/src/g_template.c
+++ b/pd/src/g_template.c
@@ -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 
diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c
index 195887fc5790f6aec8eccb177b4ebb4fa7161fea..bcc06a597a4c67105b0d840f5af3a15f82175cec 100644
--- a/pd/src/g_toggle.c
+++ b/pd/src/g_toggle.c
@@ -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;
diff --git a/pd/src/m_binbuf.c b/pd/src/m_binbuf.c
index 01750677fce387b6e8210891e14c9116a7a91848..f2c020ccbf7c470266e9235dcecd097d6d6194e0 100644
--- a/pd/src/m_binbuf.c
+++ b/pd/src/m_binbuf.c
@@ -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)
diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c
index d927daa2964dcc75b72ace5e5797bd29f69a9bf8..1dc0646a809a2d73255dda9a5d51d7d420d1d46c 100644
--- a/pd/src/s_loader.c
+++ b/pd/src/s_loader.c
@@ -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");
 
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 2dbc5e906b753a1fd17f7bae45460964b106b07d..7603e5d1b56b8c02c55394db77dc932d8535ea26 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -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");
diff --git a/pd/src/s_midi.c b/pd/src/s_midi.c
index 9c9b04f2db1971d8a31d4524aa15217acb33aff2..5d6886e2697ff38849664e04fe79da6606d3d398 100644
--- a/pd/src/s_midi.c
+++ b/pd/src/s_midi.c
@@ -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
diff --git a/pd/src/s_print.c b/pd/src/s_print.c
index 156f45ac612b7da74dd01681f2a7e9bde1692921..5c6705b9d32d020676e64bb5e68d6a015fa24944 100644
--- a/pd/src/s_print.c
+++ b/pd/src/s_print.c
@@ -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) 
diff --git a/pd/src/s_utf8.c b/pd/src/s_utf8.c
index 8cf20aa27199e11e7ce82bcdb73c32acce37313b..09d0da32ef0cd31a843a53715bea9604472fe3fd 100644
--- a/pd/src/s_utf8.c
+++ b/pd/src/s_utf8.c
@@ -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];
diff --git a/pd/src/x_interface.c b/pd/src/x_interface.c
index 6753ea626236c574d981ccfa9753e4e22a037aae..e498b5bfad50b1103ec87841a814669c9e4462a5 100644
--- a/pd/src/x_interface.c
+++ b/pd/src/x_interface.c
@@ -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);
 }
diff --git a/pd/src/x_net.c b/pd/src/x_net.c
index e81ce245041e3fab868093bcfe770b1ec73674a9..4ddecf63b25c0d2f0c7a398acaa165bc18b9921d 100644
--- a/pd/src/x_net.c
+++ b/pd/src/x_net.c
@@ -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);
diff --git a/pd/src/x_text.c b/pd/src/x_text.c
index 3d61d0cf3f1c3aa9fded175287e38f8a51303a26..4e5c719152e155a1330448953b97169358b38b59 100644
--- a/pd/src/x_text.c
+++ b/pd/src/x_text.c
@@ -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)