gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9582 - in GNUnet/src/applications: fs/tools topology_defau


From: gnunet
Subject: [GNUnet-SVN] r9582 - in GNUnet/src/applications: fs/tools topology_default
Date: Wed, 18 Nov 2009 16:45:18 -0700

Author: grothoff
Date: 2009-11-18 16:45:18 -0700 (Wed, 18 Nov 2009)
New Revision: 9582

Modified:
   GNUnet/src/applications/fs/tools/gnunet-auto-share.c
   GNUnet/src/applications/topology_default/topology.c
Log:
misc bugfixes

Modified: GNUnet/src/applications/fs/tools/gnunet-auto-share.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2009-11-18 
23:37:38 UTC (rev 9581)
+++ GNUnet/src/applications/fs/tools/gnunet-auto-share.c        2009-11-18 
23:45:18 UTC (rev 9582)
@@ -389,7 +389,7 @@
 static void
 write_all_records (struct DirectoryRecord *dr)
 {
-  const char dummy;
+  static char dummy;
   long off;
   unsigned int d;
   unsigned long long size;
@@ -658,6 +658,7 @@
         GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_NO);
       return GNUNET_SYSERR;
     }
+  head = NULL;
   errorCode = 0;
   if ((GNUNET_NO == debug_flag)
       && (GNUNET_OK != GNUNET_terminal_detach (ectx, cfg, filedes,

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2009-11-18 23:37:38 UTC 
(rev 9581)
+++ GNUnet/src/applications/topology_default/topology.c 2009-11-18 23:45:18 UTC 
(rev 9582)
@@ -491,80 +491,82 @@
       GNUNET_free_non_null (fn);
       return 0;
     }
-  if ((fn != NULL) && (frstat.st_size > 0))
+  if (frstat.st_size == 0)
     {
-      GNUNET_array_grow (fInfo.friends, fInfo.friendCount, 0);
-      data = GNUNET_malloc (frstat.st_size);
-      if (frstat.st_size !=
-          GNUNET_disk_file_read (ectx, fn, frstat.st_size, data))
-        {
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _("Failed to read friends list from `%s'\n"), fn);
-          GNUNET_free (fn);
-          GNUNET_free (data);
-          return GNUNET_SYSERR;
-        }
+      GNUNET_free_non_null (fn);
+      return 0;
+    }
+  GNUNET_array_grow (fInfo.friends, fInfo.friendCount, 0);
+  data = GNUNET_malloc (frstat.st_size);
+  if (frstat.st_size !=
+      GNUNET_disk_file_read (ectx, fn, frstat.st_size, data))
+    {
+      GNUNET_GE_LOG (ectx,
+                    GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+                    _("Failed to read friends list from `%s'\n"), fn);
       GNUNET_free (fn);
-      fn = NULL;
-      pos = 0;
-      while ((pos < frstat.st_size) && isspace (data[pos]))
-        pos++;
-      while ((frstat.st_size >= sizeof (GNUNET_EncName)) &&
-             (pos <= frstat.st_size - sizeof (GNUNET_EncName)))
-        {
-          memcpy (&enc, &data[pos], sizeof (GNUNET_EncName));
-          if (!isspace (enc.encoding[sizeof (GNUNET_EncName) - 1]))
-            {
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_WARNING | GNUNET_GE_BULK |
-                             GNUNET_GE_USER,
-                             _
-                             ("Syntax error in topology specification, 
skipping bytes.\n"));
-              pos++;
-              while ((pos < frstat.st_size) && (!isspace (data[pos])))
-                pos++;
-              continue;
-            }
-          enc.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
-          if (GNUNET_OK == GNUNET_enc_to_hash ((char *) &enc, &hc))
-            {
-              GNUNET_array_grow (fInfo.friends, fInfo.friendCount,
-                                 fInfo.friendCount + 1);
-              fInfo.friends[fInfo.friendCount - 1].hashPubKey = hc;
-            }
-          else
-            {
-              GNUNET_GE_LOG (ectx,
-                             GNUNET_GE_WARNING | GNUNET_GE_BULK |
-                             GNUNET_GE_USER,
-                             _
-                             ("Syntax error in topology specification, 
skipping bytes `%s'.\n"),
-                             &enc);
-            }
-          pos = pos + sizeof (GNUNET_EncName);
-          while ((pos < frstat.st_size) && isspace (data[pos]))
-            pos++;
-        }
-      if ((fInfo.minimum_friend_count > fInfo.friendCount)
-          && (fInfo.friends_only == GNUNET_NO))
-        {
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _
-                         ("Fewer friends specified than required by minimum 
friend count. Will only connect to friends.\n"));
-        }
-      if ((fInfo.minimum_friend_count >
-           coreAPI->core_slots_count ()) && (fInfo.friends_only == GNUNET_NO))
-        {
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _
-                         ("More friendly connections required than target 
total number of connections.\n"));
-        }
       GNUNET_free (data);
+      return GNUNET_SYSERR;
     }
-  GNUNET_free_non_null (fn);
+  GNUNET_free (fn);
+  fn = NULL;
+  pos = 0;
+  while ((pos < frstat.st_size) && isspace (data[pos]))
+    pos++;
+  while ((frstat.st_size >= sizeof (GNUNET_EncName)) &&
+        (pos <= frstat.st_size - sizeof (GNUNET_EncName)))
+    {
+      memcpy (&enc, &data[pos], sizeof (GNUNET_EncName));
+      if (!isspace (enc.encoding[sizeof (GNUNET_EncName) - 1]))
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_WARNING | GNUNET_GE_BULK |
+                        GNUNET_GE_USER,
+                        _
+                        ("Syntax error in topology specification, skipping 
bytes.\n"));
+         pos++;
+         while ((pos < frstat.st_size) && (!isspace (data[pos])))
+           pos++;
+         continue;
+       }
+      enc.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
+      if (GNUNET_OK == GNUNET_enc_to_hash ((char *) &enc, &hc))
+       {
+         GNUNET_array_grow (fInfo.friends, fInfo.friendCount,
+                            fInfo.friendCount + 1);
+         fInfo.friends[fInfo.friendCount - 1].hashPubKey = hc;
+       }
+      else
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_WARNING | GNUNET_GE_BULK |
+                        GNUNET_GE_USER,
+                        _
+                        ("Syntax error in topology specification, skipping 
bytes `%s'.\n"),
+                        &enc);
+       }
+      pos = pos + sizeof (GNUNET_EncName);
+      while ((pos < frstat.st_size) && isspace (data[pos]))
+       pos++;
+    }
+  if ((fInfo.minimum_friend_count > fInfo.friendCount)
+      && (fInfo.friends_only == GNUNET_NO))
+    {
+      GNUNET_GE_LOG (ectx,
+                    GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                    _
+                    ("Fewer friends specified than required by minimum friend 
count. Will only connect to friends.\n"));
+    }
+  if ((fInfo.minimum_friend_count >
+       coreAPI->core_slots_count ()) && (fInfo.friends_only == GNUNET_NO))
+    {
+      GNUNET_GE_LOG (ectx,
+                    GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                    _
+                    ("More friendly connections required than target total 
number of connections.\n"));
+    }
+  GNUNET_free (data);
+  GNUNET_free (fn);
   return 0;
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]