summaryrefslogtreecommitdiffstats
path: root/extras/libmemif/examples/icmp_responder
diff options
context:
space:
mode:
Diffstat (limited to 'extras/libmemif/examples/icmp_responder')
-rw-r--r--extras/libmemif/examples/icmp_responder/main.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/extras/libmemif/examples/icmp_responder/main.c b/extras/libmemif/examples/icmp_responder/main.c
index 2e85d0320d5..df94da34478 100644
--- a/extras/libmemif/examples/icmp_responder/main.c
+++ b/extras/libmemif/examples/icmp_responder/main.c
@@ -290,7 +290,6 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
memif_connection_t *c = &memif_connection;
int err;
uint16_t rx;
- uint16_t fb = 0;
/* receive data from shared memory buffers */
err = memif_rx_burst (c->conn, qid, c->rx_bufs, MAX_MEMIF_BUFS, &rx);
c->rx_buf_num += rx;
@@ -314,10 +313,14 @@ on_interrupt (memif_conn_handle_t conn, void *private_ctx, uint16_t qid)
/* mark memif buffers and shared memory buffers as free */
err = memif_refill_queue (c->conn, qid, rx, 0);
- c->rx_buf_num -= fb;
+ /*
+ * In this example we can assert that c->conn points to valid connection
+ * and 'rx <= c->rx_buf_num'.
+ */
+ c->rx_buf_num -= rx;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
- fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
+ rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
icmpr_tx_burst (c->tx_qid);
@@ -327,9 +330,9 @@ error:
err = memif_refill_queue (c->conn, qid, rx, 0);
if (err != MEMIF_ERR_SUCCESS)
INFO ("memif_buffer_free: %s", memif_strerror (err));
- c->rx_buf_num -= fb;
+ c->rx_buf_num -= rx;
DBG ("freed %d buffers. %u/%u alloc/free buffers",
- fb, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
+ rx, c->rx_buf_num, MAX_MEMIF_BUFS - c->rx_buf_num);
return 0;
}