summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-05 18:19:59 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-05 18:19:59 +0200
commitf108a560bf7d755947aac4607bb66c7eb51db801 (patch)
tree89db3dec9a95608f51a85098429271c6349122dd
parenta3017d9fdc5e9bd218f0a7f3ffd665e2453b58db (diff)
downloadmerchant-f108a560bf7d755947aac4607bb66c7eb51db801.tar.gz
merchant-f108a560bf7d755947aac4607bb66c7eb51db801.tar.bz2
merchant-f108a560bf7d755947aac4607bb66c7eb51db801.zip
Fix some signed/unsigned issues, plus some doxygen typos
-rw-r--r--src/backend/taler-merchant-httpd_history.c69
-rw-r--r--src/backend/taler-merchant-httpd_mhd.c20
-rw-r--r--src/backend/taler-merchant-httpd_track-transfer.c5
-rw-r--r--src/include/taler_merchantdb_plugin.h8
-rw-r--r--src/lib/merchant_api_history.c1
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 a06259cf..53a485be 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 7e0a6f34..9debb67a 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 5eeff5b1..3df97036 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 0a390f5b..92f4a534 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 ab4c6f44..c002d0a2 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
*