ds_put_hex_dump() will output a single trailing whitespace
in the case where its ascii parameter is false. Though somewhat
cosmetic this seems undesirable.

Signed-off-by: Simon Horman <ho...@verge.net.au>

---

I noticed this when preparing another change to allow monitor
to output a hex-dump of packet data which may be used by
tests in the test suite.
---
 lib/dynamic-string.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c
index ba9aa6d..ef55852 100644
--- a/lib/dynamic-string.c
+++ b/lib/dynamic-string.c
@@ -377,9 +377,13 @@ ds_put_hex_dump(struct ds *ds, const void *buf_, size_t 
size,
       ds_put_format(ds, "%08jx  ", (uintmax_t) ROUND_DOWN(ofs, per_line));
       for (i = 0; i < start; i++)
         ds_put_format(ds, "   ");
-      for (; i < end; i++)
-        ds_put_format(ds, "%02hhx%c",
-                buf[i - start], i == per_line / 2 - 1? '-' : ' ');
+      for (; i < end; i++) {
+        ds_put_format(ds, "%02hhx", buf[i - start]);
+        if (i == per_line / 2 - 1)
+            ds_put_char(ds, '-');
+        else if (ascii || i != end - 1)
+            ds_put_char(ds, ' ');
+      }
       if (ascii)
         {
           for (; i < per_line; i++)
-- 
1.8.2.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to