diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-09 21:17:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-09 21:17:46 +0000 |
commit | e0f0366f920a4681be3ceb60bb86ecc82d14ce54 (patch) | |
tree | 168a4d8e7f00fa1e5077a267924587f220102996 | |
parent | 3420db8ee66c510eb3680ba92a00d810b352b03d (diff) | |
download | gnunet-e0f0366f920a4681be3ceb60bb86ecc82d14ce54.tar.gz gnunet-e0f0366f920a4681be3ceb60bb86ecc82d14ce54.zip |
-handle negative results correctly
-rw-r--r-- | src/scalarproduct/gnunet-scalarproduct.c | 3 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_api.c | 4 | ||||
-rwxr-xr-x | src/scalarproduct/test_scalarproduct_negative.sh | 2 |
3 files changed, 4 insertions, 5 deletions
diff --git a/src/scalarproduct/gnunet-scalarproduct.c b/src/scalarproduct/gnunet-scalarproduct.c index 6f8d03bf3..b3b954211 100644 --- a/src/scalarproduct/gnunet-scalarproduct.c +++ b/src/scalarproduct/gnunet-scalarproduct.c | |||
@@ -138,8 +138,7 @@ requester_callback (void *cls, | |||
138 | { | 138 | { |
139 | ret = 0; | 139 | ret = 0; |
140 | fprintf (stdout, | 140 | fprintf (stdout, |
141 | "%s%s\n", | 141 | "%s\n", |
142 | (0 > gcry_mpi_cmp_ui (result, 0)) ? "-" : "", | ||
143 | buf); | 142 | buf); |
144 | fflush (stdout); | 143 | fflush (stdout); |
145 | } | 144 | } |
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index cae045d62..cd63030bd 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -389,9 +389,9 @@ process_result_message (struct GNUNET_SCALARPRODUCT_ComputationHandle *h, | |||
389 | } | 389 | } |
390 | else | 390 | else |
391 | { | 391 | { |
392 | if (0 < ntohl (msg->range)) | 392 | if (0 < (int32_t) ntohl (msg->range)) |
393 | gcry_mpi_add (result, result, num); | 393 | gcry_mpi_add (result, result, num); |
394 | else if (0 > ntohl (msg->range)) | 394 | else |
395 | gcry_mpi_sub (result, result, num); | 395 | gcry_mpi_sub (result, result, num); |
396 | gcry_mpi_release (num); | 396 | gcry_mpi_release (num); |
397 | } | 397 | } |
diff --git a/src/scalarproduct/test_scalarproduct_negative.sh b/src/scalarproduct/test_scalarproduct_negative.sh index a7514cf5e..eb9ead4bf 100755 --- a/src/scalarproduct/test_scalarproduct_negative.sh +++ b/src/scalarproduct/test_scalarproduct_negative.sh | |||
@@ -39,6 +39,6 @@ then | |||
39 | echo "OK" | 39 | echo "OK" |
40 | exit 0 | 40 | exit 0 |
41 | else | 41 | else |
42 | echo "Result $RESULT NOTOK" | 42 | echo "Result $RESULT, expected $EXPECTED NOTOK" |
43 | exit 1 | 43 | exit 1 |
44 | fi | 44 | fi |