gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9564 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r9564 - gnunet/src/util
Date: Mon, 16 Nov 2009 07:33:38 -0700

Author: grothoff
Date: 2009-11-16 07:33:38 -0700 (Mon, 16 Nov 2009)
New Revision: 9564

Modified:
   gnunet/src/util/pseudonym.c
Log:
proper error handling 

Modified: gnunet/src/util/pseudonym.c
===================================================================
--- gnunet/src/util/pseudonym.c 2009-11-16 14:23:54 UTC (rev 9563)
+++ gnunet/src/util/pseudonym.c 2009-11-16 14:33:38 UTC (rev 9564)
@@ -177,19 +177,29 @@
                       int32_t ranking, const char *ns_name)
 {
   char *fn;
-  int ret;
+  struct GNUNET_BIO_WriteHandle *fileW;
+
   fn = get_data_filename (cfg, PS_METADATA_DIR, nsid);
   GNUNET_assert (fn != NULL);
-  struct GNUNET_BIO_WriteHandle *fileW;
   fileW = GNUNET_BIO_write_open(fn);
-  if((NULL != fileW)&&
-        (GNUNET_OK == GNUNET_BIO_write_int32(fileW, ranking))&&
-     (GNUNET_OK == GNUNET_BIO_write_string(fileW, ns_name))&&
-     (GNUNET_OK == GNUNET_BIO_write_meta_data(fileW, meta))&&
-     (GNUNET_OK == GNUNET_BIO_write_close(fileW)))
-  ret = GNUNET_OK;
-  else
-  ret = GNUNET_SYSERR;
+  if (NULL != fileW) 
+    {
+      if ( (GNUNET_OK != GNUNET_BIO_write_int32(fileW, ranking)) ||
+          (GNUNET_OK != GNUNET_BIO_write_string(fileW, ns_name)) ||
+          (GNUNET_OK != GNUNET_BIO_write_meta_data(fileW, meta)) )
+       {
+         GNUNET_BIO_write_close(fileW);
+         GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fileW));
+         GNUNET_free (fn);
+         return;
+       }
+      if (GNUNET_OK != GNUNET_BIO_write_close(fileW))
+       {
+         GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fileW));
+         GNUNET_free (fn);
+         return;
+       }
+    }
   GNUNET_free (fn);
   /* create entry for pseudonym name in names */
   GNUNET_free_non_null (GNUNET_PSEUDONYM_id_to_name (cfg, nsid));





reply via email to

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