[v2] examples/ioat: fix stats print

Message ID 20200917130740.207443-1-kevin.laatz@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] examples/ioat: fix stats print |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Kevin Laatz Sept. 17, 2020, 1:07 p.m. UTC
  Currently some of the status string at the top of the stats output is being
cut off. To fix this, the status string array size has been increased.
In addition to this, the "\n" has been moved to the printf, rather than
having it in the last string, in case of future formatting issues due to
truncation.

Bugzilla ID: 536
Fixes: 632bcd9b5d4f ("examples/ioat: print statistics")

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>

---
v2:
  - Increased string array by larger value - ie. up to 255.
  - Moved the "\n" to avoid future formatting issues from truncation.
---
 examples/ioat/ioatfwd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson Sept. 17, 2020, 1:21 p.m. UTC | #1
On Thu, Sep 17, 2020 at 02:07:40PM +0100, Kevin Laatz wrote:
> Currently some of the status string at the top of the stats output is being
> cut off. To fix this, the status string array size has been increased.
> In addition to this, the "\n" has been moved to the printf, rather than
> having it in the last string, in case of future formatting issues due to
> truncation.
> 
> Bugzilla ID: 536
> Fixes: 632bcd9b5d4f ("examples/ioat: print statistics")
> 
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> 
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Thomas Monjalon Oct. 8, 2020, 12:44 p.m. UTC | #2
17/09/2020 15:21, Bruce Richardson:
> On Thu, Sep 17, 2020 at 02:07:40PM +0100, Kevin Laatz wrote:
> > Currently some of the status string at the top of the stats output is being
> > cut off. To fix this, the status string array size has been increased.
> > In addition to this, the "\n" has been moved to the printf, rather than
> > having it in the last string, in case of future formatting issues due to
> > truncation.
> > 
> > Bugzilla ID: 536
> > Fixes: 632bcd9b5d4f ("examples/ioat: print statistics")

+Cc: stable@dpdk.org

> > Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> > 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks
  

Patch

diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index 43a19843ee..4e971dc054 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -168,7 +168,7 @@  print_stats(char *prgname)
 	struct rte_rawdev_xstats_name *names_xstats;
 	uint64_t *xstats;
 	unsigned int *ids_xstats, nb_xstats;
-	char status_string[120]; /* to print at the top of the output */
+	char status_string[255]; /* to print at the top of the output */
 	int status_strlen;
 	int ret;
 
@@ -194,7 +194,7 @@  print_stats(char *prgname)
 		"Rx Queues = %d, ", nb_queues);
 	status_strlen += snprintf(status_string + status_strlen,
 		sizeof(status_string) - status_strlen,
-		"Ring Size = %d\n", ring_size);
+		"Ring Size = %d", ring_size);
 
 	/* Allocate memory for xstats names and values */
 	ret = rte_rawdev_xstats_names_get(
@@ -251,7 +251,7 @@  print_stats(char *prgname)
 
 		memset(&delta_ts, 0, sizeof(struct total_statistics));
 
-		printf("%s", status_string);
+		printf("%s\n", status_string);
 
 		for (i = 0; i < cfg.nb_ports; i++) {
 			port_id = cfg.ports[i].rxtx_port;