coverity fixes
authorMatthias Wachs <wachs@net.in.tum.de>
Tue, 18 Oct 2011 16:31:08 +0000 (16:31 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Tue, 18 Oct 2011 16:31:08 +0000 (16:31 +0000)
src/ats/test_ats_api_bandwidth_consumption.c
src/transport/plugin_transport_http_client.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_udp.c
src/transport/test_transport_api.c
src/transport/test_transport_startonly.c
src/transport/transport-testing.c

index 05a3e257a4d6729b375cf87bb48a5eafc9a0335c..d2a7b53dc07597fe2a9314facab12d63c324e866 100644 (file)
@@ -258,6 +258,8 @@ check (void *cls, char *const *args, const char *cfgfile,
     ret = GNUNET_SYSERR;
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init ATS performance\n");
     end_badly(NULL, NULL);
+    GNUNET_free (p);
+    GNUNET_free (addr);
     return;
   }
 
index c116a9d778810f58692a40dff8fd203b37bfb159..a2024953c9498afe33eed9cf6651f5bd62eab87c 100644 (file)
@@ -405,7 +405,6 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls)
                              GNUNET_NO);
 
   return len;
-  client_wake_up(NULL,NULL);
 }
 
 /**
index 4ae0df35a65983310860d1a280a200e784f9674c..c1c35d4bae1ad3e12e119032953045856964a075 100644 (file)
@@ -145,7 +145,7 @@ server_load_certificate (struct Plugin *plugin)
       GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name,
                                                "CERT_FILE", &cert_file))
   {
-    cert_file = "https_cert.crt";
+    GNUNET_asprintf(&cert_file, "%s", "https_cert.crt");
   }
 
   /* read key & certificates from file */
index f4a806723880291498a87d9523f4c24a5c019376..ddb6187e5893024c578ae4c35d562c27ef727018 100644 (file)
@@ -681,11 +681,14 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
     }
   }
 //session_invalid:
+  if ((addr == NULL) && (addrlen == 0))
+    return GNUNET_SYSERR;
   peer_session = create_session (plugin, target, addr, addrlen, cont, cont_cls);
   if (peer_session == NULL)
   {
     if (cont != NULL)
       cont (cont_cls, target, GNUNET_SYSERR);
+    return GNUNET_SYSERR;;
   }
 
   /* Message */
index 81a0b39e13ccdb06dbb171e802fd29bd53cdfdf1..6b6cc0c0e62edc259a59db1a5002b1a5e6f820bc 100644 (file)
@@ -150,6 +150,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
     t = p1;
   if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
     t = p2;
+  GNUNET_assert (t != NULL);
 
   char * ps = strdup (GNUNET_i2s(&p->id));
 
@@ -245,6 +246,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
     t = p1;
   if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
     t = p2;
+  GNUNET_assert (t!=NULL);
 
   char * ps = strdup (GNUNET_i2s(&p->id));
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
index 721154f9e63309885786f02c9f814f2b49c03236..1349a0c4dbe5892ab1944187fd414b33616707c9 100644 (file)
@@ -150,7 +150,7 @@ run (void *cls, char *const *args, const char *cfgfile,
       fprintf (stderr, "..%i", i);
   }
 
-  GNUNET_TRANSPORT_TESTING_init (tth);
+  tth = GNUNET_TRANSPORT_TESTING_init ();
 
   fprintf (stderr, "\n");
   end ();
index 0079bc42196412daa5fb1303df68aaca2920b145..5d0e990f7fd72ff620e8266d16822bdebd193815 100644 (file)
@@ -91,6 +91,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
 {
   struct PeerContext *p = cls;
   /* Find PeerContext */
+  GNUNET_assert (p != 0);
   GNUNET_assert (p->tth != NULL);
   struct PeerContext * p2 = find_peer_context (p->tth, peer);
 
@@ -136,8 +137,15 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *p = cls;
   /* Find PeerContext */
-  GNUNET_assert (p->tth != NULL);
-  struct PeerContext * p2 = find_peer_context (p->tth, peer);
+  int no = 0;
+  struct PeerContext * p2 = NULL;
+
+  if (p != NULL)
+  {
+    GNUNET_assert (p->tth != NULL);
+    p2 = find_peer_context (p->tth, peer);
+    no = p->no;
+  }
 
   char * p2_s;
   if (p2 != NULL)
@@ -147,7 +155,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
       "Peers %s disconnected from peer %u (`%s')\n",
       p2_s,
-      p->no, GNUNET_i2s (&p->id));
+      no , GNUNET_i2s (&p->id));
   GNUNET_free (p2_s);
 
   if (p == NULL)