- fix coverity
[oweals/gnunet.git] / src / transport / gnunet-service-transport.c
index 89a1ec4c9166bc813be86ee16b5ae4ce9eda98a6..5a764f91fcb6cbe58dc6f1f7991a44da37cf1158 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2015 GNUnet e.V.
 
  GNUnet is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
@@ -224,7 +224,7 @@ process_payload (const struct GNUNET_HELLO_Address *address,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Discarded %u bytes type %u payload from peer `%s'\n",
-                msg_size,
+                (unsigned int) msg_size,
                 ntohs (message->type),
                 GNUNET_i2s (&address->peer));
     GNUNET_STATISTICS_update (GST_stats, gettext_noop
@@ -250,11 +250,9 @@ process_payload (const struct GNUNET_HELLO_Address *address,
  * Task to asynchronously terminate a session.
  *
  * @param cls the `struct GNUNET_ATS_SessionKiller` with the information for the kill
- * @param tc scheduler context
  */
 static void
-kill_session_task (void *cls,
-                   const struct GNUNET_SCHEDULER_TaskContext *tc)
+kill_session_task (void *cls)
 {
   struct GNUNET_ATS_SessionKiller *sk = cls;
 
@@ -756,11 +754,9 @@ ats_request_address_change (void *cls,
  * and cancels pending validations.
  *
  * @param cls closure, unused
- * @param tc task context (unused)
  */
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   GST_neighbours_stop ();
   GST_plugins_unload ();
@@ -852,9 +848,8 @@ run (void *cls,
              "My identity is `%4s'\n",
              GNUNET_i2s_full (&GST_my_identity));
 
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
   if (NULL == GST_peerinfo)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
@@ -864,23 +859,24 @@ run (void *cls,
   }
 
   max_fd_rlimit = 0;
-  max_fd_cfg = 0;
 #if HAVE_GETRLIMIT
   struct rlimit r_file;
   if (0 == getrlimit (RLIMIT_NOFILE, &r_file))
   {
     max_fd_rlimit = r_file.rlim_cur;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Maximum number of open files was: %u/%u\n",
-        r_file.rlim_cur,
-        r_file.rlim_max);
+                "Maximum number of open files was: %u/%u\n",
+                (unsigned int) r_file.rlim_cur,
+                (unsigned int) r_file.rlim_max);
   }
   max_fd_rlimit = (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */
 #endif
-  GNUNET_CONFIGURATION_get_value_number (GST_cfg,
-                                         "transport",
-                                         "MAX_FD",
-                                         &max_fd_cfg);
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (GST_cfg,
+                                             "transport",
+                                             "MAX_FD",
+                                             &max_fd_cfg))
+    max_fd_cfg = max_fd_rlimit;
 
   if (max_fd_cfg > max_fd_rlimit)
     max_fd = max_fd_cfg;
@@ -891,7 +887,9 @@ run (void *cls,
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Limiting number of sockets to %u: validation %u, neighbors: %u\n",
-             max_fd, (max_fd / 3), (max_fd / 3) * 2);
+              max_fd,
+              (max_fd / 3),
+              (max_fd / 3) * 2);
 
   friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg,
                                                       "topology",