Commit f7ac3690 authored by Richard P. Curnow's avatar Richard P. Curnow

Cleanup compiler warnings generated by gcc4

parent 2bd0ef29
......@@ -287,7 +287,7 @@ static void import_toktable(char *data, unsigned int hash_key, int n_msgs, struc
enc_hi = idx;
text = data + in->tok_offsets[i];
hash = hashfn(text, strlen(text), hash_key);
hash = hashfn((unsigned char *) text, strlen(text), hash_key);
nt = new(struct token);
nt->hashval = hash;
......@@ -297,7 +297,7 @@ static void import_toktable(char *data, unsigned int hash_key, int n_msgs, struc
nt->match0.n = enc_len;
nt->match0.highest = enc_hi;
assert(nt->match0.highest < n_msgs);
nt->match0.msginfo = new_array(char, nt->match0.max);
nt->match0.msginfo = new_array(unsigned char, nt->match0.max);
memcpy(nt->match0.msginfo, enc, nt->match0.n);
index = hash & out->mask;
......@@ -369,7 +369,7 @@ static void import_toktable2(char *data, unsigned int hash_key, int n_msgs, stru
/*}}}*/
text = data + in->tok_offsets[i];
hash = hashfn(text, strlen(text), hash_key);
hash = hashfn((unsigned char *) text, strlen(text), hash_key);
nt = new(struct token2);
nt->hashval = hash;
......@@ -380,7 +380,7 @@ static void import_toktable2(char *data, unsigned int hash_key, int n_msgs, stru
nt->match0.n = enc0_len;
nt->match0.highest = enc0_hi;
assert(nt->match0.highest < n_msgs);
nt->match0.msginfo = new_array(char, nt->match0.max);
nt->match0.msginfo = new_array(unsigned char, nt->match0.max);
memcpy(nt->match0.msginfo, enc0, nt->match0.n);
/*}}}*/
/*{{{ set up match1 chain */
......@@ -388,7 +388,7 @@ static void import_toktable2(char *data, unsigned int hash_key, int n_msgs, stru
nt->match1.n = enc1_len;
nt->match1.highest = enc1_hi;
assert(nt->match1.highest < n_msgs);
nt->match1.msginfo = new_array(char, nt->match1.max);
nt->match1.msginfo = new_array(unsigned char, nt->match1.max);
memcpy(nt->match1.msginfo, enc1, nt->match1.n);
/*}}}*/
......@@ -463,7 +463,8 @@ struct database *new_database_from_file(char *db_filename, int do_integrity_chec
break;
case DB_MSG_MBOX:
{
int mbi, msgi, n;
unsigned int mbi, msgi;
int n;
struct mbox *mb;
result->type[i] = MTY_MBOX;
decode_mbox_indices(input->path_offsets[i], &mbi, &msgi);
......@@ -554,17 +555,26 @@ static unsigned char special_table[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* f0-ff */
};
#define CHAR_VALID(x,mask) (isalnum(x) || (special_table[(unsigned int)(unsigned char) x] & mask))
#if 0
#define CHAR_VALID(x,mask) (isalnum((unsigned char) x) || (special_table[(unsigned int)(unsigned char) x] & mask))
#endif
static inline int char_valid_p(char x, unsigned int mask)/*{{{*/
{
unsigned char xx = (unsigned char) x;
if (isalnum(xx)) return 1;
else if (special_table[(unsigned int) xx] & mask) return 1;
else return 0;
}
/*}}}*/
static void tokenise_string(int file_index, unsigned int hash_key, struct toktable *table, char *data, int match_mask)/*{{{*/
{
unsigned char *ss, *es, old_es;
ss = (unsigned char *) data;
char *ss, *es, old_es;
ss = data;
for (;;) {
while (*ss && !CHAR_VALID(*ss,match_mask)) ss++;
while (*ss && !char_valid_p(*ss,match_mask)) ss++;
if (!*ss) break;
es = ss + 1;
while (*es && CHAR_VALID(*es,match_mask)) es++;
while (*es && char_valid_p(*es,match_mask)) es++;
/* deal with token [ss,es) */
old_es = *es;
......@@ -580,14 +590,14 @@ static void tokenise_string(int file_index, unsigned int hash_key, struct toktab
/*}}}*/
static void tokenise_html_string(int file_index, unsigned int hash_key, struct toktable *table, char *data)/*{{{*/
{
unsigned char *ss, *es, old_es;
char *ss, *es, old_es;
/* FIXME : Probably want to rewrite this as an explicit FSM */
ss = (unsigned char *) data;
ss = data;
for (;;) {
/* Assume < and > are never valid token characters ! */
while (*ss && !CHAR_VALID(*ss, 1)) {
while (*ss && !char_valid_p(*ss, 1)) {
if (*ss++ == '<') {
/* Skip over HTML tag */
while (*ss && (*ss != '>')) ss++;
......@@ -596,7 +606,7 @@ static void tokenise_html_string(int file_index, unsigned int hash_key, struct t
if (!*ss) break;
es = ss + 1;
while (*es && CHAR_VALID(*es, 1)) es++;
while (*es && char_valid_p(*es, 1)) es++;
/* deal with token [ss,es) */
old_es = *es;
......
......@@ -2,7 +2,7 @@
mairix - message index builder and finder for maildir folders.
**********************************************************************
* Copyright (C) Richard P. Curnow 2004
* Copyright (C) Richard P. Curnow 2004, 2005
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
......@@ -47,7 +47,7 @@ static void dump_toktable(struct read_db *db, struct toktable_db *tbl, const cha
printf("%d entries\n", n);
for (i=0; i<n; i++) {
printf("Word %d : <%s>\n", i, db->data + tbl->tok_offsets[i]);
foo = db->data + tbl->enc_offsets[i];
foo = (unsigned char *) db->data + tbl->enc_offsets[i];
j = 0;
on_line = 0;
printf(" ");
......@@ -86,7 +86,7 @@ void dump_database(char *filename)
break;
case DB_MSG_MBOX:
{
int mbix, msgix;
unsigned int mbix, msgix;
decode_mbox_indices(db->path_offsets[i], &mbix, &msgix);
printf("MBOX %d, msg %d, offset=%d, size=%d, tid=%d",
......
......@@ -207,7 +207,6 @@ struct globber_array *colon_sep_string_to_globber_array(const char *in)/*{{{*/
result->n = n_strings;
result->globs = new_array(struct globber *, n_strings);
for (i=0; i<n_strings; i++) {
int len;
result->globs[i] = make_globber(strings[i]);
free(strings[i]);
}
......
......@@ -431,7 +431,7 @@ static void usage(void)/*{{{*/
int main (int argc, char **argv)/*{{{*/
{
struct msgpath_array *msgs;
struct database *db;
struct database *db = NULL;
char *arg_rc_file_path = NULL;
char *arg_mfolder = NULL;
......
......@@ -306,7 +306,7 @@ void free_token(struct token *x);
void free_token2(struct token2 *x);
void free_toktable(struct toktable *x);
void free_toktable2(struct toktable2 *x);
void add_token_in_file(int file_index, unsigned int hash_key, unsigned char *tok_text, struct toktable *table);
void add_token_in_file(int file_index, unsigned int hash_key, char *tok_text, struct toktable *table);
void check_and_enlarge_encoding(struct matches *m);
void insert_index_on_encoding(struct matches *m, int idx);
void add_token2_in_file(int file_index, unsigned int hash_key, char *tok_text, struct toktable2 *table, int add_to_chain1);
......@@ -325,13 +325,12 @@ int cull_dead_messages(struct database *db, int do_integrity_checks);
void build_mbox_lists(struct database *db, const char *folder_base,
const char *mboxen_paths, struct globber_array *omit_globs);
int add_mbox_messages(struct database *db);
void compute_checksum(const unsigned char *data, size_t len, checksum_t *csum);
void compute_checksum(const char *data, size_t len, checksum_t *csum);
void cull_dead_mboxen(struct database *db);
unsigned int encode_mbox_indices(unsigned int mb, unsigned int msg);
void decode_mbox_indices(unsigned int index, unsigned int *mb, unsigned int *msg);
int verify_mbox_size_constraints(struct database *db);
void glob_and_expand_paths(const char *folder_base, char **paths_in, int n_in, char ***paths_out, int *n_out, const struct traverse_methods *methods, struct globber_array *omit_globs);
int filter_is_file(const char *x, struct stat *sb);
/* In glob.c */
struct globber;
......
......@@ -101,11 +101,11 @@ static void append_new_mboxen_to_db(struct database *db, struct extant_mbox *ext
db->n_mboxen = n_reqd;
}
/*}}}*/
void compute_checksum(const unsigned char *data, size_t len, checksum_t *csum)/*{{{*/
void compute_checksum(const char *data, size_t len, checksum_t *csum)/*{{{*/
{
MD5_CTX md5;
MD5Init(&md5);
MD5Update(&md5, data, len);
MD5Update(&md5, (unsigned char *) data, len);
MD5Final(&md5);
memcpy(csum, md5.digest, sizeof(md5.digest));
return;
......@@ -132,7 +132,7 @@ static int message_is_intact(struct mbox *mb, int idx, char *va, size_t len)/*{{
return 0;
}
/*}}}*/
static int find_number_intact(struct mbox *mb, unsigned char *va, size_t len)/*{{{*/
static int find_number_intact(struct mbox *mb, char *va, size_t len)/*{{{*/
{
/* Pick up the common obvious case first - where new messages have been appended to the
end of the mbox */
......@@ -199,9 +199,9 @@ static signed char fromcheck_table[256];
#undef DEBUG_DFA
static int looks_like_from_separator(off_t n, unsigned char *va, size_t len, int verbose)/*{{{*/
static int looks_like_from_separator(off_t n, char *va, size_t len, int verbose)/*{{{*/
{
unsigned char p;
char p;
int current_state = 0;
int result = 0;
......@@ -210,9 +210,9 @@ static int looks_like_from_separator(off_t n, unsigned char *va, size_t len, int
while (n < len) {
p = va[n++];
if (verbose) {
printf("current_state=%d, p=%02x (%1c) ", current_state, (int)p, ((p>=32)&&(p<=126))?p:'.');
printf("current_state=%d, p=%02x (%1c) ", current_state, (int)(unsigned char)p, ((p>=32)&&(p<=126))?p:'.');
}
current_state = fromcheck_next_state(current_state, (int)fromcheck_table[(int)p]);
current_state = fromcheck_next_state(current_state, (int)fromcheck_table[(int)(unsigned char)p]);
if (verbose) {
printf("next_state=%d\n", current_state);
}
......@@ -255,7 +255,7 @@ static void init_fromcheck_table()/*{{{*/
fromcheck_table['='] = FS_OTHEREMAIL;
}
/*}}}*/
static off_t find_next_from(off_t n, unsigned char *va, size_t len)/*{{{*/
static off_t find_next_from(off_t n, char *va, size_t len)/*{{{*/
{
unsigned char c;
unsigned long hit;
......@@ -300,7 +300,7 @@ scan_again:
return -1;
}
/*}}}*/
static off_t start_of_next_line(off_t n, unsigned char *va, size_t len)/*{{{*/
static off_t start_of_next_line(off_t n, char *va, size_t len)/*{{{*/
{
unsigned char c;
/* We are always starting from 'From ' so we can advance before testing */
......@@ -318,7 +318,7 @@ static off_t start_of_next_line(off_t n, unsigned char *va, size_t len)/*{{{*/
/*}}}*/
static struct message_list *build_new_message_list(struct mbox *mb, unsigned char *va, size_t len, int *n_messages)/*{{{*/
static struct message_list *build_new_message_list(struct mbox *mb, char *va, size_t len, int *n_messages)/*{{{*/
{
struct message_list *result, *here, *next;
off_t start_from, start_pos, end_from;
......@@ -393,7 +393,7 @@ done:
}
/*}}}*/
static void append_new_messages(struct mbox *mb, struct message_list *list, int n, unsigned char *va)/*{{{*/
static void append_new_messages(struct mbox *mb, struct message_list *list, int n)/*{{{*/
{
int j;
struct message_list *here, *next;
......@@ -417,7 +417,7 @@ static void append_new_messages(struct mbox *mb, struct message_list *list, int
mb->n_msgs = N;
}
/*}}}*/
static void rescan_mbox(struct mbox *mb, unsigned char *va, size_t len)/*{{{*/
static void rescan_mbox(struct mbox *mb, char *va, size_t len)/*{{{*/
{
/* We get here if it's determined that
* 1. the mbox file still exists
......@@ -431,7 +431,7 @@ static void rescan_mbox(struct mbox *mb, unsigned char *va, size_t len)/*{{{*/
/* Find the last message in the box that appears to be intact. */
mb->n_old_msgs_valid = find_number_intact(mb, va, len);
new_messages = build_new_message_list(mb, va, len, &n_new_messages);
append_new_messages(mb, new_messages, n_new_messages, va);
append_new_messages(mb, new_messages, n_new_messages);
}
/*}}}*/
static void deaden_mbox(struct mbox *mb)/*{{{*/
......@@ -684,7 +684,7 @@ static void handle_single(char *path, int base_len, struct string_list *list,/*{
}
}
/*}}}*/
int filter_is_file(const char *x, struct stat *sb)/*{{{*/
static int filter_is_file(const char *x, const struct stat *sb)/*{{{*/
{
if (S_ISREG(sb->st_mode))
return 1;
......@@ -692,7 +692,7 @@ int filter_is_file(const char *x, struct stat *sb)/*{{{*/
return 0;
}
/*}}}*/
enum traverse_check scrutinize_mbox_entry(int parent_is_mbox, const char *de_name, const struct stat *sb)/*{{{*/
enum traverse_check scrutinize_mbox_entry(int parent_is_mbox, const char *de_name)/*{{{*/
{
/* We have to keep looking at everything in this case. */
return TRAV_PROCESS;
......@@ -871,7 +871,7 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/
int len;
create_ro_mapping(mb->path, &va, &len);
if (va) {
rescan_mbox(mb, va, len);
rescan_mbox(mb, (char *) va, len);
free_ro_mapping(va, len);
} else if (!len) {
mb->n_old_msgs_valid = mb->n_msgs = 0;
......@@ -931,7 +931,7 @@ int add_mbox_messages(struct database *db)/*{{{*/
start = mb->start[j];
len = mb->len[j];
msg_src = setup_msg_src(mb->path, start, len);
r8 = data_to_rfc822(msg_src, va + start, len);
r8 = data_to_rfc822(msg_src, (char *) va + start, len);
if (r8) {
if (verbose) {
printf("Scanning %s[%d] at [%d,%d)\n", mb->path, j, (int)start, (int)(start + len));
......
......@@ -35,9 +35,10 @@
#include "reader.h"
#include "memmac.h"
#include "mairix.h"
int read_increment(unsigned char **encpos) {/*{{{*/
char *j = *encpos;
unsigned char *j = *encpos;
int result;
unsigned char x0, x1, x2, x3;
......
......@@ -1056,7 +1056,7 @@ void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{
return;
}
*data = (char *) mmap(0, *len, PROT_READ, MAP_SHARED, fd, 0);
*data = (unsigned char *) mmap(0, *len, PROT_READ, MAP_SHARED, fd, 0);
if (close(fd) < 0)
perror("close");
if (*data == MAP_FAILED) {
......@@ -1096,10 +1096,10 @@ static struct msg_src *setup_msg_src(char *filename)/*{{{*/
struct rfc822 *make_rfc822(char *filename)/*{{{*/
{
int len;
char *data;
unsigned char *data;
struct rfc822 *result;
create_ro_mapping(filename, (unsigned char **)&data, &len);
create_ro_mapping(filename, &data, &len);
/* Don't process empty files */
result = NULL;
......@@ -1109,7 +1109,7 @@ struct rfc822 *make_rfc822(char *filename)/*{{{*/
struct msg_src *src;
/* Now process the data */
src = setup_msg_src(filename);
result = data_to_rfc822(src, data, len);
result = data_to_rfc822(src, (char *) data, len);
free_ro_mapping(data, len);
}
......
......@@ -352,7 +352,7 @@ static void match_substring_in_paths(struct read_db *db, char *substring, int ma
}
for (i=0; i<db->n_msgs; i++) {
char *token = NULL;
int mbix, msgix;
unsigned int mbix, msgix;
switch (db->msg_type[i]) {
case DB_MSG_FILE:
token = db->data + db->path_offsets[i];
......@@ -492,6 +492,7 @@ static void find_size_matches_in_table(struct read_db *db, char *size_expr, char
int has_start, has_end, start_cond, end_cond;
int i;
start = end = -1; /* avoid compiler warning about uninitialised variables. */
parse_size_range(size_expr, &has_start, &start, &has_end, &end);
if (has_start && has_end) {
/* Allow user to put the endpoints in backwards */
......@@ -639,7 +640,7 @@ static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/
start = *mbox_data + db->mtime_table[msg_index];
*msg_len = db->size_table[msg_index];
compute_checksum(start, *msg_len, &csum);
compute_checksum((char *)start, *msg_len, &csum);
if (!memcmp((db->data + db->mbox_checksum_table[mbi] + (msgi * sizeof(checksum_t))), &csum, sizeof(checksum_t))) {
*msg_data = start;
} else {
......@@ -1038,7 +1039,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
break;
case DB_MSG_MBOX:
{
int mbix, msgix;
unsigned int mbix, msgix;
int start, len, after_end;
start = db->mtime_table[i];
len = db->size_table[i];
......
......@@ -2,7 +2,7 @@
mairix - message index builder and finder for maildir folders.
**********************************************************************
* Copyright (C) Richard P. Curnow 2002-2004
* Copyright (C) Richard P. Curnow 2002-2004, 2005
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
......@@ -242,20 +242,20 @@ void insert_index_on_encoding(struct matches *m, int idx)/*{{{*/
m->highest = idx;
}
/*}}}*/
void add_token_in_file(int file_index, unsigned int hash_key, unsigned char *tok_text, struct toktable *table)/*{{{*/
void add_token_in_file(int file_index, unsigned int hash_key, char *tok_text, struct toktable *table)/*{{{*/
{
unsigned long hash;
int index;
struct token *tok;
unsigned char *lc_tok_text;
unsigned char *p;
char *lc_tok_text;
char *p;
lc_tok_text = (unsigned char *) new_string((char*)tok_text);
lc_tok_text = new_string((char*)tok_text);
for (p = lc_tok_text; *p; p++) {
*p = tolower(*p);
*p = tolower(*(unsigned char *) p);
}
/* 2nd arg is string length */
hash = hashfn(lc_tok_text, p - lc_tok_text, hash_key);
hash = hashfn((unsigned char *) lc_tok_text, p - lc_tok_text, hash_key);
if (table->n >= table->hwm) {
enlarge_toktable(table);
......@@ -274,7 +274,7 @@ void add_token_in_file(int file_index, unsigned int hash_key, unsigned char *tok
/* Allocate new */
struct token *new_tok = new_token();
/* New token takes ownership of lc_tok_text, no need to free that later. */
new_tok->text = lc_tok_text;
new_tok->text = (char *) lc_tok_text;
new_tok->hashval = hash; /* save full width for later */
table->tokens[index] = new_tok;
++table->n;
......@@ -301,7 +301,7 @@ void add_token2_in_file(int file_index, unsigned int hash_key, char *tok_text, s
*p = tolower(*(unsigned char *) p);
}
/* 2nd arg is string length */
hash = hashfn(lc_tok_text, p - lc_tok_text, hash_key);
hash = hashfn((unsigned char *) lc_tok_text, p - lc_tok_text, hash_key);
if (table->n >= table->hwm) {
enlarge_toktable2(table);
......
......@@ -298,7 +298,7 @@ static void write_header(char *data, unsigned int *uidata, struct database *db,
return;
}
/*}}}*/
static char *write_type_table(struct database *db, unsigned int *uidata, unsigned char *data, unsigned char *cdata)/*{{{*/
static char *write_type_table(struct database *db, unsigned int *uidata, char *data, char *cdata)/*{{{*/
{
int i;
for (i=0; i<db->n_msgs; i++) {
......@@ -376,10 +376,10 @@ static int compare_tokens(const void *a, const void *b)/*{{{*/
/*}}}*/
#endif
static char *write_mbox_headers(struct database *db, struct write_map *map, unsigned int *uidata, unsigned char *data, unsigned char *cdata)/*{{{*/
static char *write_mbox_headers(struct database *db, struct write_map *map, unsigned int *uidata, char *data, char *cdata)/*{{{*/
{
int i, len;
unsigned char *start_cdata = cdata;
char *start_cdata = cdata;
for (i=0; i<db->n_mboxen; i++) {
struct mbox *mb = &db->mboxen[i];
......@@ -402,10 +402,10 @@ static char *write_mbox_headers(struct database *db, struct write_map *map, uns
return cdata;
}
/*}}}*/
static char * write_mbox_checksums(struct database *db, struct write_map *map, unsigned int *uidata, unsigned char *data, unsigned char *cdata)/*{{{*/
static char * write_mbox_checksums(struct database *db, struct write_map *map, unsigned int *uidata, char *data, char *cdata)/*{{{*/
{
int i, j;
unsigned char *start_cdata = cdata;
char *start_cdata = cdata;
for (i=0; i<db->n_mboxen; i++) {
struct mbox *mb = &db->mboxen[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment