From 7134da0915cf56c7eeff2cd22b6b3ddeff5e7e33 Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sat, 5 Oct 2013 21:26:28 +0200
Subject: [PATCH] Rearranged some expressions to avoid triggering a cc65 bug.
---
apps/shell/shell-netperf.c | 8 ++++----
apps/shell/shell-rime-debug-runicast.c | 2 +-
apps/shell/shell-rime-debug.c | 4 ++--
apps/shell/shell-rime-ping.c | 6 +++---
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/apps/shell/shell-netperf.c b/apps/shell/shell-netperf.c
index 1fa4643e2..2250488c8 100644
--- a/apps/shell/shell-netperf.c
+++ b/apps/shell/shell-netperf.c
@@ -187,8 +187,8 @@ print_local_stats(struct stats *s)
printf(" Total transfer time: %lu.%02lu seconds, %lu.%02lu packets/second\n",
(s->end - s->start) / CLOCK_SECOND,
((10 * (s->end - s->start)) / CLOCK_SECOND) % 10,
- ((1UL * CLOCK_SECOND * s->sent) / (s->end - s->start)),
- (((100UL * CLOCK_SECOND * s->sent) / (s->end - s->start)) % 100));
+ ((s->sent * 1UL * CLOCK_SECOND) / (s->end - s->start)),
+ (((s->sent * 100UL * CLOCK_SECOND) / (s->end - s->start)) % 100));
printf(" Average round-trip-time: %lu ms (%lu + %lu)\n",
(1000 * (s->total_rx_latency + s->total_tx_latency) / s->received) /
@@ -206,8 +206,8 @@ print_local_stats(struct stats *s)
((10000 * (s->power.tx - s->power0.tx))/total_time) % 100);
printf(" Packets received: %d.%lu%%, %d of %d\n",
- 100 * s->received / s->sent,
- (10000L * s->received / s->sent) % 10,
+ s->received * 100 / s->sent,
+ (s->received * 10000L / s->sent) % 10,
s->received, s->sent);
}
/*---------------------------------------------------------------------------*/
diff --git a/apps/shell/shell-rime-debug-runicast.c b/apps/shell/shell-rime-debug-runicast.c
index 1ab08cc23..7c2b55262 100644
--- a/apps/shell/shell-rime-debug-runicast.c
+++ b/apps/shell/shell-rime-debug-runicast.c
@@ -141,7 +141,7 @@ recv_ruc(struct runicast_conn *c, const rimeaddr_t *from, uint8_t seqno)
printf("runicast message received from %d.%d, latency %lu ms, seqno %d, data '%.*s'\n",
from->u8[0], from->u8[1],
- (1000L * latency) / RTIMER_ARCH_SECOND,
+ (latency * 1000L) / RTIMER_ARCH_SECOND,
seqno,
packetbuf_datalen() - COLLECT_MSG_HDRSIZE,
msg->data);
diff --git a/apps/shell/shell-rime-debug.c b/apps/shell/shell-rime-debug.c
index fd83c0723..aa1f0c9fc 100644
--- a/apps/shell/shell-rime-debug.c
+++ b/apps/shell/shell-rime-debug.c
@@ -129,7 +129,7 @@ recv_broadcast(struct broadcast_conn *c, const rimeaddr_t *from)
printf("broadcast message received from %d.%d, latency %lu ms, data '%.*s'\n",
from->u8[0], from->u8[1],
- (1000L * latency) / RTIMER_ARCH_SECOND,
+ (latency * 1000L) / RTIMER_ARCH_SECOND,
packetbuf_datalen() - COLLECT_MSG_HDRSIZE,
msg->data);
}
@@ -201,7 +201,7 @@ recv_uc(struct unicast_conn *c, const rimeaddr_t *from)
printf("unicast message received from %d.%d, latency %lu ms, data '%.*s'\n",
from->u8[0], from->u8[1],
- (1000L * latency) / RTIMER_ARCH_SECOND,
+ (latency * 1000L) / RTIMER_ARCH_SECOND,
packetbuf_datalen() - COLLECT_MSG_HDRSIZE,
msg->data);
}
diff --git a/apps/shell/shell-rime-ping.c b/apps/shell/shell-rime-ping.c
index d146c8cda..99c68e6fa 100644
--- a/apps/shell/shell-rime-ping.c
+++ b/apps/shell/shell-rime-ping.c
@@ -145,9 +145,9 @@ recv_mesh(struct mesh_conn *c, const rimeaddr_t *from, uint8_t hops)
pingrecvtime = rtimer_arch_now();
#endif
snprintf(buf, sizeof(buf), "%lu ms (%lu + %lu), %d hops.",
- (1000L * (pingrecvtime - ping.pingtime)) / RTIMER_ARCH_SECOND,
- (1000L * (ping.pongtime - ping.pingtime)) / RTIMER_ARCH_SECOND,
- (1000L * (pingrecvtime - ping.pongtime)) / RTIMER_ARCH_SECOND,
+ ((pingrecvtime - ping.pingtime) * 1000L) / RTIMER_ARCH_SECOND,
+ ((ping.pongtime - ping.pingtime) * 1000L) / RTIMER_ARCH_SECOND,
+ ((pingrecvtime - ping.pongtime) * 1000L) / RTIMER_ARCH_SECOND,
hops);
shell_output_str(&rime_ping_command,