lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 May 2013 20:55:51 +0300
From:	"Yuval Mintz" <yuvalmin@...adcom.com>
To:	bhutchings@...arflare.com, netdev@...r.kernel.org
cc:	eilong@...adcom.com, "Yuval Mintz" <yuvalmin@...adcom.com>
Subject: [PATCH] Ethtool: Beautify private flags print

When printing the private flags of the device, align all strings
to have the same length.

Signed-off-by: Yuval Mintz <yuvalmin@...adcom.com>
---
 ethtool.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 8cc10b5..1244c74 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3445,6 +3445,7 @@ static int do_gprivflags(struct cmd_context *ctx)
 	struct ethtool_gstrings *strings;
 	struct ethtool_value flags;
 	unsigned int i;
+	int max_len = 0, cur_len;
 
 	if (ctx->argc != 0)
 		exit_bad_args();
@@ -3472,11 +3473,28 @@ static int do_gprivflags(struct cmd_context *ctx)
 		return 1;
 	}
 
+	/* Find longest string and align all strings accordingly */
+	for (i = 0; i < strings->len; i++) {
+		cur_len = strlen((const char*)strings->data +
+					      i * ETH_GSTRING_LEN);
+		if (cur_len > max_len)
+			max_len = cur_len;
+	}
+
 	printf("Private flags for %s:\n", ctx->devname);
-	for (i = 0; i < strings->len; i++)
-		printf("%s: %s\n",
-		       (const char *)strings->data + i * ETH_GSTRING_LEN,
-		       (flags.data & (1U << i)) ? "on" : "off");
+	for (i = 0; i < strings->len; i++) {
+		int j;
+
+		printf("%s", (const char *)strings->data +
+					   i * ETH_GSTRING_LEN);
+
+		cur_len = strlen((const char*)strings->data +
+					      i * ETH_GSTRING_LEN);
+		for (j = 0; j < max_len - cur_len; j++)
+			printf(" ");
+
+		printf(": %s\n", (flags.data & (1U << i)) ? "on" : "off");
+	}
 
 	return 0;
 }
-- 
1.8.1.227.g44fe835


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ