examples: gnrc_networking uses variable it hasn't access to anymore
This commit is contained in:
parent
69b1ef3a41
commit
634adf37d8
@ -51,12 +51,15 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
|||||||
|
|
||||||
for (unsigned int i = 0; i < num; i++) {
|
for (unsigned int i = 0; i < num; i++) {
|
||||||
gnrc_pktsnip_t *payload, *udp, *ip;
|
gnrc_pktsnip_t *payload, *udp, *ip;
|
||||||
|
unsigned payload_size;
|
||||||
/* allocate payload */
|
/* allocate payload */
|
||||||
payload = gnrc_pktbuf_add(NULL, data, strlen(data), GNRC_NETTYPE_UNDEF);
|
payload = gnrc_pktbuf_add(NULL, data, strlen(data), GNRC_NETTYPE_UNDEF);
|
||||||
if (payload == NULL) {
|
if (payload == NULL) {
|
||||||
puts("Error: unable to copy data to packet buffer");
|
puts("Error: unable to copy data to packet buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* store size for output */
|
||||||
|
payload_size = (unsigned)payload->size;
|
||||||
/* allocate UDP header, set source port := destination port */
|
/* allocate UDP header, set source port := destination port */
|
||||||
udp = gnrc_udp_hdr_build(payload, port, port);
|
udp = gnrc_udp_hdr_build(payload, port, port);
|
||||||
if (udp == NULL) {
|
if (udp == NULL) {
|
||||||
@ -77,8 +80,10 @@ static void send(char *addr_str, char *port_str, char *data, unsigned int num,
|
|||||||
gnrc_pktbuf_release(ip);
|
gnrc_pktbuf_release(ip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("Success: send %u byte to [%s]:%u\n", (unsigned)payload->size,
|
/* access to `payload` was implicitly given up with the send operation above
|
||||||
addr_str, port);
|
* => use temporary variable for output */
|
||||||
|
printf("Success: send %u byte to [%s]:%u\n", payload_size, addr_str,
|
||||||
|
port);
|
||||||
xtimer_usleep(delay);
|
xtimer_usleep(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user