diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c
index ec8f0cf76..fcaba7030 100644
--- a/libtransmission/peer-mgr.c
+++ b/libtransmission/peer-mgr.c
@@ -128,6 +128,9 @@ struct peer_atom
     time_t      shelf_date;
 };
 
+#ifdef NDEBUG
+#define tr_isAtom(a) (TRUE)
+#else
 static tr_bool
 tr_isAtom( const struct peer_atom * atom )
 {
@@ -135,6 +138,7 @@ tr_isAtom( const struct peer_atom * atom )
         && ( atom->from < TR_PEER_FROM__MAX )
         && ( tr_isAddress( &atom->addr ) );
 }
+#endif
 
 static const char*
 tr_atomAddrStr( const struct peer_atom * atom )
diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c
index ec4c5c75e..410ab289d 100644
--- a/libtransmission/peer-msgs.c
+++ b/libtransmission/peer-msgs.c
@@ -1377,7 +1377,9 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
     uint32_t      ui32;
     uint32_t      msglen = msgs->incoming.length;
     const uint8_t id = msgs->incoming.id;
+#ifndef NDEBUG
     const size_t  startBufLen = EVBUFFER_LENGTH( inbuf );
+#endif
     const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
 
     --msglen; /* id length */
diff --git a/libtransmission/ptrarray.c b/libtransmission/ptrarray.c
index c2ace243a..1506cc7c7 100644
--- a/libtransmission/ptrarray.c
+++ b/libtransmission/ptrarray.c
@@ -170,17 +170,19 @@ tr_ptrArrayLowerBound( const tr_ptrArray *                t,
     return first;
 }
 
+#ifdef NDEBUG
+#define assertSortedAndUnique(a,b)
+#else
 static void
 assertSortedAndUnique( const tr_ptrArray * t,
                         int compare(const void*, const void*) )
 {
-#ifndef NDEBUG
     int i;
 
     for( i = 0; i < t->n_items - 2; ++i )
         assert( compare( t->items[i], t->items[i + 1] ) <= 0 );
-#endif
 }
+#endif
 
 int
 tr_ptrArrayInsertSorted( tr_ptrArray * t,
diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c
index 362521cd9..f991316dd 100644
--- a/libtransmission/rpcimpl.c
+++ b/libtransmission/rpcimpl.c
@@ -183,7 +183,7 @@ static const char*
 torrentStart( tr_session               * session,
               tr_benc                  * args_in,
               tr_benc                  * args_out UNUSED,
-              struct tr_rpc_idle_data  * idle_data )
+              struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int           i, torrentCount;
     tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
@@ -204,7 +204,7 @@ static const char*
 torrentStop( tr_session               * session,
              tr_benc                  * args_in,
              tr_benc                  * args_out UNUSED,
-             struct tr_rpc_idle_data  * idle_data )
+             struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int           i, torrentCount;
     tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
@@ -225,7 +225,7 @@ static const char*
 torrentRemove( tr_session               * session,
                tr_benc                  * args_in,
                tr_benc                  * args_out UNUSED,
-               struct tr_rpc_idle_data  * idle_data )
+               struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int i;
     int torrentCount;
@@ -252,7 +252,7 @@ static const char*
 torrentReannounce( tr_session               * session,
                    tr_benc                  * args_in,
                    tr_benc                  * args_out UNUSED,
-                   struct tr_rpc_idle_data  * idle_data )
+                   struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int i, torrentCount;
     tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
@@ -277,7 +277,7 @@ static const char*
 torrentVerify( tr_session               * session,
                tr_benc                  * args_in,
                tr_benc                  * args_out UNUSED,
-               struct tr_rpc_idle_data  * idle_data )
+               struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int           i, torrentCount;
     tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
@@ -618,7 +618,7 @@ static const char*
 torrentGet( tr_session               * session,
             tr_benc                  * args_in,
             tr_benc                  * args_out,
-            struct tr_rpc_idle_data  * idle_data )
+            struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int           i, torrentCount;
     tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
@@ -737,7 +737,7 @@ static const char*
 torrentSet( tr_session               * session,
             tr_benc                  * args_in,
             tr_benc                  * args_out UNUSED,
-            struct tr_rpc_idle_data  * idle_data )
+            struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     const char * errmsg = NULL;
     int i, torrentCount;
@@ -793,7 +793,7 @@ static const char*
 torrentSetLocation( tr_session               * session,
                     tr_benc                  * args_in,
                     tr_benc                  * args_out UNUSED,
-                    struct tr_rpc_idle_data  * idle_data )
+                    struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     const char * errmsg = NULL;
     const char * location = NULL;
@@ -1132,7 +1132,7 @@ static const char*
 sessionSet( tr_session               * session,
             tr_benc                  * args_in,
             tr_benc                  * args_out UNUSED,
-            struct tr_rpc_idle_data  * idle_data )
+            struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int64_t      i;
     double       d;
@@ -1207,7 +1207,7 @@ static const char*
 sessionStats( tr_session               * session,
               tr_benc                  * args_in UNUSED,
               tr_benc                  * args_out,
-              struct tr_rpc_idle_data  * idle_data )
+              struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     int running = 0;
     int total = 0;
@@ -1254,7 +1254,7 @@ static const char*
 sessionGet( tr_session               * s,
             tr_benc                  * args_in UNUSED,
             tr_benc                  * args_out,
-            struct tr_rpc_idle_data  * idle_data )
+            struct tr_rpc_idle_data  * idle_data UNUSED )
 {
     const char * str;
     tr_benc *    d = args_out;
diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c
index c84056674..50074f6b5 100644
--- a/libtransmission/tr-dht.c
+++ b/libtransmission/tr-dht.c
@@ -187,16 +187,16 @@ dht_bootstrap(void *closure)
 
     if(!bootstrap_done(cl->session, 0)) {
         char *bootstrap_file;
-        FILE *f;
+        FILE *f = NULL;
 
         bootstrap_file =
             tr_buildPath(cl->session->configDir, "dht.bootstrap", NULL);
 
         if(bootstrap_file)
             f = fopen(bootstrap_file, "r");
-        if(f) {
+        if(f != NULL) {
             tr_ninf("DHT", "Attempting manual bootstrap");
-            while(1) {
+            for(;;) {
                 char buf[201];
                 char *p;
                 int port = 0;