summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2015-09-17 13:41:38 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2015-09-18 13:00:47 +0200
commit5ec384676ae938dbe6281c98ebb26b821cdf8fea (patch)
treed9d7af01ddf5d205b9cf07bee0f7409ccb136240
parent751df6363cb23a15f9ac6f927659410ef8dcca01 (diff)
downloadcanutils-5ec384676ae938dbe6281c98ebb26b821cdf8fea.tar.gz
cansequence: do_receive: move variables into loop
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--src/cansequence.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cansequence.c b/src/cansequence.c
index 11b429e..1e1af29 100644
--- a/src/cansequence.c
+++ b/src/cansequence.c
@@ -87,12 +87,10 @@ static void do_receive()
.msg_iovlen = 1,
.msg_control = &ctrlmsg,
};
- struct cmsghdr *cmsg;
const int dropmonitor_on = 1;
bool sequence_init = true;
unsigned int seq_wrap = 0;
uint8_t sequence = 0;
- ssize_t nbytes;
if (setsockopt(s, SOL_SOCKET, SO_RXQ_OVFL,
&dropmonitor_on, sizeof(dropmonitor_on)) < 0) {
@@ -106,11 +104,13 @@ static void do_receive()
}
while ((infinite || loopcount--) && running) {
+ ssize_t nbytes;
+
msg.msg_iov[0].iov_len = sizeof(frame);
msg.msg_controllen = sizeof(ctrlmsg);
msg.msg_flags = 0;
- nbytes = recvmsg(s, &msg, 0);
+ nbytes = recvmsg(s, &msg, 0);
if (nbytes < 0) {
perror("read()");
exit(EXIT_FAILURE);
@@ -125,6 +125,7 @@ static void do_receive()
printf("received frame. sequence number: %d\n", frame.data[0]);
if (frame.data[0] != sequence) {
+ struct cmsghdr *cmsg;
uint32_t overflows = 0;
drop_count++;