-LRN: use FOPEN/CLOSE instead of fopen/close - #2051
authorChristian Grothoff <christian@grothoff.org>
Fri, 30 Dec 2011 22:43:52 +0000 (22:43 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 30 Dec 2011 22:43:52 +0000 (22:43 +0000)
src/dv/test_transport_api_dv.c
src/testing/test_testing_large_topology.c
src/testing/test_testing_topology.c
src/testing/test_testing_topology_blacklist.c
src/testing/testing_group.c
src/util/configuration.c
src/util/os_installation.c
src/util/service.c
src/util/test_crypto_hash.c

index 435bb2a608f6fce5d576daec002e8a9972a6a19f..386ea5f29c05661206b992e253bec4afded154ec 100644 (file)
@@ -274,8 +274,8 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 #endif
   if (dotOutFile != NULL)
   {
-    fclose (dotOutFile);
     FPRINTF (dotOutFile, "%s",  "}");
+    FCLOSE (dotOutFile);
   }
 
   ok = 0;
@@ -383,7 +383,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 }
 
index 2bca7b3b95dbe8e3ff49b2ba833d4f091b3a2699..605761105b85459fe35f2d078e4b0d5b400d470e 100644 (file)
@@ -246,7 +246,7 @@ finish_testing ()
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 
   ok = 0;
@@ -303,7 +303,7 @@ topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
     if (outfile != NULL)
     {
       FPRINTF (outfile, "%s",  "}\n");
-      fclose (outfile);
+      FCLOSE (outfile);
       GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
     }
   }
@@ -358,7 +358,7 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
 #endif
     GNUNET_SCHEDULER_cancel (die_task);
     GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology");
-    dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
+    dotOutFileFinished = FOPEN (dotOutFileNameFinished, "w");
     GNUNET_free (dotOutFileNameFinished);
     if (dotOutFileFinished != NULL)
     {
@@ -425,7 +425,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 }
 
@@ -949,7 +949,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   ok = 1;
 
-  dotOutFile = fopen (dotOutFileName, "w");
+  dotOutFile = FOPEN (dotOutFileName, "w");
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "strict graph G {\n");
index 17f3be89a13da0ace5c3135a39940dafc5b1ba4c..7404aa73e448e00a1a7b939d4476aa75e398e2c6 100644 (file)
@@ -339,7 +339,7 @@ topology_cb (void *cls, const struct GNUNET_PeerIdentity *first,
     if (outfile != NULL)
     {
       FPRINTF (outfile, "%s",  "}\n");
-      fclose (outfile);
+      FCLOSE (outfile);
 #if DO_STATS
       GNUNET_TESTING_get_statistics (pg, &stats_finished, &stats_print, NULL);
 #endif
@@ -398,7 +398,7 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
 #endif
     GNUNET_SCHEDULER_cancel (die_task);
     GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology");
-    dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
+    dotOutFileFinished = FOPEN (dotOutFileNameFinished, "w");
     GNUNET_free (dotOutFileNameFinished);
     if (dotOutFileFinished != NULL)
     {
@@ -465,7 +465,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 }
 
@@ -1006,7 +1006,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   ok = 1;
 
-  dotOutFile = fopen (dotOutFileName, "w");
+  dotOutFile = FOPEN (dotOutFileName, "w");
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "strict graph G {\n");
index 9ff1fcbaaac859c19d5fe3b2c850ee65776da4e3..d207ac2fcf9dfa10ba0c77c12a85864a3b81b26a 100644 (file)
@@ -143,7 +143,7 @@ finish_testing ()
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 
   ok = 0;
@@ -168,7 +168,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "}");
-    fclose (dotOutFile);
+    FCLOSE (dotOutFile);
   }
 }
 
@@ -396,7 +396,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 
   ok = 1;
 
-  dotOutFile = fopen (dotOutFileName, "w");
+  dotOutFile = FOPEN (dotOutFileName, "w");
   if (dotOutFile != NULL)
   {
     FPRINTF (dotOutFile, "%s",  "strict graph G {\n");
@@ -414,7 +414,7 @@ run (void *cls, char *const *args, const char *cfgfile,
     ok = 404;
     if (dotOutFile != NULL)
     {
-      fclose (dotOutFile);
+      FCLOSE (dotOutFile);
     }
     return;
   }
@@ -453,7 +453,7 @@ run (void *cls, char *const *args, const char *cfgfile,
       ok = 707;
       if (dotOutFile != NULL)
       {
-        fclose (dotOutFile);
+        FCLOSE (dotOutFile);
       }
       return;
     }
@@ -470,7 +470,7 @@ run (void *cls, char *const *args, const char *cfgfile,
     ok = 808;
     if (dotOutFile != NULL)
     {
-      fclose (dotOutFile);
+      FCLOSE (dotOutFile);
     }
     return;
   }
index 4f67179c1a19ba4fd1958c15881c1329532e1189..32adf465e0e2d9803dcdc0f9eea67794d612e727 100644 (file)
@@ -2891,7 +2891,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
   {
     mytemp = GNUNET_DISK_mktemp ("friends");
     GNUNET_assert (mytemp != NULL);
-    temp_friend_handle = fopen (mytemp, "wt");
+    temp_friend_handle = FOPEN (mytemp, "wt");
     GNUNET_assert (temp_friend_handle != NULL);
 #if OLD
     conn_iter = pg->peers[pg_iter].allowed_peers_head;
@@ -2907,7 +2907,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
                                            &friend_file_iterator,
                                            temp_friend_handle);
 #endif
-    fclose (temp_friend_handle);
+    FCLOSE (temp_friend_handle);
 
     if (GNUNET_OK !=
         GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
@@ -3064,7 +3064,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
   {
     mytemp = GNUNET_DISK_mktemp ("blacklist");
     GNUNET_assert (mytemp != NULL);
-    temp_file_handle = fopen (mytemp, "wt");
+    temp_file_handle = FOPEN (mytemp, "wt");
     GNUNET_assert (temp_file_handle != NULL);
     temp_transports = GNUNET_strdup (transports);
 #if !OLD
@@ -3106,7 +3106,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
     }
 
     GNUNET_free (temp_transports);
-    fclose (temp_file_handle);
+    FCLOSE (temp_file_handle);
 
     if (GNUNET_OK !=
         GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
index eb86d0496dbf79ee4f740aac21bd329ed3b95be1..50f32e2864d49d698883c9596b2e42327ccba4ad 100644 (file)
@@ -248,7 +248,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
       break;
     }
   }
-  GNUNET_assert (0 == fclose (fp));
+  GNUNET_assert (0 == FCLOSE (fp));
   /* restore dirty flag - anything we set in the meantime
    * came from disk */
   cfg->dirty = dirty;
@@ -348,7 +348,7 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
   }
   if (error != 0)
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", filename);
-  GNUNET_assert (0 == fclose (fp));
+  GNUNET_assert (0 == FCLOSE (fp));
   if (error != 0)
   {
     cfg->dirty = GNUNET_SYSERR; /* last write failed */
index c5cf1ccb36394c6a4b437b280715b6acf01cf1f2..6d25c57096ddeaeab7c3c5ec3aaaef7b34ab4c25 100644 (file)
@@ -56,7 +56,7 @@ get_path_from_proc_maps ()
   char *lgu;
 
   GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/maps", getpid ());
-  f = fopen (fn, "r");
+  f = FOPEN (fn, "r");
   if (f == NULL)
     return NULL;
   while (NULL != fgets (line, sizeof (line), f))
@@ -66,11 +66,11 @@ get_path_from_proc_maps ()
         (NULL != (lgu = strstr (dir, "libgnunetutil"))))
     {
       lgu[0] = '\0';
-      fclose (f);
+      FCLOSE (f);
       return GNUNET_strdup (dir);
     }
   }
-  fclose (f);
+  FCLOSE (f);
   return NULL;
 }
 
index ebdf2c61a967c9daba08283a2d1dbe5c83f287f8..8235830c99dd463274ee765e3d68d47b76cb8278 100644 (file)
@@ -1351,7 +1351,7 @@ write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
   }
   if (0 > FPRINTF (pidfd, "%u", pid))
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif);
-  GNUNET_break (0 == fclose (pidfd));
+  GNUNET_break (0 == FCLOSE (pidfd));
   if ((user != NULL) && (0 < strlen (user)))
     GNUNET_DISK_file_change_owner (pif, user);
   GNUNET_free_non_null (user);
index b0fa4f3325da1345f0c91b575486348a2b298e41..bc0411482d2f0079146df0763d166895fd2c4588 100644 (file)
@@ -137,9 +137,9 @@ testFileHash ()
 
   memset (block, 42, sizeof (block) / 2);
   memset (&block[sizeof (block) / 2], 43, sizeof (block) / 2);
-  GNUNET_assert (NULL != (f = fopen (FILENAME, "w+")));
+  GNUNET_assert (NULL != (f = FOPEN (FILENAME, "w+")));
   GNUNET_break (sizeof (block) == fwrite (block, 1, sizeof (block), f));
-  GNUNET_break (0 == fclose (f));
+  GNUNET_break (0 == FCLOSE (f));
   ret = 1;
   GNUNET_SCHEDULER_run (&file_hasher, &ret);
   GNUNET_break (0 == UNLINK (FILENAME));