[PATCH 02/22] block: Replace strnicmp with strncasecmp

From: Rasmus Villemoes
Date: Tue Sep 16 2014 - 16:59:56 EST


The kernel used to contain two functions for length-delimited,
case-insensitive string comparison, strnicmp with correct semantics
and a slightly buggy strncasecmp. The latter is the POSIX name, so
strnicmp was renamed to strncasecmp, and strnicmp made into a wrapper
for the new strncasecmp to avoid breaking existing users.

To allow the compat wrapper strnicmp to be removed at some point in
the future, and to avoid the extra indirection cost, do
s/strnicmp/strncasecmp/g.

Cc: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
block/partitions/mac.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/partitions/mac.c b/block/partitions/mac.c
index 76d8ba6..c2c48ec 100644
--- a/block/partitions/mac.c
+++ b/block/partitions/mac.c
@@ -81,7 +81,7 @@ int mac_partition(struct parsed_partitions *state)
be32_to_cpu(part->start_block) * (secsize/512),
be32_to_cpu(part->block_count) * (secsize/512));

- if (!strnicmp(part->type, "Linux_RAID", 10))
+ if (!strncasecmp(part->type, "Linux_RAID", 10))
state->parts[slot].flags = ADDPART_FLAG_RAID;
#ifdef CONFIG_PPC_PMAC
/*
@@ -100,7 +100,7 @@ int mac_partition(struct parsed_partitions *state)
goodness++;

if (strcasecmp(part->type, "Apple_UNIX_SVR2") == 0
- || (strnicmp(part->type, "Linux", 5) == 0
+ || (strncasecmp(part->type, "Linux", 5) == 0
&& strcasecmp(part->type, "Linux_swap") != 0)) {
int i, l;

@@ -109,13 +109,13 @@ int mac_partition(struct parsed_partitions *state)
if (strcmp(part->name, "/") == 0)
goodness++;
for (i = 0; i <= l - 4; ++i) {
- if (strnicmp(part->name + i, "root",
+ if (strncasecmp(part->name + i, "root",
4) == 0) {
goodness += 2;
break;
}
}
- if (strnicmp(part->name, "swap", 4) == 0)
+ if (strncasecmp(part->name, "swap", 4) == 0)
goodness--;
}

--
2.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/