gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: Fix some signed/uns


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: Fix some signed/unsigned issues, plus some doxygen typos
Date: Mon, 05 Jun 2017 18:20:02 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new f108a56  Fix some signed/unsigned issues, plus some doxygen typos
f108a56 is described below

commit f108a560bf7d755947aac4607bb66c7eb51db801
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jun 5 18:19:59 2017 +0200

    Fix some signed/unsigned issues, plus some doxygen typos
---
 src/backend/taler-merchant-httpd_history.c        | 69 ++++++++++-------------
 src/backend/taler-merchant-httpd_mhd.c            | 20 +++++--
 src/backend/taler-merchant-httpd_track-transfer.c |  5 +-
 src/include/taler_merchantdb_plugin.h             |  8 +--
 src/lib/merchant_api_history.c                    |  1 +
 5 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_history.c 
b/src/backend/taler-merchant-httpd_history.c
index a06259c..53a485b 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -1,6 +1,6 @@
 /*
   This file is part of TALER
-  (C) 2014, 2015, 2016 INRIA
+  (C) 2014, 2015, 2016, 2017 INRIA
 
   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU Affero General Public License as published by the Free 
Software
@@ -93,14 +93,13 @@ MH_handler_history (struct TMH_RequestHandler *rh,
   unsigned int ret;
   unsigned long long seconds;
   struct MerchantInstance *mi;
-  int start = -1;
+  unsigned int start = UINT_MAX;
   unsigned int delta;
 
-  response = json_array (); /*FIXME who decrefs this?*/
+  response = json_array ();
   str = MHD_lookup_connection_value (connection,
                                      MHD_GET_ARGUMENT_KIND,
                                      "date");
-
   date = GNUNET_TIME_absolute_get ();
 
   if (NULL != str)
@@ -113,25 +112,21 @@ MH_handler_history (struct TMH_RequestHandler *rh,
                                              "date");
     }
 
-  date.abs_value_us = seconds * 1000LL * 1000LL;
-
-  if (date.abs_value_us / 1000LL / 1000LL != seconds)
-  {
-    json_decref (response);
-    return TMH_RESPONSE_reply_bad_request (connection,
-                                           TALER_EC_HISTORY_TIMESTAMP_OVERFLOW,
-                                           "Timestamp overflowed");
-  }
-
+    date.abs_value_us = seconds * 1000LL * 1000LL;
 
+    if (date.abs_value_us / 1000LL / 1000LL != seconds)
+    {
+      json_decref (response);
+      return TMH_RESPONSE_reply_bad_request (connection,
+                                             
TALER_EC_HISTORY_TIMESTAMP_OVERFLOW,
+                                             "Timestamp overflowed");
+    }
   }
 
-  mi = TMH_lookup_instance ("default");
   str = MHD_lookup_connection_value (connection,
                                      MHD_GET_ARGUMENT_KIND,
                                      "instance");
-  if (NULL != str)
-    mi = TMH_lookup_instance (str);
+  mi = TMH_lookup_instance (NULL != str ? str : "default");
 
   if (NULL == mi)
   {
@@ -151,10 +146,10 @@ MH_handler_history (struct TMH_RequestHandler *rh,
   {
 
     ret = db->find_contract_terms_history (db->cls,
-                                          str,
-                                          &mi->pubkey,
-                                          pd_cb,
-                                          response);
+                                           str,
+                                           &mi->pubkey,
+                                           &pd_cb,
+                                           response);
     if (GNUNET_SYSERR == ret)
     {
       json_decref (response);
@@ -176,8 +171,7 @@ MH_handler_history (struct TMH_RequestHandler *rh,
                                      "start");
   if (NULL != str)
   {
-    if ((1 != sscanf (str, "%d", &start)) ||
-        0 > start)
+    if (1 != sscanf (str, "%u", &start))
     {
       json_decref (response);
       return TMH_RESPONSE_reply_arg_invalid (connection,
@@ -192,34 +186,33 @@ MH_handler_history (struct TMH_RequestHandler *rh,
 
   if (NULL != str)
   {
-    if ((1 != sscanf (str, "%d", &delta)) ||
-        delta < 0)
+    if (1 != sscanf (str, "%u", &delta))
       return TMH_RESPONSE_reply_arg_invalid (connection,
                                              TALER_EC_PARAMETER_MALFORMED,
                                              "delta");
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Querying history back to %s, start: %d, delta: %d\n",
+              "Querying history back to %s, start: %u, delta: %u\n",
               GNUNET_STRINGS_absolute_time_to_string (date),
               start,
               delta);
 
   if (0 > start)
     ret = db->find_contract_terms_by_date (db->cls,
-                                          date,
-                                          &mi->pubkey,
-                                          delta,
-                                          pd_cb,
-                                          response);
+                                           date,
+                                           &mi->pubkey,
+                                           delta,
+                                           &pd_cb,
+                                           response);
   else
     ret = db->find_contract_terms_by_date_and_range (db->cls,
-                                                    date,
-                                                    &mi->pubkey,
-                                                    start,
-                                                    delta,
-                                                    GNUNET_NO,
-                                                    pd_cb,
-                                                    response);
+                                                     date,
+                                                     &mi->pubkey,
+                                                     start,
+                                                     delta,
+                                                     GNUNET_NO,
+                                                     &pd_cb,
+                                                     response);
   if (GNUNET_SYSERR == ret)
   {
     json_decref (response);
diff --git a/src/backend/taler-merchant-httpd_mhd.c 
b/src/backend/taler-merchant-httpd_mhd.c
index 7e0a6f3..9debb67 100644
--- a/src/backend/taler-merchant-httpd_mhd.c
+++ b/src/backend/taler-merchant-httpd_mhd.c
@@ -108,12 +108,20 @@ TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler 
*rh,
     (void) MHD_add_response_header (response,
                                     MHD_HTTP_HEADER_CONTENT_TYPE,
                                     rh->mime_type);
-  MHD_add_response_header (response,
-                           MHD_HTTP_HEADER_LOCATION,
-                           "http://www.git.taler.net/?p=exchange.git";);
-  ret = MHD_queue_response (connection,
-                            rh->response_code,
-                            response);
+  if (MHD_NO ==
+      MHD_add_response_header (response,
+                               MHD_HTTP_HEADER_LOCATION,
+                               "http://www.git.taler.net/?p=exchange.git";))
+  {
+    GNUNET_break (0);
+    ret = MHD_NO;
+  }
+  else
+  {
+    ret = MHD_queue_response (connection,
+                              rh->response_code,
+                              response);
+  }
   MHD_destroy_response (response);
   return ret;
 }
diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index 5eeff5b..3df9703 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -250,8 +250,9 @@ build_deposits_response (void *cls,
     GNUNET_break_op (0);
     return GNUNET_NO;
   }
-  json_array_append_new (rctx->deposits_response,
-                         element);
+  GNUNET_break (0 ==
+                json_array_append_new (rctx->deposits_response,
+                                       element));
   return GNUNET_YES;
 }
 
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 0a390f5..92f4a53 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -226,8 +226,8 @@ struct TALER_MERCHANTDB_Plugin
    * instance are returned.
    * @param start only rows with serial id less than start are returned.
    * @param nrows only nrows rows are returned.
-   * @param future if set to GNUNET_YES, retrieves rows younger than `date`.
-   * This is tipically used to show live updates on the merchant's backoffice
+   * @param future if set to #GNUNET_YES, retrieves rows younger than `date`.
+   * This is typically used to show live updates on the merchant's backoffice
    * @param cb function to call with transaction data, can be NULL.
    * @param cb_cls closure for @a cb
    * @return numer of found tuples, #GNUNET_SYSERR upon error
@@ -250,8 +250,8 @@ struct TALER_MERCHANTDB_Plugin
    * @param order_id order id used to search for the proposal data
    * @param merchant_pub public key of the merchant using this method
    * @param cb the callback
-   * @param cb_cls closure to pass to the callback
-   * @return GNUNET_YES, GNUNET_NO, GNUNET_SYSERR according to the
+   * @param cb_cls closure to pass to @a cb
+   * @return #GNUNET_YES, #GNUNET_NO, #GNUNET_SYSERR according to the
    * query being successful, unsuccessful, or generated errors.
    */
   int
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index ab4c6f4..c002d0a 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -61,6 +61,7 @@ struct TALER_MERCHANT_HistoryOperation
   struct GNUNET_CURL_Context *ctx;
 };
 
+
 /**
  * Cancel a pending /history request
  *

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]