diff --git a/src/dmalloc.h b/src/dmalloc.h
index 4ca094345d4358cf300bfcfd2d4c995a78d9af3f..5a3ae9be6f52b2dd9775b043911db3359286a326 100644
--- a/src/dmalloc.h
+++ b/src/dmalloc.h
@@ -42,7 +42,7 @@ typedef void *c_stack_frame;
  * 'T': memory map template
  * 'M': memory map
  */
-typedef char *LOCATION;
+typedef const char *LOCATION;
 #define LOCATION_TYPE(X) ((X)[0])
 #define LOCATION_NAME(X) ((X)+1)
 #define LOCATION_IS_DYNAMIC(X)						\
@@ -110,7 +110,7 @@ void search_all_memheaders_for_references(void);
 /* Beware! names of named memory regions are never ever freed!! /Hubbe */
 PMOD_EXPORT void *debug_malloc_name(void *p, const char *fn, INT_TYPE line);
 PMOD_EXPORT int debug_malloc_copy_names(void *p, void *p2);
-char *dmalloc_find_name(void *p);
+const char *dmalloc_find_name(void *p);
 
 /* glibc 2.1 defines this as a macro. */
 #ifdef strdup
diff --git a/src/modules/_Stdio/file.c b/src/modules/_Stdio/file.c
index cb0dae800faa30b4bda0c4afd90aa410f8199d0a..6ba3d691a5fb5c466e4239ff7d6be135acefd052 100644
--- a/src/modules/_Stdio/file.c
+++ b/src/modules/_Stdio/file.c
@@ -5980,7 +5980,8 @@ static inline long TO_LONG(ptrdiff_t x)
 #endif /* __ECL */
 
 #ifdef PIKE_DEBUG
-void check_static_file_data(struct callback *a, void *b, void *c)
+void check_static_file_data(struct callback *UNUSED(a), void *UNUSED(b),
+                            void *UNUSED(c))
 {
   if(file_program)
   {
diff --git a/src/pike_memory.c b/src/pike_memory.c
index d352ea73816aca51f8e37642c6668e45bee23c39..f6ef05922ea0a59396baeed33797a36d24a25920 100644
--- a/src/pike_memory.c
+++ b/src/pike_memory.c
@@ -1861,58 +1861,6 @@ static void add_location(struct memhdr *mh,
   return;
 }
 
-static void remove_location(struct memhdr *mh, LOCATION location)
-{
-  struct memloc *ml,**prev;
-  unsigned long l;
-
-#if defined(DMALLOC_VERIFY_INTERNALS) && !defined(__NT__) && defined(PIKE_THREADS)
-  if(!mt_trylock(& debug_malloc_mutex))
-    Pike_fatal("remove_location running unlocked!\n");
-#endif
-  
-#if DEBUG_MALLOC - 0 < 2
-  if(find_location(&no_leak_memlocs, location)) return;
-#endif
-
-  if (!(ml = find_location(mh, location))) {
-    return;
-  }
-
-  /* Unlink from the hashtable. */
-  if ((ml->hash_prev[0] = ml->hash_next)) {
-    ml->hash_next->hash_prev = ml->hash_prev;
-  }
-
-  prev=&mh->locations;
-  while((ml=*prev))
-  {
-#ifdef DMALLOC_VERIFY_INTERNALS
-    if (ml->mh != mh) {
-      Pike_fatal("Non-owned memloc in location list!\n");
-    }
-#endif
-
-    if(ml->location==location)
-    {
-      *prev=ml->next;
-#ifdef DMALLOC_VERIFY_INTERNALS
-      mh->times -= ml->times;
-#endif
-#ifdef DMALLOC_TRACE_MEMLOC
-      if (ml == DMALLOC_TRACE_MEMLOC) {
-        fprintf(stderr, "rem_loc: Freeing memloc %p location %s memhdr: %p data: %p\n",
-		ml, ml->location, ml->mh, ml->mh->data);
-      }
-#endif /* DMALLOC_TRACE_MEMLOC */
-      really_free_memloc(ml);
-      return;
-    }else{
-      prev=&ml->next;
-    }
-  }
-}
-
 LOCATION dmalloc_default_location=0;
 
 static struct memhdr *low_make_memhdr(void *p, int s, LOCATION location
@@ -2058,7 +2006,7 @@ PMOD_EXPORT int dmalloc_unregister(void *p, int already_gone)
   return ret;
 }
 
-static int low_dmalloc_mark_as_free(void *p, int already_gone)
+static int low_dmalloc_mark_as_free(void *p, int UNUSED(already_gone))
 {
   struct memhdr *mh=find_memhdr(p);
   if(mh)
@@ -3044,9 +2992,9 @@ PMOD_EXPORT int debug_malloc_copy_names(void *p, void *p2)
   return names;
 }
 
-char *dmalloc_find_name(void *p)
+const char *dmalloc_find_name(void *p)
 {
-  char *name=0;
+  const char *name=0;
   if(p)
   {
     struct memhdr *mh;
@@ -3089,9 +3037,9 @@ PMOD_EXPORT void *debug_malloc_update_location_bt (void *p, const char *file,
   return debug_malloc_update_location (p, l);
 }
 
+#ifdef DMALLOC_C_STACK_TRACE
 static void dump_location_bt (LOCATION location, int indent, const char *prefix)
 {
-#ifdef DMALLOC_C_STACK_TRACE
   if (LOCATION_TYPE (location) == 'B') {
     c_stack_frame bt[BT_MAX_FRAMES];
     int i, frames;
@@ -3106,8 +3054,12 @@ static void dump_location_bt (LOCATION location, int indent, const char *prefix)
       backtrace_symbols_fd (bt + i, 1, 2);
     }
   }
-#endif
 }
+#else
+static void dump_location_bt (LOCATION UNUSED(location), int UNUSED(indent),
+                              const char *UNUSED(prefix))
+{ }
+#endif
 
 PMOD_EXPORT int debug_malloc_touch_fd(int fd, LOCATION location)
 {
@@ -3129,7 +3081,7 @@ PMOD_EXPORT void debug_malloc_accept_leak_fd(int fd)
   dmalloc_accept_leak(FD2PTR(fd));
 }
 
-PMOD_EXPORT int debug_malloc_close_fd(int fd, LOCATION location)
+PMOD_EXPORT int debug_malloc_close_fd(int fd, LOCATION UNUSED(location))
 {
   if(fd==-1) return fd;
 #ifdef DMALLOC_TRACK_FREE
@@ -3189,10 +3141,6 @@ static struct memory_map * alloc_memory_map() {
     return ba_alloc(&memory_map_allocator);
 }
 
-static void really_free_memory_map(struct memory_map * m) {
-    ba_free(&memory_map_allocator, m);
-}
-
 void count_memory_in_memory_maps(size_t * n, size_t * s) {
     ba_count_all(&memory_map_allocator, n, s);
 }
@@ -3204,10 +3152,6 @@ static struct memory_map_entry * alloc_memory_map_entry() {
     return ba_alloc(&memory_map_entry_allocator);
 }
 
-static void really_free_memory_map_entry(struct memory_map_entry * m) {
-    ba_free(&memory_map_entry_allocator, m);
-}
-
 void count_memory_in_memory_map_entrys(size_t * n, size_t * s) {
     ba_count_all(&memory_map_entry_allocator, n, s);
 }
diff --git a/src/pike_types.c b/src/pike_types.c
index 34c9dc2e907f8c4dd49dcdc9c15c8a5c0019c241..8707c02a7c29c92fbfad6aefb809a995469f3ae1 100644
--- a/src/pike_types.c
+++ b/src/pike_types.c
@@ -132,7 +132,7 @@ static struct program *implements_b;
 static int implements_mode;
 
 #ifdef PIKE_DEBUG
-void TYPE_STACK_DEBUG(const char *fun)
+void TYPE_STACK_DEBUG(const char *UNUSED(fun))
 {
 #if 0
   fprintf(stderr, "%25s(): stack_depth:%ld   mark_stack_depth:%ld\n",
@@ -738,7 +738,7 @@ void debug_push_int_type(INT_TYPE min, INT_TYPE max)
 #endif
 
 #ifdef PIKE_DEBUG	/* FIXME: Kludge to support 2^32-1 */
-  if ((min>0 && max>0 || min<0 && max<0) && min > max)
+  if (((min>0 && max>0) || (min<0 && max<0)) && min > max)
     Pike_fatal("push_int_type(): Bad integer range:"
 	       " min:%"PRINTPIKEINT"d, max:%"PRINTPIKEINT"d.\n",
 	       min, max);
@@ -9064,7 +9064,8 @@ void gc_mark_type_as_referenced(struct pike_type *t)
 }
 
 #ifdef PIKE_DEBUG
-static void gc_mark_external_types(struct callback *cb, void *a, void *b)
+static void gc_mark_external_types(struct callback *UNUSED(cb),
+                                   void *UNUSED(a), void *UNUSED(b))
 {
   unsigned int e;
   for (e = 0; e < NELEM (a_markers); e++) {
diff --git a/src/program.c b/src/program.c
index b024243f6ad0bd8b5febcb14e8da84a89fde0123..c73878f86e1e18ff652fe7c55c011fa8ce7de13e 100644
--- a/src/program.c
+++ b/src/program.c
@@ -2417,7 +2417,7 @@ struct pike_string *find_program_name(struct program *p, INT_TYPE *line)
 
 #ifdef DEBUG_MALLOC
   {
-    char *tmp=dmalloc_find_name(p);
+    const char *tmp=dmalloc_find_name(p);
     if (tmp) {
       char *p = strchr (tmp, ':');
       if (p) {
diff --git a/src/signal_handler.c b/src/signal_handler.c
index 6c998b88b980e0fd62df8c6a4cac598a8df79b63..f1dbae1046f8e293c7e12d270305ca08ff3a29db 100644
--- a/src/signal_handler.c
+++ b/src/signal_handler.c
@@ -4785,16 +4785,6 @@ static void f_ualarm(INT32 args)
 }
 #endif /* HAVE_UALARM || HAVE_SETITIMER */
 
-#ifdef PIKE_DEBUG
-static RETSIGTYPE fatal_signal(int signum)
-{
-  my_signal(signum,SIG_DFL);
-  Pike_fatal("Fatal signal (%s) recived.\n",signame(signum));
-}
-#endif
-
-
-
 static struct array *atexit_functions;
 
 static void run_atexit_functions(struct callback *UNUSED(cb), void *UNUSED(arg),void *UNUSED(arg2))