aboutsummaryrefslogtreecommitdiff
path: root/test_brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-09-21 13:50:20 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-09-21 13:50:20 +0200
commitb31da162a85e993e8bb4287db9b5d8bc6ef2e53f (patch)
treefca58833e5fd19b750ad1aa165661f0bc5200d1b /test_brandt.c
parent658cb968460233a04e77d37558275a894e9d345c (diff)
coding style fixes
Diffstat (limited to 'test_brandt.c')
-rw-r--r--test_brandt.c104
1 files changed, 53 insertions, 51 deletions
diff --git a/test_brandt.c b/test_brandt.c
index fb0f2c9..077f6f1 100644
--- a/test_brandt.c
+++ b/test_brandt.c
@@ -30,19 +30,18 @@
#include "util.h"
-struct msg
-{
- uint16_t sender;
- uint16_t receiver;
- void *buf;
- size_t buf_len;
+struct msg {
+ uint16_t sender;
+ uint16_t receiver;
+ void *buf;
+ size_t buf_len;
};
-static uint16_t *id;
+static uint16_t *id;
static struct BRANDT_Auction **ad;
-static uint16_t bidders = 3;
-static uint16_t prizes = 8;
+static uint16_t bidders = 3;
+static uint16_t prizes = 8;
static void
@@ -50,7 +49,7 @@ bidder_start (void *arg)
{
uint16_t i = *(uint16_t *)arg;
- weprintf("starting bidder %d", i);
+ weprintf ("starting bidder %d", i);
BRANDT_bidder_start (ad[i], i, bidders);
}
@@ -58,10 +57,11 @@ bidder_start (void *arg)
static void
transfer_message (void *arg)
{
- struct msg *m = (struct msg *)arg;
+ struct msg *m = (struct msg *)arg;
struct msg_head *h = (struct msg_head *)m->buf;
- weprintf("xfer msg %d %x from %d to %d", ntohl(h->msg_type), arg, m->sender, m->receiver);
+ weprintf ("xfer msg %d %x from %d to %d", ntohl (
+ h->msg_type), arg, m->sender, m->receiver);
BRANDT_got_message (ad[m->receiver], m->sender, m->buf, m->buf_len);
free (arg);
}
@@ -71,6 +71,7 @@ static uint16_t
cb_start (void *auction_closure)
{
uint16_t *s = (uint16_t *)auction_closure;
+
if (!s || bidders != *s)
{
weprintf ("start callback called from bidder");
@@ -89,7 +90,7 @@ cb_broadcast (void *auction_closure,
const void *msg,
size_t msg_len)
{
- uint16_t *s = (uint16_t *)auction_closure;
+ uint16_t *s = (uint16_t *)auction_closure;
struct msg *m;
for (uint16_t i = 0; i <= bidders; i++)
@@ -113,7 +114,7 @@ cb_unicast (void *auction_closure,
const void *msg,
size_t msg_len)
{
- uint16_t *s = (uint16_t *)auction_closure;
+ uint16_t *s = (uint16_t *)auction_closure;
struct msg *m;
m = GNUNET_new (struct msg);
@@ -139,37 +140,38 @@ cb_result (void *auction_closure,
weprintf ("result determined by agent %d: none", *s);
for (uint16_t i = 0; i < results_len; i++)
- weprintf ("result determined by agent %d: bidder %d got status %d with price %d",
- *s,
- results[i].bidder,
- results[i].status,
- results[i].price);
+ weprintf (
+ "result determined by agent %d: bidder %d got status %d with price %d",
+ *s,
+ results[i].bidder,
+ results[i].status,
+ results[i].price);
}
static void
run_new_join (void *arg)
{
- int *ret = arg;
- const char description[] = "test description for test_new_join";
- void *desc;
- size_t desc_len;
+ int *ret = arg;
+ const char description[] = "test description for test_new_join";
+ void *desc;
+ size_t desc_len;
ad = GNUNET_new_array (bidders + 1, struct BRANDT_Auction *);
ad[bidders] = BRANDT_new (&cb_result,
- &cb_broadcast,
- &cb_start,
- &id[bidders],
- &desc,
- &desc_len,
- description,
- sizeof (description),
- GNUNET_TIME_absolute_get (),
- GNUNET_TIME_UNIT_MINUTES,
- prizes, /* amount of possible prizes */
- 0, /* m */
- 1); /* outcome public */
+ &cb_broadcast,
+ &cb_start,
+ &id[bidders],
+ &desc,
+ &desc_len,
+ description,
+ sizeof (description),
+ GNUNET_TIME_absolute_get (),
+ GNUNET_TIME_UNIT_MINUTES,
+ prizes, /* amount of possible prizes */
+ 0, /* m */
+ 1); /* outcome public */
if (!ad[bidders])
{
weprintf ("BRANDT_new() failed.");
@@ -179,14 +181,14 @@ run_new_join (void *arg)
for (uint16_t i = 0; i < bidders; i++)
{
ad[i] = BRANDT_join (&cb_result,
- &cb_broadcast,
- &cb_unicast,
- &id[i],
- desc,
- desc_len,
- description,
- sizeof (description),
- 3); /* bid */
+ &cb_broadcast,
+ &cb_unicast,
+ &id[i],
+ desc,
+ desc_len,
+ description,
+ sizeof (description),
+ 3); /* bid */
if (!ad[i])
{
weprintf ("BRANDT_join() failed.");
@@ -194,14 +196,14 @@ run_new_join (void *arg)
}
if (ad[bidders]->k != ad[i]->k ||
- ad[bidders]->m != ad[i]->m ||
- ad[bidders]->outcome_public != ad[i]->outcome_public ||
- ad[bidders]->time_start.abs_value_us
- != ad[i]->time_start.abs_value_us ||
- ad[bidders]->time_round.rel_value_us
- != ad[i]->time_round.rel_value_us ||
- !ad[bidders]->seller_mode || /* todo: split out */
- ad[i]->seller_mode)
+ ad[bidders]->m != ad[i]->m ||
+ ad[bidders]->outcome_public != ad[i]->outcome_public ||
+ ad[bidders]->time_start.abs_value_us
+ != ad[i]->time_start.abs_value_us ||
+ ad[bidders]->time_round.rel_value_us
+ != ad[i]->time_round.rel_value_us ||
+ !ad[bidders]->seller_mode || /* todo: split out */
+ ad[i]->seller_mode)
{
weprintf ("error/mismatch in basic auction data");
_exit (1);