* grub-core/kern/misc.c (grub_strcmp): Use unsigned comparison as

per common usage and preffered in several parts of code.
	(grub_memcmp): Likewise.
	(grub_strncmp): Likewise.
	* include/grub/misc.h (grub_strcasecmp): Likewise.
	(grub_strncasecmp): Likewise.
	* Makefile.util.def (cmp_test): New test.
	(grub_script_strcmp): Likewise.
	* tests/cmp_unit_test.c: New file.
	* tests/grub_script_strcmp.in: Likewise.
	* grub-core/fs/hfsplus.c (grub_hfsplus_cmp_catkey): Add a comment.
This commit is contained in:
Vladimir 'phcoder' Serbinenko committed 2012-05-04 12:08:22 +02:00
1 parent 49717bf429
commit ce41ab7aab
7 files changed
+293 -7

No files matched your search

+2
View File
@@ -532,6 +532,8 @@ grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya,
len = grub_be_to_cpu16 (catkey_a->namelen);
if (len > catkey_b->namelen)
len = catkey_b->namelen;
/* Since it's big-endian memcmp gives the same result as manually comparing
uint16_t but may be faster. */
diff = grub_memcmp (catkey_a->name, catkey_b->name,
len * sizeof (catkey_a->name[0]));
if (diff == 0)
+4 -4
View File
@@ -216,8 +216,8 @@ grub_vprintf (const char *fmt, va_list args)
int
grub_memcmp (const void *s1, const void *s2, grub_size_t n)
{
const char *t1 = s1;
const char *t2 = s2;
const grub_uint8_t *t1 = s1;
const grub_uint8_t *t2 = s2;
while (n--)
{
@@ -252,7 +252,7 @@ grub_strcmp (const char *s1, const char *s2)
s2++;
}
return (int) *s1 - (int) *s2;
return (int) (grub_uint8_t) *s1 - (int) (grub_uint8_t) *s2;
}
int
@@ -270,7 +270,7 @@ grub_strncmp (const char *s1, const char *s2, grub_size_t n)
s2++;
}
return (int) *s1 - (int) *s2;
return (int) (grub_uint8_t) *s1 - (int) (grub_uint8_t) *s2;
}
char *