summaryrefslogtreecommitdiff
path: root/src/print_eth_info.c
diff options
context:
space:
mode:
authorMats <d912e3@gmail.com>2014-03-11 20:15:36 +0100
committerMichael Stapelberg <michael@stapelberg.de>2014-03-12 08:28:16 +0100
commit4f7da73885934a052425fc71861b0c9922c2122f (patch)
treef3872ee680309fa8955318f4d3a586cb08846a9d /src/print_eth_info.c
parent52814295a0b3a0785631256e9e2dc6b8139e2be8 (diff)
Unify use of string comparisons
* strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2) * strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2) * Prefer case-insensitive comparison for options
Diffstat (limited to 'src/print_eth_info.c')
-rw-r--r--src/print_eth_info.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/print_eth_info.c b/src/print_eth_info.c
index 45a44a4..c446da4 100644
--- a/src/print_eth_info.c
+++ b/src/print_eth_info.c
@@ -90,8 +90,8 @@ static int print_eth_speed(char *outwalk, const char *interface) {
* Skip these non-informative values and go right ahead to the
* actual speeds.
*/
- if (strncmp(desc->ifmt_string, "autoselect", strlen("autoselect")) == 0 ||
- strncmp(desc->ifmt_string, "auto", strlen("auto")) == 0)
+ if (BEGINS_WITH(desc->ifmt_string, "autoselect") ||
+ BEGINS_WITH(desc->ifmt_string, "auto"))
continue;
if (IFM_TYPE_MATCH(desc->ifmt_word, ifmr.ifm_active) &&
@@ -131,10 +131,10 @@ void print_eth_info(yajl_gen json_gen, char *buffer, const char *interface, cons
continue;
}
- if (strncmp(walk+1, "ip", strlen("ip")) == 0) {
+ if (BEGINS_WITH(walk+1, "ip")) {
outwalk += sprintf(outwalk, "%s", ip_address);
walk += strlen("ip");
- } else if (strncmp(walk+1, "speed", strlen("speed")) == 0) {
+ } else if (BEGINS_WITH(walk+1, "speed")) {
outwalk += print_eth_speed(outwalk, interface);
walk += strlen("speed");
}