From 5e678873f9ff7c95d43b278feee547ce989b3b20 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 30 Jan 2006 19:48:23 +0000 Subject: [PATCH] clean up yet more annoying signed/unsigned mismatches and fixup yet more incorrect types --- console-tools/loadfont.c | 4 ++-- coreutils/expr.c | 6 ++++-- coreutils/install.c | 2 +- coreutils/ls.c | 2 +- coreutils/od.c | 10 +++++----- coreutils/tr.c | 24 ++++++++++++------------ coreutils/uudecode.c | 2 +- coreutils/uuencode.c | 2 +- editors/patch.c | 2 +- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 4580dc4e0..d9bbb2072 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c @@ -52,7 +52,7 @@ extern int loadfont_main(int argc, char **argv) return EXIT_SUCCESS; } -static void do_loadfont(int fd, char *inbuf, int unit, int fontsize) +static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize) { char buf[16384]; int i; @@ -138,7 +138,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) static void loadnewfont(int fd) { int unit; - char inbuf[32768]; /* primitive */ + unsigned char inbuf[32768]; /* primitive */ unsigned int inputlth, offset; /* diff --git a/coreutils/expr.c b/coreutils/expr.c index e0eb4ec8c..b23de8e9f 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c @@ -57,10 +57,12 @@ typedef enum valtype TYPE; #if ENABLE_EXPR_MATH_SUPPORT_64 typedef int64_t arith_t; #define PF_REZ "ll" +#define PF_REZ_TYPE (long long) #define STRTOL(s, e, b) strtoll(s, e, b) #else typedef long arith_t; #define PF_REZ "l" +#define PF_REZ_TYPE (long) #define STRTOL(s, e, b) strtol(s, e, b) #endif @@ -102,7 +104,7 @@ int expr_main (int argc, char **argv) bb_error_msg_and_die ("syntax error"); if (v->type == integer) - printf ("%" PF_REZ "d\n", v->u.i); + printf ("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); else puts (v->u.s); @@ -159,7 +161,7 @@ static int null (VALUE *v) static void tostring (VALUE *v) { if (v->type == integer) { - v->u.s = bb_xasprintf ("%" PF_REZ "d", v->u.i); + v->u.s = bb_xasprintf ("%" PF_REZ "d", PF_REZ_TYPE v->u.i); v->type = string; } } diff --git a/coreutils/install.c b/coreutils/install.c index c3d4f8c82..e58cac931 100644 --- a/coreutils/install.c +++ b/coreutils/install.c @@ -115,7 +115,7 @@ extern int install_main(int argc, char **argv) ? 0 : S_ISDIR(statbuf.st_mode); } for (i = optind; i < argc - 1; i++) { - unsigned char *dest; + char *dest; dest = argv[argc - 1]; if (isdir) dest = concat_path_file(argv[argc - 1], basename(argv[i])); diff --git a/coreutils/ls.c b/coreutils/ls.c index 46ab865dd..489c29ad1 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -679,7 +679,7 @@ static int list_single(struct dnode *dn) break; case LIST_BLOCKS: #if _FILE_OFFSET_BITS == 64 - column += printf("%4lld ", dn->dstat.st_blocks >> 1); + column += printf("%4lld ", (long long)dn->dstat.st_blocks >> 1); #else column += printf("%4ld ", dn->dstat.st_blocks >> 1); #endif diff --git a/coreutils/od.c b/coreutils/od.c index 6a138e838..b70cb85e2 100644 --- a/coreutils/od.c +++ b/coreutils/od.c @@ -155,9 +155,9 @@ static const char * const add_strings[] = { "4/4 \" %011o \" \"\\n\"", /* O */ }; -static const signed char od_opts[] = "aBbcDdeFfHhIiLlOoXxv"; +static const char od_opts[] = "aBbcDdeFfHhIiLlOoXxv"; -static const signed char od_o2si[] = { +static const char od_o2si[] = { 0, 1, 2, 3, 5, 4, 6, 6, 7, 8, 9, 0xa, 0xb, 0xa, 0xa, @@ -168,14 +168,14 @@ int od_main(int argc, char **argv) { int ch; int first = 1; - signed char *p; + char *p; bb_dump_vflag = FIRST; bb_dump_length = -1; while ((ch = getopt(argc, argv, od_opts)) > 0) { if (ch == 'v') { bb_dump_vflag = ALL; - } else if (((p = strchr(od_opts, ch)) != NULL) && (*p >= 0)) { + } else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) { if (first) { first = 0; bb_dump_add("\"%07.7_Ao\n\""); @@ -183,7 +183,7 @@ int od_main(int argc, char **argv) } else { bb_dump_add("\" \""); } - bb_dump_add(add_strings[od_o2si[(int)(p-od_opts)]]); + bb_dump_add(add_strings[(int)od_o2si[(p-od_opts)]]); } else { /* P, p, s, w, or other unhandled */ bb_show_usage(); } diff --git a/coreutils/tr.c b/coreutils/tr.c index e9eca4c60..d6c5e346e 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c @@ -40,7 +40,7 @@ static short in_index, out_index; /* these last are pointers to static buffers declared in tr_main */ static unsigned char *poutput; static unsigned char *pvector; -static char *pinvec, *poutvec; +static unsigned char *pinvec, *poutvec; #define input bb_common_bufsiz1 @@ -141,9 +141,9 @@ static unsigned int expand(const char *arg, register unsigned char *buffer) for (i = 'A'; i <= 'Z'; i++) *buffer++ = i; else if (strncmp(arg, "space", 5) == 0) - strcat(buffer, " \f\n\r\t\v"); + strcat((char*)buffer, " \f\n\r\t\v"); else if (strncmp(arg, "blank", 5) == 0) - strcat(buffer, " \t"); + strcat((char*)buffer, " \t"); /* gcc gives a warning if braces aren't used here */ else if (strncmp(arg, "punct", 5) == 0) { for (i = 0; i <= ASCII; i++) @@ -156,7 +156,7 @@ static unsigned int expand(const char *arg, register unsigned char *buffer) *buffer++ = i; } else { - strcat(buffer, "[:"); + strcat((char*)buffer, "[:"); arg++; continue; } @@ -214,10 +214,10 @@ extern int tr_main(int argc, char **argv) RESERVE_CONFIG_BUFFER(outvec, ASCII+1); /* ... but make them available globally */ - poutput = output; - pvector = vector; - pinvec = invec; - poutvec = outvec; + poutput = (unsigned char*)output; + pvector = (unsigned char*)vector; + pinvec = (unsigned char*)invec; + poutvec = (unsigned char*)outvec; if (argc > 1 && argv[idx][0] == '-') { for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) { @@ -243,14 +243,14 @@ extern int tr_main(int argc, char **argv) } if (argv[idx] != NULL) { - input_length = expand(argv[idx++], input); + input_length = expand(argv[idx++], (unsigned char*)input); if (com_fl) - input_length = complement(input, input_length); + input_length = complement((unsigned char*)input, input_length); if (argv[idx] != NULL) { if (*argv[idx] == '\0') bb_error_msg_and_die("STRING2 cannot be empty"); - output_length = expand(argv[idx], output); - map(input, input_length, output, output_length); + output_length = expand(argv[idx], (unsigned char*)output); + map((unsigned char*)input, input_length, (unsigned char*)output, output_length); } for (i = 0; i < input_length; i++) invec[(unsigned char)input[i]] = TRUE; diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index da6490a81..60bf7d8c1 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -93,7 +93,7 @@ static int read_base64(FILE *src_stream, FILE *dst_stream) while (count < 4) { char *table_ptr; - char ch; + int ch; /* Get next _valid_ character */ do { diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index 2660f4a19..ee07b084f 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c @@ -130,7 +130,7 @@ int uuencode_main(int argc, char **argv) memset(&src_buf[size], 0, src_buf_size - size); } /* Encode the buffer we just read in */ - uuencode(src_buf, dst_buf, size, tbl); + uuencode((unsigned char*)src_buf, dst_buf, size, tbl); putchar('\n'); if (tbl == tbl_std) { diff --git a/editors/patch.c b/editors/patch.c index bcd3c6830..d406a62bb 100644 --- a/editors/patch.c +++ b/editors/patch.c @@ -52,7 +52,7 @@ static int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int li * returns malloc'ed filename */ -static unsigned char *extract_filename(char *line, unsigned short patch_level) +static char *extract_filename(char *line, unsigned short patch_level) { char *filename_start_ptr = line + 4; int i; -- 2.25.1