make clang static analysis happy
[oweals/gnunet.git] / src / fs / gnunet-service-fs_indexing.c
index de569f7cae5f6e65c12e0c0e4c23e61c5bae5a72..4041997423d89df7f1b0efd4c1554ca0337aff30 100644 (file)
@@ -22,9 +22,6 @@
  * @file fs/gnunet-service-fs_indexing.c
  * @brief program that provides indexing functions of the file-sharing service
  * @author Christian Grothoff
- *
- * TODO:
- * - indexed files/blocks not removed on errors
  */
 #include "platform.h"
 #include <float.h>
@@ -92,7 +89,7 @@ static struct GNUNET_SCHEDULER_Handle *sched;
 /**
  * Our configuration.
  */
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
 
 /**
@@ -180,7 +177,7 @@ read_index_list ()
     }
   if (GNUNET_NO == GNUNET_DISK_file_test (fn))
     {
-      /* no index info  yet */
+      /* no index info yet */
       GNUNET_free (fn);
       return;
     }
@@ -248,7 +245,7 @@ signal_index_ok (struct IndexInfo *ii)
                                         GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                 _("Index request received for file `%s' is indexed as `%s'.  Permitting anyway.\n"),
+                 _("Index request received for file `%s' is already indexed as `%s'.  Permitting anyway.\n"),
                  ii->filename,
                  (const char*) GNUNET_CONTAINER_multihashmap_get (ifm,
                                                                   &ii->file_id));
@@ -325,7 +322,7 @@ GNUNET_FS_handle_index_start (void *cls,
                              const struct GNUNET_MessageHeader *message)
 {
   const struct IndexStartMessage *ism;
-  const char *fn;
+  char *fn;
   uint16_t msize;
   struct IndexInfo *ii;
   size_t slen;
@@ -344,7 +341,7 @@ GNUNET_FS_handle_index_start (void *cls,
       return;
     }
   ism = (const struct IndexStartMessage*) message;
-  fn = (const char*) &ism[1];
+  fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]);
   dev = ntohl (ism->device);
   ino = GNUNET_ntohll (ism->inode);
   ism = (const struct IndexStartMessage*) message;
@@ -366,6 +363,7 @@ GNUNET_FS_handle_index_start (void *cls,
     {      
       /* fast validation OK! */
       signal_index_ok (ii);
+      GNUNET_free (fn);
       return;
     }
 #if DEBUG_FS
@@ -383,6 +381,7 @@ GNUNET_FS_handle_index_start (void *cls,
                           HASHING_BLOCKSIZE,
                           &hash_for_index_val,
                           ii);
+  GNUNET_free (fn);
 }
 
 
@@ -596,8 +595,12 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
                  STRERROR (errno));
       if (fh != NULL)
        GNUNET_DISK_file_close (fh);
-      /* FIXME: if this happens often, we need
-        to remove the OnDemand block from the DS! */
+      GNUNET_FS_drq_remove (key,
+                           size,
+                           data,
+                           &remove_cont,
+                           NULL,
+                           GNUNET_TIME_UNIT_FOREVER_REL);
       return GNUNET_SYSERR;
     }
   GNUNET_DISK_file_close (fh);
@@ -621,8 +624,12 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
                  _("Indexed file `%s' changed at offset %llu\n"),
                  fn,
                  (unsigned long long) off);
-      /* FIXME: if this happens often, we need
-        to remove the OnDemand block from the DS! */
+      GNUNET_FS_drq_remove (key,
+                           size,
+                           data,
+                           &remove_cont,
+                           NULL,
+                           GNUNET_TIME_UNIT_FOREVER_REL);
       return GNUNET_SYSERR;
     }
 #if DEBUG_FS