libmemif: icmp-responder example buffer management fix

Type: fix

Change-Id: Ieeb763f282ee929a121585747119f458c00056ae
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
diff --git a/extras/libmemif/examples/icmp_responder/main.c b/extras/libmemif/examples/icmp_responder/main.c
index 2e85d03..df94da3 100644
--- a/extras/libmemif/examples/icmp_responder/main.c
+++ b/extras/libmemif/examples/icmp_responder/main.c
@@ -290,7 +290,6 @@
   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 @@
 
   /* 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 @@
   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;
 }