Skip to content

Commit

Permalink
fix most sign and variable initialization warnings
Browse files Browse the repository at this point in the history
Change-Id: I56e08db791152a9c95fc0d16bc75b702e403274d
  • Loading branch information
tpruvot committed May 5, 2012
1 parent 8a6c2c2 commit 6fef6a3
Show file tree
Hide file tree
Showing 56 changed files with 161 additions and 152 deletions.
1 change: 1 addition & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BIONIC_ICS := true
include $(CLEAR_VARS)
LOCAL_SRC_FILES := android/regex/regex.c
LOCAL_C_INCLUDES := $(BB_PATH)/android/regex
LOCAL_CFLAGS := -Wno-sign-compare
LOCAL_MODULE := libclearsilverregex
include $(BUILD_STATIC_LIBRARY)

Expand Down
1 change: 1 addition & 0 deletions android/regex/cs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define HAVE_REGEX 1

/* Does your system have pthreads? */
#undef HAVE_PTHREADS
#define HAVE_PTHREADS 1

/* Does your system have lockf ? */
Expand Down
46 changes: 24 additions & 22 deletions android/regex/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ typedef enum
wordend, /* Succeeds if at word end. */

wordbound, /* Succeeds if at a word boundary. */
notwordbound /* Succeeds if not at a word boundary. */
notwordbound, /* Succeeds if not at a word boundary. */

#ifdef emacs
,before_dot, /* Succeeds if before point. */
before_dot, /* Succeeds if before point. */
at_dot, /* Succeeds if at point. */
after_dot, /* Succeeds if after point. */

Expand All @@ -467,7 +467,7 @@ typedef enum
syntaxspec,

/* Matches any character whose syntax is not that specified. */
notsyntaxspec
notsyntaxspec,
#endif /* emacs */
} re_opcode_t;

Expand Down Expand Up @@ -1157,7 +1157,7 @@ typedef struct
DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
\
/* Ensure we have enough space allocated for what we will push. */ \
while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
while ((int) REMAINING_AVAIL_SLOTS < (int) NUM_FAILURE_ITEMS) \
{ \
if (!DOUBLE_FAIL_STACK (fail_stack)) \
return failure_code; \
Expand All @@ -1171,7 +1171,8 @@ typedef struct
DEBUG_PRINT1 ("\n"); \
\
if (1) \
for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
for (this_reg = lowest_active_reg; \
this_reg <= (int) highest_active_reg; \
this_reg++) \
{ \
DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \
Expand All @@ -1195,23 +1196,23 @@ typedef struct
PUSH_FAILURE_ELT (reg_info[this_reg].word); \
} \
\
DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\
DEBUG_PRINT2(" Pushing low active reg: %d\n", lowest_active_reg); \
PUSH_FAILURE_INT (lowest_active_reg); \
\
DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
DEBUG_PRINT2(" Pushing high active reg: %d\n", highest_active_reg);\
PUSH_FAILURE_INT (highest_active_reg); \
\
DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
DEBUG_PRINT2(" Pushing pattern 0x%x: ", pattern_place); \
DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
PUSH_FAILURE_POINTER (pattern_place); \
\
DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
DEBUG_PRINT2(" Pushing string 0x%x: `", string_place); \
DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
size2); \
DEBUG_PRINT1 ("'\n"); \
DEBUG_PRINT1("'\n"); \
PUSH_FAILURE_POINTER (string_place); \
\
DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
DEBUG_PRINT2(" Pushing failure id: %u\n", failure_id); \
DEBUG_PUSH (failure_id); \
} while (0)

Expand Down Expand Up @@ -1268,7 +1269,7 @@ typedef struct
DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
\
assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
assert ((int) fail_stack.avail >= (int) NUM_NONREG_ITEMS); \
\
DEBUG_POP (&failure_id); \
DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
Expand Down Expand Up @@ -1296,7 +1297,7 @@ typedef struct
DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
\
if (1) \
for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
for (this_reg = high_reg; this_reg >= (int) low_reg; this_reg--) \
{ \
DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
\
Expand All @@ -1311,7 +1312,8 @@ typedef struct
} \
else \
{ \
for (this_reg = highest_active_reg; this_reg > high_reg; this_reg--) \
for (this_reg = highest_active_reg; this_reg > (int) high_reg; \
this_reg--) \
{ \
reg_info[this_reg].word.integer = 0; \
regend[this_reg] = 0; \
Expand Down Expand Up @@ -1431,14 +1433,14 @@ static reg_errcode_t compile_range ();

/* Make sure we have at least N more bytes of space in buffer. */
#define GET_BUFFER_SPACE(n) \
while (b - bufp->buffer + (n) > bufp->allocated) \
while (b - bufp->buffer + (n) > (int) bufp->allocated) \
EXTEND_BUFFER ()

/* Make sure we have one more byte of buffer space and then add C to it. */
#define BUF_PUSH(c) \
do { \
GET_BUFFER_SPACE (1); \
*b++ = (unsigned char) (c); \
*b++ = (unsigned char) (c); \
} while (0)


Expand Down Expand Up @@ -3490,7 +3492,7 @@ static boolean alt_match_null_string_p (),

/* Free everything we malloc. */
#ifdef MATCH_MAY_ALLOCATE
#define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL; } else
#define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL; } else {}
#define FREE_VARIABLES() \
do { \
REGEX_FREE_STACK (fail_stack.stack); \
Expand Down Expand Up @@ -3746,7 +3748,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
/* Initialize subexpression text positions to -1 to mark ones that no
start_memory/stop_memory has been seen for. Also initialize the
register information struct. */
for (mcnt = 1; mcnt < num_regs; mcnt++)
for (mcnt = 1; mcnt < (int) num_regs; mcnt++)
{
regstart[mcnt] = regend[mcnt]
= old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
Expand Down Expand Up @@ -3846,7 +3848,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)

DEBUG_PRINT1 ("\nSAVING match as best so far.\n");

for (mcnt = 1; mcnt < num_regs; mcnt++)
for (mcnt = 1; mcnt < (int) num_regs; mcnt++)
{
best_regstart[mcnt] = regstart[mcnt];
best_regend[mcnt] = regend[mcnt];
Expand All @@ -3872,7 +3874,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
dend = ((d >= string1 && d <= end1)
? end_match_1 : end_match_2);

for (mcnt = 1; mcnt < num_regs; mcnt++)
for (mcnt = 1; mcnt < (int) num_regs; mcnt++)
{
regstart[mcnt] = best_regstart[mcnt];
regend[mcnt] = best_regend[mcnt];
Expand Down Expand Up @@ -3937,7 +3939,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)

/* Go through the first `min (num_regs, regs->num_regs)'
registers, since that is all we initialized. */
for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
for (mcnt = 1; mcnt < (int) MIN (num_regs, regs->num_regs); mcnt++)
{
if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
regs->start[mcnt] = regs->end[mcnt] = -1;
Expand All @@ -3955,7 +3957,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
we (re)allocated the registers, this is the case,
because we always allocate enough to have at least one
-1 at the end. */
for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
for (mcnt = num_regs; mcnt < (int) regs->num_regs; mcnt++)
regs->start[mcnt] = regs->end[mcnt] = -1;
} /* regs && !bufp->no_sub */

Expand Down
2 changes: 1 addition & 1 deletion applets/usage_pod.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int main(void)
} else {
printf(", ");
}
printf(usage_array[i].aname);
printf("%s", usage_array[i].aname);
col += len2;
}
printf("\n\n");
Expand Down
2 changes: 1 addition & 1 deletion archival/libarchive/bz/blocksort.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ void mainSort(EState* state,
int32_t vv;
/* bbox: was: int32_t h = 1; */
/* do h = 3 * h + 1; while (h <= 256); */
uint32_t h = 364;
int32_t h = 364;

do {
/*h = h / 3;*/
Expand Down
2 changes: 1 addition & 1 deletion archival/libarchive/data_extract_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
bb_perror_msg_and_die("can't stat old file");
}
}
else if (existing_sb.st_mtime >= file_header->mtime) {
else if ((time_t) existing_sb.st_mtime >= (time_t) file_header->mtime) {
if (!(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
&& !S_ISDIR(file_header->mode)
) {
Expand Down
4 changes: 2 additions & 2 deletions archival/libarchive/decompress_bunzip2.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static int get_next_block(bunzip_data *bd)
struct group_data *hufGroup;
int dbufCount, dbufSize, groupCount, *base, *limit, selector,
i, j, t, runPos, symCount, symTotal, nSelectors, byteCount[256];
int runCnt = runCnt; /* for compiler */
int runCnt = 0;
uint8_t uc, symToByte[256], mtfSymbol[256], *selectors;
uint32_t *dbuf;
unsigned origPtr;
Expand Down Expand Up @@ -780,7 +780,7 @@ unpack_bz2_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
len = bd->inbufCount - bd->inbufPos;
memcpy(outbuf, &bd->inbuf[bd->inbufPos], len);
if (len < 2) {
if (safe_read(src_fd, outbuf + len, 2 - len) != 2 - len)
if (safe_read(src_fd, outbuf + len, 2 - len) != (int)(2 - len))
break;
len = 2;
}
Expand Down
4 changes: 2 additions & 2 deletions archival/libarchive/decompress_gunzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
while (*current < required) {
if (bytebuffer_offset >= bytebuffer_size) {
unsigned sz = bytebuffer_max - 4;
if (to_read >= 0 && to_read < sz) /* unzip only */
if (to_read >= 0 && (unsigned) to_read < sz) /* unzip only */
sz = to_read;
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
* to the front of the bytebuffer */
Expand Down Expand Up @@ -409,7 +409,7 @@ static int huft_build(const unsigned *b, const unsigned n,
f -= *xp; /* else deduct codes from patterns */
}
}
j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */
j = ((unsigned) (w + j) > eob_len && w > 0 && (unsigned) w < eob_len) ? eob_len - w : j; /* make EOB code end at table */
z = 1 << j; /* table entries for j-bit table */
ws[htl+1] = w + j; /* set bits decoded in stack */

Expand Down
2 changes: 1 addition & 1 deletion archival/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static void unzip_extract(zip_header_t *zip_header, int dst_fd)
bb_error_msg_and_die("crc error");
}
/* Validate decompression - size */
if (zip_header->formatted.ucmpsize != aux.bytes_out) {
if (zip_header->formatted.ucmpsize != (uint32_t) aux.bytes_out) {
/* Don't die. Who knows, maybe len calculation
* was botched somewhere. After all, crc matched! */
bb_error_msg("bad length");
Expand Down
2 changes: 1 addition & 1 deletion coreutils/cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static char *build_row(char *p, unsigned *dp)
col = 0;
do {
day = *dp++;
if (day != SPACE) {
if (day != (unsigned) SPACE) {
if (julian) {
++p;
if (day >= 100) {
Expand Down
4 changes: 2 additions & 2 deletions coreutils/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ static VALUE *eval6(void)
"quote\0""length\0""match\0""index\0""substr\0";

VALUE *r, *i1, *i2;
VALUE *l = l; /* silence gcc */
VALUE *v = v; /* silence gcc */
VALUE *l = NULL;
VALUE *v = NULL;
int key = *G.args ? index_in_strings(keywords, *G.args) + 1 : 0;

if (key == 0) /* not a keyword */
Expand Down
2 changes: 1 addition & 1 deletion coreutils/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ static void display_files(struct dnode **dn, unsigned nfiles)
/* find the longest file name, use that as the column width */
for (i = 0; dn[i]; i++) {
int len = calc_name_len(dn[i]->name);
if (column_width < len)
if ((int)column_width < len)
column_width = len;
}
column_width += 1 +
Expand Down
4 changes: 2 additions & 2 deletions coreutils/seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int seq_main(int argc, char **argv)
};
double first, last, increment, v;
unsigned n;
unsigned width;
int width;
unsigned frac_part;
const char *sep, *opt_s = "\n";
unsigned opt;
Expand Down Expand Up @@ -70,7 +70,7 @@ int seq_main(int argc, char **argv)
while (1) {
char *dot = strchrnul(*argv, '.');
int w = (dot - *argv);
int f = strlen(dot);
unsigned f = strlen(dot);
if (width < w)
width = w;
argv++;
Expand Down
4 changes: 2 additions & 2 deletions coreutils/tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ int tail_main(int argc, char **argv)

char *tailbuf;
size_t tailbufsize;
unsigned header_threshhold = 1;
unsigned nfiles;
int header_threshhold = 1;
int nfiles;
int i, opt;

int *fds;
Expand Down
16 changes: 8 additions & 8 deletions editors/awk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,15 +2410,15 @@ static var *evaluate(node *op, var *res)
v1 = nvalloc(2);

while (op) {
struct {
static struct {
var *v;
const char *s;
} L = L; /* for compiler */
struct {
} L;
static struct {
var *v;
const char *s;
} R = R;
double L_d = L_d;
} R;
static double L_d;
uint32_t opinfo;
int opn;
node *op1;
Expand Down Expand Up @@ -2645,7 +2645,7 @@ static var *evaluate(node *op, var *res)
copyvar(v, arg);
v->type |= VF_CHILD;
v->x.parent = arg;
if (++v - vbeg >= op->r.f->nargs)
if (++v - vbeg >= (int) op->r.f->nargs)
break;
}

Expand Down Expand Up @@ -2703,7 +2703,7 @@ static var *evaluate(node *op, var *res)

/* simple builtins */
case XC( OC_FBLTIN ): {
double R_d = R_d; /* for compiler */
static double R_d;

switch (opn) {
case F_in:
Expand Down Expand Up @@ -2914,7 +2914,7 @@ static var *evaluate(node *op, var *res)
}

case XC( OC_COMPARE ): {
int i = i; /* for compiler */
static int i;
double Ld;

if (is_numeric(L.v) && is_numeric(R.v)) {
Expand Down
2 changes: 1 addition & 1 deletion editors/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static NOINLINE int *create_J(FILE_and_pos_t ft[2], int nlen[2], off_t *ix[2])
for (i = 0; i < 2; i++) {
unsigned hash;
token_t tok;
size_t sz = 100;
int sz = 100;
nfile[i] = xmalloc((sz + 3) * sizeof(nfile[i][0]));
/* ft gets here without the correct position, cant use seek_ft */
ft[i].ft_pos = 0;
Expand Down
Loading

0 comments on commit 6fef6a3

Please sign in to comment.