diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-12-16 17:48:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-12-16 17:48:43 +0100 |
commit | 4ec4cc9bd9afdd4af19cb97018f2fa34ebf5b313 (patch) | |
tree | fae67972e9a1276ee12b25ed7e4840c526a64294 | |
parent | dcbad92e1d934a350a7d5c19a64416a7e8d87576 (diff) | |
download | gnunet-4ec4cc9bd9afdd4af19cb97018f2fa34ebf5b313.tar.gz gnunet-4ec4cc9bd9afdd4af19cb97018f2fa34ebf5b313.zip |
fix
GNUNET_PQ_result_spec_timestamp_nbo
-rw-r--r-- | src/pq/pq_query_helper.c | 54 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 4 |
2 files changed, 3 insertions, 55 deletions
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index f5b4f38a2..ce8ce8f87 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c | |||
@@ -554,62 +554,10 @@ GNUNET_PQ_query_param_absolute_time_nbo ( | |||
554 | } | 554 | } |
555 | 555 | ||
556 | 556 | ||
557 | /** | ||
558 | * Function called to convert input argument into SQL parameters. | ||
559 | * | ||
560 | * @param cls closure | ||
561 | * @param data pointer to input argument | ||
562 | * @param data_len number of bytes in @a data (if applicable) | ||
563 | * @param[out] param_values SQL data to set | ||
564 | * @param[out] param_lengths SQL length data to set | ||
565 | * @param[out] param_formats SQL format data to set | ||
566 | * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays | ||
567 | * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() | ||
568 | * @param scratch_length number of entries left in @a scratch | ||
569 | * @return -1 on error, number of offsets used in @a scratch otherwise | ||
570 | */ | ||
571 | static int | ||
572 | qconv_timestamp (void *cls, | ||
573 | const void *data, | ||
574 | size_t data_len, | ||
575 | void *param_values[], | ||
576 | int param_lengths[], | ||
577 | int param_formats[], | ||
578 | unsigned int param_length, | ||
579 | void *scratch[], | ||
580 | unsigned int scratch_length) | ||
581 | { | ||
582 | const struct GNUNET_TIME_Timestamp *u = data; | ||
583 | struct GNUNET_TIME_Absolute abs; | ||
584 | uint64_t *u_nbo; | ||
585 | |||
586 | GNUNET_break (NULL == cls); | ||
587 | if (1 != param_length) | ||
588 | return -1; | ||
589 | abs = u->abs_time; | ||
590 | if (abs.abs_value_us > INT64_MAX) | ||
591 | abs.abs_value_us = INT64_MAX; | ||
592 | u_nbo = GNUNET_new (uint64_t); | ||
593 | scratch[0] = u_nbo; | ||
594 | *u_nbo = GNUNET_htonll (abs.abs_value_us); | ||
595 | param_values[0] = (void *) u_nbo; | ||
596 | param_lengths[0] = sizeof(uint64_t); | ||
597 | param_formats[0] = 1; | ||
598 | return 1; | ||
599 | } | ||
600 | |||
601 | |||
602 | struct GNUNET_PQ_QueryParam | 557 | struct GNUNET_PQ_QueryParam |
603 | GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x) | 558 | GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x) |
604 | { | 559 | { |
605 | struct GNUNET_PQ_QueryParam res = { | 560 | return GNUNET_PQ_query_param_absolute_time (&x->abs_time); |
606 | .conv = &qconv_timestamp, | ||
607 | .data = x, | ||
608 | .size = sizeof(*x), | ||
609 | .num_params = 1 | ||
610 | }; | ||
611 | |||
612 | return res; | ||
613 | } | 561 | } |
614 | 562 | ||
615 | 563 | ||
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index be7c85ce9..2c11f5202 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -857,12 +857,12 @@ extract_timestamp_nbo (void *cls, | |||
857 | struct GNUNET_TIME_Timestamp t; | 857 | struct GNUNET_TIME_Timestamp t; |
858 | enum GNUNET_GenericReturnValue r; | 858 | enum GNUNET_GenericReturnValue r; |
859 | 859 | ||
860 | r = extract_timestamp (&t, | 860 | r = extract_timestamp (NULL, |
861 | result, | 861 | result, |
862 | row, | 862 | row, |
863 | fname, | 863 | fname, |
864 | dst_size, | 864 | dst_size, |
865 | dst); | 865 | &t); |
866 | if (GNUNET_OK != r) | 866 | if (GNUNET_OK != r) |
867 | return r; | 867 | return r; |
868 | *udst = GNUNET_TIME_timestamp_hton (t); | 868 | *udst = GNUNET_TIME_timestamp_hton (t); |