From 4f7da73885934a052425fc71861b0c9922c2122f Mon Sep 17 00:00:00 2001 From: Mats Date: Tue, 11 Mar 2014 20:15:36 +0100 Subject: Unify use of string comparisons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2) * strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2) * Prefer case-insensitive comparison for options --- src/print_disk_info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/print_disk_info.c') diff --git a/src/print_disk_info.c b/src/print_disk_info.c index d586839..1671210 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -43,9 +43,9 @@ static int format_bytes(char *outwalk, uint64_t bytes, uint64_t base, const char * */ static int print_bytes_human(char *outwalk, uint64_t bytes, const char *prefix_type) { - if (strncmp(prefix_type, "decimal", strlen(prefix_type)) == 0) { + if (strcasecmp(prefix_type, "decimal") == 0) { return format_bytes(outwalk, bytes, DECIMAL_BASE, si_symbols); - } else if (strncmp(prefix_type, "custom", strlen(prefix_type)) == 0) { + } else if (strcasecmp(prefix_type, "custom") == 0) { return format_bytes(outwalk, bytes, BINARY_BASE, custom_symbols); } else { return format_bytes(outwalk, bytes, BINARY_BASE, iec_symbols); -- cgit v1.2.3