- fix coverity
[oweals/gnunet.git] / src / scalarproduct / gnunet-service-scalarproduct_bob.c
index 6d41668e35be931a5a143f42a348b9d967547497..d0a622a36a3d9567675793fe217a50b49b99f335 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2013, 2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2013, 2014 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
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
  */
 /**
  * @file scalarproduct/gnunet-service-scalarproduct_bob.c
@@ -139,11 +139,6 @@ struct BobServiceSession
    */
   struct CadetIncomingSession *cadet;
 
-  /**
-   * The computed scalar
-   */
-  gcry_mpi_t product;
-
   /**
    * How many elements will be supplied in total from the client.
    */
@@ -408,11 +403,6 @@ destroy_service_session (struct BobServiceSession *s)
     GNUNET_free (s->r_prime);
     s->r_prime = NULL;
   }
-  if (NULL != s->product)
-  {
-    gcry_mpi_release (s->product);
-    s->product = NULL;
-  }
   GNUNET_free (s);
 }
 
@@ -470,6 +460,8 @@ prepare_client_end_notification (struct BobServiceSession *session)
   struct ClientResponseMessage *msg;
   struct GNUNET_MQ_Envelope *e;
 
+  if (NULL == session->client_mq)
+    return; /* no client left to be notified */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Sending session-end notification with status %d to client for session %s\n",
               session->status,
@@ -507,12 +499,6 @@ cb_channel_destruction (void *cls,
               "Peer disconnected, terminating session %s with peer %s\n",
               GNUNET_h2s (&in->session_id),
               GNUNET_i2s (&in->peer));
-  if (NULL != in->cadet_mq)
-  {
-    GNUNET_MQ_destroy (in->cadet_mq);
-    in->cadet_mq = NULL;
-  }
-  in->channel = NULL;
   if (NULL != (s = in->s))
   {
     if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
@@ -521,6 +507,12 @@ cb_channel_destruction (void *cls,
       prepare_client_end_notification (s);
     }
   }
+  if (NULL != in->cadet_mq)
+  {
+    GNUNET_MQ_destroy (in->cadet_mq);
+    in->cadet_mq = NULL;
+  }
+  in->channel = NULL;
   destroy_cadet_session (in);
 }
 
@@ -1144,11 +1136,6 @@ handle_alices_computation_request (void *cls,
   struct BobServiceSession *s;
   const struct ServiceRequestMessage *msg;
 
-  if (ntohs (message->size) != sizeof (struct ServiceRequestMessage))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_SYSERR;
-  }
   msg = (const struct ServiceRequestMessage *) message;
   if (GNUNET_YES == in->in_map)
   {
@@ -1274,8 +1261,6 @@ GSS_handle_bob_client_message_multipart (void *cls,
   elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1];
   for (i = 0; i < contained_count; i++)
   {
-    if (0 == GNUNET_ntohll (elements[i].value))
-      continue;
     elem = GNUNET_new (struct GNUNET_SCALARPRODUCT_Element);
     memcpy (elem,
             &elements[i],
@@ -1450,11 +1435,9 @@ GSS_handle_bob_client_message (void *cls,
  * Task run during shutdown.
  *
  * @param cls unused
- * @param tc unused
  */
 static void
-shutdown_task (void *cls,
-               const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Shutting down, initiating cleanup.\n");
@@ -1489,8 +1472,7 @@ handle_client_disconnect (void *cls,
   if (NULL == client)
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Client disconnected from us.\n",
-              client);
+              "Client disconnected from us.\n");
   s = GNUNET_SERVER_client_get_user_context (client,
                                              struct BobServiceSession);
   if (NULL == s)
@@ -1567,9 +1549,8 @@ run (void *cls,
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
 }