fix bugs found by compiling with -Wextra
authorPhilipp Tölke <toelke@in.tum.de>
Wed, 15 Jun 2011 07:15:39 +0000 (07:15 +0000)
committerPhilipp Tölke <toelke@in.tum.de>
Wed, 15 Jun 2011 07:15:39 +0000 (07:15 +0000)
src/mesh/mesh_api.c
src/vpn/gnunet-daemon-exit.c
src/vpn/gnunet-daemon-vpn-helper.c
src/vpn/gnunet-daemon-vpn.c
src/vpn/gnunet-helper-vpn-api.c
src/vpn/gnunet-helper-vpn-api.h
src/vpn/gnunet-service-dns.c

index edbc549b88f373126b5185fb7a35d524d3f6282b..c1875854ec97b9013f121fbbf7dd7c3b78388e04 100644 (file)
@@ -127,6 +127,9 @@ static void
 send_end_connect(void* cls,
                     const struct GNUNET_SCHEDULER_TaskContext* tc)
 {
+  if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+    return;
+
   struct GNUNET_MESH_Tunnel* tunnel = cls;
 
   tunnel->connect_handler(tunnel->handler_cls, NULL, NULL);
@@ -136,6 +139,9 @@ static void
 send_self_connect(void* cls,
                        const struct GNUNET_SCHEDULER_TaskContext* tc)
 {
+  if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+      return;
+
   struct GNUNET_MESH_Tunnel* tunnel = cls;
 
   tunnel->connect_handler(tunnel->handler_cls, &tunnel->handle->myself, NULL);
@@ -146,6 +152,9 @@ static void
 call_connect_handler (void *cls,
                       const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+      return;
+
   struct GNUNET_MESH_Tunnel *tunnel = cls;
 
   tunnel->connect_handler (tunnel->handler_cls, &tunnel->peer,
@@ -689,7 +698,7 @@ GNUNET_MESH_connect (const struct
 
   build_hello_message(ret, stypes);
 
-  const static struct GNUNET_CORE_MessageHandler core_handlers[] = {
+  static const struct GNUNET_CORE_MessageHandler core_handlers[] = {
     {&core_receive, GNUNET_MESSAGE_TYPE_MESH, 0},
     {&receive_hello, GNUNET_MESSAGE_TYPE_MESH_HELLO, 0},
     {NULL, 0, 0}
index 87b795edd4be34c467e34d8af61f6f8287925f38..0ee07feadfcf0c75149c77f2a6e86004a73ba2dc 100644 (file)
@@ -243,8 +243,7 @@ send_udp_to_peer_notify_callback (void *cls, size_t size, void *buf)
  * @param version 4 or 6
  */
 static void
-udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen,
-                 unsigned int version)
+udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen)
 {
   struct redirect_info u_i;
   struct GNUNET_MESH_Tunnel *tunnel;
@@ -337,7 +336,7 @@ udp_from_helper (struct udp_pkt *udp, unsigned char *dadr, size_t addrlen,
  */
 static void
 tcp_from_helper (struct tcp_pkt *tcp, unsigned char *dadr, size_t addrlen,
-                 unsigned int version, size_t pktlen)
+                 size_t pktlen)
 {
   struct redirect_info u_i;
   struct GNUNET_MESH_Tunnel *tunnel;
@@ -421,10 +420,10 @@ message_token (void *cls,
       struct ip6_pkt *pkt6 = (struct ip6_pkt *) pkt_tun;
       if (0x11 == pkt6->ip6_hdr.nxthdr)
         udp_from_helper (&((struct ip6_udp *) pkt6)->udp_hdr,
-                         (unsigned char *) &pkt6->ip6_hdr.dadr, 16, 6);
+                         (unsigned char *) &pkt6->ip6_hdr.dadr, 16);
       else if (0x06 == pkt6->ip6_hdr.nxthdr)
         tcp_from_helper (&((struct ip6_tcp *) pkt6)->tcp_hdr,
-                         (unsigned char *) &pkt6->ip6_hdr.dadr, 16, 6,
+                         (unsigned char *) &pkt6->ip6_hdr.dadr, 16,
                          ntohs (pkt6->ip6_hdr.paylgth));
     }
   else if (ntohs (pkt_tun->tun.type) == 0x0800)
@@ -433,7 +432,7 @@ message_token (void *cls,
       uint32_t tmp = pkt4->ip_hdr.dadr;
       if (0x11 == pkt4->ip_hdr.proto)
         udp_from_helper (&((struct ip_udp *) pkt4)->udp_hdr,
-                         (unsigned char *) &tmp, 4, 4);
+                         (unsigned char *) &tmp, 4);
       else if (0x06 == pkt4->ip_hdr.proto)
         {
           size_t pktlen = ntohs(pkt4->ip_hdr.tot_lngth);
@@ -441,7 +440,7 @@ message_token (void *cls,
           pktlen -= 4*pkt4->ip_hdr.hdr_lngth;
           GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "-hdr: %d\n", pktlen);
           tcp_from_helper (&((struct ip_tcp *) pkt4)->tcp_hdr,
-                           (unsigned char *) &tmp, 4, 4, pktlen);
+                           (unsigned char *) &tmp, 4, pktlen);
         }
     }
   else
@@ -634,7 +633,6 @@ start_helper_and_schedule(void *cls,
                                 "exit-gnunet",
                                 start_helper_and_schedule,
                                 message_token,
-                                NULL,
                                 NULL);
 
     GNUNET_free(ipv6addr);
@@ -1189,7 +1187,7 @@ run (void *cls,
      char *const *args,
      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
-  const static struct GNUNET_MESH_MessageHandler handlers[] = {
+  static const struct GNUNET_MESH_MessageHandler handlers[] = {
     {receive_udp_service, GNUNET_MESSAGE_TYPE_SERVICE_UDP, 0},
     {receive_tcp_service, GNUNET_MESSAGE_TYPE_SERVICE_TCP, 0},
     {receive_udp_remote,  GNUNET_MESSAGE_TYPE_REMOTE_UDP, 0},
@@ -1197,7 +1195,7 @@ run (void *cls,
     {NULL, 0, 0}
   };
 
-  const static GNUNET_MESH_ApplicationType apptypes[] =
+  static const GNUNET_MESH_ApplicationType apptypes[] =
     {
       GNUNET_APPLICATION_TYPE_INTERNET_TCP_GATEWAY,
       GNUNET_APPLICATION_TYPE_INTERNET_UDP_GATEWAY,
index 1c7ee798789e7b40c5cb8f9c7b380aef8b257538..100f08c974d6d67dc5b2c102852c93ab570dcd2f 100644 (file)
@@ -111,7 +111,6 @@ start_helper_and_schedule(void *cls,
                                 "vpn-gnunet",
                                 start_helper_and_schedule,
                                 message_token,
-                                NULL,
                                 NULL);
 
     GNUNET_free(ipv6addr);
index 49a33a7bb8fbd73da2788cd79cbd52f1dbdcc3c9..1be01068522c13b487c872f48dc16be851a199b4 100644 (file)
@@ -275,6 +275,9 @@ new_ip6addr_remote (unsigned char *buf, unsigned char *addr, char addrlen)
  */
 void
 process_answer(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tc) {
+    if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+      return;
+
     struct answer_packet* pkt = cls;
     struct answer_packet_list* list;
 
@@ -701,7 +704,7 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg_)
 {
-    const static struct GNUNET_MESH_MessageHandler handlers[] = {
+    static const struct GNUNET_MESH_MessageHandler handlers[] = {
          {receive_udp_back, GNUNET_MESSAGE_TYPE_SERVICE_UDP_BACK, 0},
          {receive_tcp_back, GNUNET_MESSAGE_TYPE_SERVICE_TCP_BACK, 0},
          {receive_udp_back, GNUNET_MESSAGE_TYPE_REMOTE_UDP_BACK, 0},
index 5736df2b104050b9cbf3a3dd4d0b9b6515d7709c..195a79217e1f47e0d2d31ec6ec4d217fd413160d 100644 (file)
@@ -109,8 +109,7 @@ start_helper (const char *ifname,
               const char *ipv4addr,
               const char *ipv4mask, const char *process_name,
               GNUNET_SCHEDULER_Task restart_task,
-              GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls,
-              void *client)
+              GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
 {
   struct GNUNET_VPN_HELPER_Handle *handle =
     GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
index 00eb7db622854843e883beb495cde98ff58f94be..4e8f766119f9606e1f8f436d88c53e2e8e4a50a7 100644 (file)
@@ -92,7 +92,6 @@ struct GNUNET_VPN_HELPER_Handle
  * @param restart_task The task called when the helper dies. Will be called with the handle as cls
  * @param cb A callback for messages from the helper
  * @param cb_cls Closure for the callback
- * @param client client_name for the callback
  *
  * @return A pointer to the new Handle, NULL on error
  */
@@ -105,8 +104,7 @@ struct GNUNET_VPN_HELPER_Handle *start_helper (const char *ifname,
                                                GNUNET_SCHEDULER_Task
                                                restart_task,
                                                GNUNET_SERVER_MessageTokenizerCallback
-                                               cb, void *cb_cls,
-                                               void *client);
+                                               cb, void *cb_cls);
 
 /**
  * @brief Kills the helper, closes the pipe and free()s the handle
index 9ee63bbda50389e17f6cad219b99f3f14054f94a..7b96a180df42c72ede4d315af678f736036bef2a 100644 (file)
@@ -113,6 +113,9 @@ struct receive_dht_cls {
 static void
 hijack (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+
   char port_s[6];
   char *virt_dns;
   struct GNUNET_OS_Process *proc;
@@ -197,8 +200,8 @@ send_answer(void* cls, size_t size, void* buf) {
 
 struct tunnel_cls {
     struct GNUNET_MESH_Tunnel *tunnel GNUNET_PACKED;
-    struct GNUNET_MessageHeader hdr GNUNET_PACKED;
-    struct dns_pkt dns GNUNET_PACKED;
+    struct GNUNET_MessageHeader hdr;
+    struct dns_pkt dns;
 };
 
 struct tunnel_cls *remote_pending[UINT16_MAX];
@@ -704,7 +707,7 @@ receive_query(void *cls,
       }
 
     char* virt_dns;
-    int virt_dns_bytes;
+    unsigned int virt_dns_bytes;
     if (GNUNET_SYSERR ==
         GNUNET_CONFIGURATION_get_value_string (cfg, "vpn", "VIRTDNS",
                                                &virt_dns))
@@ -899,6 +902,8 @@ static void
 cleanup_task (void *cls,
              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
+  GNUNET_assert(0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
+
   unhijack(dnsoutport);
   GNUNET_DHT_disconnect(dht);
 }
@@ -1156,7 +1161,7 @@ run (void *cls,
           {NULL, 0, 0}
     };
 
-  const static GNUNET_MESH_ApplicationType apptypes[] =
+  static const GNUNET_MESH_ApplicationType apptypes[] =
     { GNUNET_APPLICATION_TYPE_INTERNET_RESOLVER,
     GNUNET_APPLICATION_TYPE_END
   };