improve scoping, fix indentation, fix type

This commit is contained in:
Christian Grothoff 2019-10-29 18:04:04 +01:00
parent 36efe024f5
commit afbcf8f42c
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 46 additions and 42 deletions

View File

@ -64,9 +64,9 @@ struct HistoryState
/** /**
* How many rows we want in the result, _at most_. In * How many rows we want in the result, _at most_. In
* the case of /history-range, we fake this value with * the case of /history-range, we fake this value with
* INT64_MAX. * UINT64_MAX.
*/ */
long long num_results; unsigned long long num_results;
/** /**
* Handle to a pending "history" operation. * Handle to a pending "history" operation.
@ -159,6 +159,10 @@ history_traits (void *cls,
const char *trait, const char *trait,
unsigned int index) unsigned int index)
{ {
(void) cls;
(void) ret;
(void) trait;
(void) index;
/* Must define this function because some callbacks /* Must define this function because some callbacks
* look for certain traits on _all_ the commands. */ * look for certain traits on _all_ the commands. */
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -184,7 +188,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is,
current_cmd = &is->commands[off]; current_cmd = &is->commands[off];
TALER_LOG_INFO ("Is `%s' rejected?\n", TALER_LOG_INFO ("Is `%s' rejected?\n",
current_cmd->label); current_cmd->label);
for (unsigned int i = 0; i<is->ip; i++) for (int i = 0; i<is->ip; i++)
{ {
const struct TALER_TESTING_Command *c = &is->commands[i]; const struct TALER_TESTING_Command *c = &is->commands[i];
@ -290,13 +294,10 @@ build_history_hit_limit (uint64_t total,
TALER_TESTING_get_trait_absolute_time (pos, TALER_TESTING_get_trait_absolute_time (pos,
0, 0,
&timestamp)); &timestamp));
GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
hs->end_date.abs_value_us); hs->end_date.abs_value_us);
return timestamp->abs_value_us >= hs->end_date.abs_value_us; return timestamp->abs_value_us >= hs->end_date.abs_value_us;
} }
return total >= hs->num_results; return total >= hs->num_results;
} }
@ -714,6 +715,7 @@ compute_result_count (struct TALER_TESTING_Interpreter *is)
return total; return total;
} }
/** /**
* Check that the "/history" response matches the * Check that the "/history" response matches the
* CMD whose offset in the list of CMDs is @a off. * CMD whose offset in the list of CMDs is @a off.
@ -1017,8 +1019,7 @@ history_range_run (void *cls,
* @param cmd the command which is being cleaned up. * @param cmd the command which is being cleaned up.
*/ */
static void static void
history_cleanup history_cleanup (void *cls,
(void *cls,
const struct TALER_TESTING_Command *cmd) const struct TALER_TESTING_Command *cmd)
{ {
struct HistoryState *hs = cls; struct HistoryState *hs = cls;
@ -1028,7 +1029,6 @@ history_cleanup
TALER_LOG_WARNING ("/history did not complete\n"); TALER_LOG_WARNING ("/history did not complete\n");
TALER_BANK_history_cancel (hs->hh); TALER_BANK_history_cancel (hs->hh);
} }
GNUNET_free (hs); GNUNET_free (hs);
} }
@ -1041,13 +1041,12 @@ history_cleanup
* operation. * operation.
* @param account_no bank account number to ask the history for. * @param account_no bank account number to ask the history for.
* @param direction which direction this operation is interested. * @param direction which direction this operation is interested.
* @param ascending if GNUNET_YES, the bank will return the rows * @param ascending if #GNUNET_YES, the bank will return the rows
* in ascending (= chronological) order. * in ascending (= chronological) order.
* @param start_row_reference reference to a command that can * @param start_row_reference reference to a command that can
* offer a row identifier, to be used as the starting row * offer a row identifier, to be used as the starting row
* to accept in the result. * to accept in the result.
* @param num_result how many rows we want in the result. * @param num_results how many rows we want in the result.
*
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
@ -1058,7 +1057,7 @@ TALER_TESTING_cmd_bank_history
enum TALER_BANK_Direction direction, enum TALER_BANK_Direction direction,
unsigned int ascending, unsigned int ascending,
const char *start_row_reference, const char *start_row_reference,
long long num_results) unsigned long long num_results)
{ {
struct HistoryState *hs; struct HistoryState *hs;
@ -1072,6 +1071,7 @@ TALER_TESTING_cmd_bank_history
hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS; hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS;
hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS; hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS;
{
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.label = label, .label = label,
.cls = hs, .cls = hs,
@ -1081,6 +1081,7 @@ TALER_TESTING_cmd_bank_history
}; };
return cmd; return cmd;
}
} }
@ -1124,6 +1125,7 @@ TALER_TESTING_cmd_bank_history_range
hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS; hs->start_date = GNUNET_TIME_UNIT_FOREVER_ABS;
hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS; hs->end_date = GNUNET_TIME_UNIT_FOREVER_ABS;
{
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.label = label, .label = label,
.cls = hs, .cls = hs,
@ -1133,6 +1135,7 @@ TALER_TESTING_cmd_bank_history_range
}; };
return cmd; return cmd;
}
} }
@ -1173,6 +1176,7 @@ TALER_TESTING_cmd_bank_history_range_with_dates
hs->start_date = start_date; hs->start_date = start_date;
hs->end_date = end_date; hs->end_date = end_date;
{
struct TALER_TESTING_Command cmd = { struct TALER_TESTING_Command cmd = {
.label = label, .label = label,
.cls = hs, .cls = hs,
@ -1182,6 +1186,7 @@ TALER_TESTING_cmd_bank_history_range_with_dates
}; };
return cmd; return cmd;
}
} }
/* end of testing_api_cmd_history.c */ /* end of testing_api_cmd_history.c */

View File

@ -108,13 +108,12 @@ TALER_TESTING_has_in_name (const char *prog,
* operation. * operation.
* @param account_no bank account number to ask the history for. * @param account_no bank account number to ask the history for.
* @param direction which direction this operation is interested * @param direction which direction this operation is interested
* @param ascending if GNUNET_YES, it ask the bank to return results * @param ascending if #GNUNET_YES, it ask the bank to return results
* in chronological order. * in chronological order.
* @param start_row_reference reference to a command that can * @param start_row_reference reference to a command that can
* offer a row identifier, to be used as the starting row * offer a row identifier, to be used as the starting row
* to accept in the result. * to accept in the result.
* @param num_result how many rows we want in the result. * @param num_results how many rows we want in the result.
*
* @return the command. * @return the command.
*/ */
struct TALER_TESTING_Command struct TALER_TESTING_Command
@ -124,7 +123,7 @@ TALER_TESTING_cmd_bank_history (const char *label,
enum TALER_BANK_Direction direction, enum TALER_BANK_Direction direction,
unsigned int ascending, unsigned int ascending,
const char *start_row_reference, const char *start_row_reference,
long long num_results); unsigned long long num_results);
/** /**