From 37d30b56405bf9858e0c1c1baad93105737e7a1b Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Tue, 18 Oct 2011 11:50:55 +1100 Subject: [PATCH] warnings: Add explict casts to silence many compiler warnings about sign comparisions. Signed-off-by: Tony Breeds --- include/ext2fs/bitops.h | 2 +- include/md5.h | 2 +- second/fs_ext2.c | 2 +- second/fs_swap.c | 2 +- second/fs_xfs.c | 6 +++--- second/md5.c | 14 +++++++------- second/partition.c | 6 +++--- second/yaboot.c | 2 +- util/addnote.c | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/ext2fs/bitops.h b/include/ext2fs/bitops.h index ae6ec34..72c8945 100644 --- a/include/ext2fs/bitops.h +++ b/include/ext2fs/bitops.h @@ -415,7 +415,7 @@ extern int ffs(unsigned int); _INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size) { - char *cp = (unsigned char *) addr; + unsigned char *cp = (unsigned char *) addr; int res = 0, d0; if (!size) diff --git a/include/md5.h b/include/md5.h index c1dbd06..82cc91e 100644 --- a/include/md5.h +++ b/include/md5.h @@ -23,7 +23,7 @@ to strcmp. If CHECK is false, crypt KEY and save the result in CRYPTED. CRYPTED must have a salt. */ -extern int md5_password (const char *key, char *crypted, int check); +extern int md5_password (const unsigned char *key, unsigned char *crypted, int check); /* For convenience. */ #define check_md5_password(key,crypted) md5_password((key), (crypted), 1) diff --git a/second/fs_ext2.c b/second/fs_ext2.c index a8bdf6b..a85958f 100644 --- a/second/fs_ext2.c +++ b/second/fs_ext2.c @@ -109,7 +109,7 @@ static unsigned long read_total; static unsigned long read_max; static struct boot_file_t* read_cur_file; static errcode_t read_result; -static char* read_buffer; +static unsigned char* read_buffer; static int read_dump_range(void); static int read_iterator(ext2_filsys fs, blk_t *blocknr, int lg_block, void *private); diff --git a/second/fs_swap.c b/second/fs_swap.c index cfa5709..87da877 100644 --- a/second/fs_swap.c +++ b/second/fs_swap.c @@ -54,7 +54,7 @@ swap_open(struct boot_file_t* file, struct partition_t* part, int i; unsigned char *buffer; /* Make static to move into the BSS rather then the stack */ - static unsigned char device_name[1024]; + static char device_name[1024]; DEBUG_ENTER; DEBUG_OPEN; diff --git a/second/fs_xfs.c b/second/fs_xfs.c index e27d857..7891068 100644 --- a/second/fs_xfs.c +++ b/second/fs_xfs.c @@ -490,7 +490,7 @@ next_dentry (xfs_ino_t *ino) int toread; static char *usual[2] = {".", ".."}; static xfs_dir2_sf_entry_t *sfe; - char *name = usual[0]; + unsigned char *name = (unsigned char *)usual[0]; if (xfs.dirpos >= xfs.dirmax) { if (xfs.forw == 0) @@ -552,14 +552,14 @@ next_dentry (xfs_ino_t *ino) #undef dau toread = roundup8 (namelen + 11) - 9; xfs_read_data (dirbuf, toread); - name = (char *)dirbuf; + name = (unsigned char *)dirbuf; xfs.blkoff += toread + 5; break; } ++xfs.dirpos; name[namelen] = 0; - return name; + return (char *)name; } static char * diff --git a/second/md5.c b/second/md5.c index 853696c..9116493 100644 --- a/second/md5.c +++ b/second/md5.c @@ -156,7 +156,7 @@ md5_init(void) } static void -md5_update (const char *input, int inputlen) +md5_update (const unsigned char *input, int inputlen) { int buflen = length & 63; length += inputlen; @@ -211,21 +211,21 @@ md5_final() If CHECK is false, crypt KEY and save the result in CRYPTED. CRYPTED must have a salt. */ int -md5_password (const char *key, char *crypted, int check) +md5_password (const unsigned char *key, unsigned char *crypted, int check) { - int keylen = strlen (key); - char *salt = crypted + 3; /* skip $1$ header */ - char *p; + int keylen = strlen ((char *)key); + unsigned char *salt = crypted + 3; /* skip $1$ header */ + unsigned char *p; int saltlen; int i, n; unsigned char alt_result[16]; unsigned char *digest; if (check) - saltlen = strstr (salt, "$") - salt; + saltlen = strstr ((char *)salt, "$") - (char* )salt; else { - char *end = strstr (salt, "$"); + unsigned char *end = (unsigned char*)strstr ((char *)salt, "$"); if (end && end - salt < 8) saltlen = end - salt; else diff --git a/second/partition.c b/second/partition.c index 4381770..eb383bc 100644 --- a/second/partition.c +++ b/second/partition.c @@ -337,12 +337,12 @@ partitions_lookup(const char *device) struct partition_t* list = NULL; unsigned int prom_blksize, iso_root_block; - strncpy(block_buffer, device, 2040); + strncpy((char *)block_buffer, device, 2040); if (_machine != _MACH_bplan) - strcat(block_buffer, ":0"); + strcat((char *)block_buffer, ":0"); /* Open device */ - disk = prom_open(block_buffer); + disk = prom_open((char *)block_buffer); if (disk == NULL) { prom_printf("Can't open device <%s>\n", block_buffer); goto bail; diff --git a/second/yaboot.c b/second/yaboot.c index 1f3f151..0fd26a1 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -603,7 +603,7 @@ void check_password(char *str) prom_printf ("\n"); #ifdef USE_MD5_PASSWORDS if (!strncmp (password, "$1$", 3)) { - if (!check_md5_password(passwdbuff, password)) + if (!check_md5_password((unsigned char*)passwdbuff, (unsigned char*)password)) return; } else if (!strcmp (password, passwdbuff)) diff --git a/util/addnote.c b/util/addnote.c index 56de0c7..ec15c59 100644 --- a/util/addnote.c +++ b/util/addnote.c @@ -165,7 +165,7 @@ main(int ac, char **av) PUT_32BE(ns, strlen(arch) + 1); PUT_32BE(ns + 4, N_DESCR * 4); PUT_32BE(ns + 8, 0x1275); - strcpy(&buf[ns + 12], arch); + strcpy((char *)&buf[ns + 12], arch); ns += 12 + strlen(arch) + 1; for (i = 0; i < N_DESCR; ++i, ns += 4) PUT_32BE(ns, descr[i]); @@ -180,7 +180,7 @@ main(int ac, char **av) PUT_32BE(ns, strlen(rpaname) + 1); PUT_32BE(ns + 4, sizeof(rpanote)); PUT_32BE(ns + 8, 0x12759999); - strcpy(&buf[ns + 12], rpaname); + strcpy((char *)&buf[ns + 12], rpaname); ns += 12 + ROUNDUP(strlen(rpaname) + 1); for (i = 0; i < N_RPA_DESCR; ++i, ns += 4) PUT_32BE(ns, rpanote[i]); -- 2.39.2