Lots more gcc warnings fixes

This commit is contained in:
whydoubt 2004-07-09 12:47:04 +00:00
parent 6380e303ff
commit e121a82946
23 changed files with 102 additions and 74 deletions

View File

@ -1,3 +1,27 @@
Fri Jul 9 07:47:27 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* include/mdbsql.h:
* include/mdbtools.h:
* src/extras/mdbsupport.c:
* src/libmdb/catalog.c:
* src/libmdb/data.c:
* src/libmdb/file.c:
* src/libmdb/index.c:
* src/libmdb/sargs.c:
* src/libmdb/table.c:
* src/libmdb/write.c:
* src/sql/mdbsql.c:
* src/util/mdb-array.c:
* src/util/mdb-export.c:
* src/util/mdb-header.c:
* src/util/mdb-import.c:
* src/util/mdb-schema.c:
* src/util/mdb-sql.c:
* src/util/mdb-tables.c:
* src/util/prindex.c:
* src/util/prole.c:
* src/util/prtable.c:
* src/util/updrow.c: Lots more gcc warnings fixes
Fri Jul 2 23:52:34 CDT 2004 Jeff Smith <whydoubt@yahoo.com>
* src/libmdb/backend.c:
* src/libmdb/iconv.c:

View File

@ -9,9 +9,9 @@
typedef struct {
MdbHandle *mdb;
int all_columns;
int num_columns;
unsigned int num_columns;
GPtrArray *columns;
int num_tables;
unsigned int num_tables;
GPtrArray *tables;
MdbTableDef *cur_table;
MdbSargNode *sarg_tree;

View File

@ -219,7 +219,7 @@ typedef struct {
unsigned int cur_pos;
unsigned char pg_buf[MDB_PGSIZE];
unsigned char alt_pg_buf[MDB_PGSIZE];
int num_catalog;
unsigned int num_catalog;
GPtrArray *catalog;
MdbBackend *default_backend;
char *backend_name;
@ -318,17 +318,17 @@ typedef struct {
typedef struct {
MdbCatalogEntry *entry;
char name[MDB_MAX_OBJ_NAME+1];
int num_cols;
unsigned int num_cols;
GPtrArray *columns;
int num_rows;
int index_start;
int num_real_idxs;
int num_idxs;
unsigned int num_real_idxs;
unsigned int num_idxs;
GPtrArray *indices;
guint32 first_data_pg;
guint32 cur_pg_num;
guint32 cur_phys_pg;
int cur_row;
unsigned int cur_row;
int noskip_del; /* don't skip deleted rows */
/* object allocation map */
guint32 map_base_pg;
@ -479,6 +479,7 @@ extern void mdb_index_scan_init(MdbHandle *mdb, MdbTableDef *table);
extern int mdb_index_find_row(MdbHandle *mdb, MdbIndex *idx, MdbIndexChain *chain, guint32 pg, guint16 row);
extern void mdb_index_swap_n(unsigned char *src, int sz, unsigned char *dest);
extern void mdb_free_indices(GPtrArray *indices);
void mdb_index_page_reset(MdbIndexPage *ipg);
/* stats.c */
@ -495,7 +496,7 @@ extern int mdb_like_cmp(char *s, char *r);
extern int mdb_crack_row(MdbTableDef *table, int row_start, int row_end, MdbField *fields);
extern guint16 mdb_add_row_to_pg(MdbTableDef *table, unsigned char *row_buffer, int new_row_size);
extern int mdb_update_index(MdbTableDef *table, MdbIndex *idx, int num_fields, MdbField *fields, guint32 pgnum, guint16 rownum);
extern int mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, int num_fields, MdbField *fields);
extern int mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fields, MdbField *fields);
extern int mdb_replace_row(MdbTableDef *table, int row, unsigned char *new_row, int new_row_size);
extern int mdb_pg_get_freespace(MdbHandle *mdb);
extern int mdb_update_row(MdbTableDef *table);

View File

@ -1,6 +1,7 @@
/* support routines for code generated by the util programs */
#include <stdio.h>
#include <string.h>
void dump_int (int i)
{

View File

@ -238,7 +238,7 @@ int next_pg, next_pg_off;
void
mdb_dump_catalog(MdbHandle *mdb, int obj_type)
{
int i;
unsigned int i;
MdbCatalogEntry *entry;
mdb_read_catalog(mdb, obj_type);

View File

@ -54,7 +54,8 @@ MdbColumn *col;
int
mdb_bind_column_by_name(MdbTableDef *table, gchar *col_name, void *bind_ptr)
{
int i, col_num = -1;
unsigned int i;
int col_num = -1;
MdbColumn *col;
for (i=0;i<table->num_cols;i++) {
@ -192,7 +193,8 @@ int mdb_read_row(MdbTableDef *table, int row)
MdbHandle *mdb = table->entry->mdb;
MdbFormatConstants *fmt = mdb->fmt;
MdbColumn *col;
int i, rc;
unsigned int i;
int rc;
//int num_cols, var_cols, fixed_cols;
int row_start, row_end;
//int fixed_cols_found, var_cols_found;
@ -563,7 +565,7 @@ mdb_fetch_row(MdbTableDef *table)
{
MdbHandle *mdb = table->entry->mdb;
MdbFormatConstants *fmt = mdb->fmt;
int rows;
unsigned int rows;
int rc;
guint32 pg;

View File

@ -197,7 +197,7 @@ MdbHandle *mdb_clone_handle(MdbHandle *mdb)
{
MdbHandle *newmdb;
MdbCatalogEntry *entry, *data;
int i;
unsigned int i;
newmdb = (MdbHandle *) g_memdup(mdb, sizeof(MdbHandle));
newmdb->stats = NULL;

View File

@ -69,7 +69,7 @@ mdb_read_indices(MdbTableDef *table)
MdbHandle *mdb = entry->mdb;
MdbFormatConstants *fmt = mdb->fmt;
MdbIndex *pidx;
int i, j;
unsigned int i, j;
int idx_num, key_num, col_num;
int cur_pos, name_sz, idx2_sz, type_offset;
int index_start_pg = mdb->cur_pg;
@ -827,7 +827,7 @@ int mdb_index_compute_cost(MdbTableDef *table, MdbIndex *idx)
MdbStrategy
mdb_choose_index(MdbTableDef *table, int *choice)
{
int i;
unsigned int i;
MdbIndex *idx;
int cost = 0;
int least = 99;

View File

@ -259,8 +259,8 @@ MdbSarg *sarg;
}
int mdb_add_sarg_by_name(MdbTableDef *table, char *colname, MdbSarg *in_sarg)
{
MdbColumn *col;
int i;
MdbColumn *col;
unsigned int i;
for (i=0;i<table->num_cols;i++) {
col = g_ptr_array_index (table->columns, i);

View File

@ -207,7 +207,8 @@ GPtrArray *mdb_read_columns(MdbTableDef *table)
MdbFormatConstants *fmt = mdb->fmt;
MdbColumn *pcol;
unsigned char *col;
int i, cur_pos, name_sz;
unsigned int i;
int cur_pos, name_sz;
table->columns = g_ptr_array_new();
@ -311,7 +312,7 @@ MdbColumn *col;
int coln;
MdbIndex *idx;
MdbHandle *mdb = entry->mdb;
int i,bitn;
unsigned int i, bitn;
guint32 pgnum;
table = mdb_read_table(entry);

View File

@ -76,8 +76,8 @@ mdb_write_pg(MdbHandle *mdb, unsigned long pg)
static int
mdb_is_col_indexed(MdbTableDef *table, int colnum)
{
int i, j;
MdbIndex *idx;
unsigned int i, j;
MdbIndex *idx;
for (i=0;i<table->num_idxs;i++) {
idx = g_ptr_array_index (table->indices, i);
@ -93,7 +93,7 @@ mdb_crack_row4(MdbTableDef *table, int row_start, int row_end, MdbField *fields)
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
MdbColumn *col;
int i;
unsigned int i;
int var_cols = 0, row_var_cols, fixed_cols = 0, row_fixed_cols, num_cols;
int var_cols_found, fixed_cols_found, var_entry_pos;
int col_start, next_col;
@ -213,7 +213,7 @@ mdb_crack_row3(MdbTableDef *table, int row_start, int row_end, MdbField *fields)
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
MdbColumn *col;
int i;
unsigned int i;
int var_cols = 0, fixed_cols = 0, num_cols;
int row_var_cols = 0, row_fixed_cols = 0;
int var_cols_found, fixed_cols_found, var_entry_pos;
@ -439,7 +439,7 @@ mdb_pack_null_mask(unsigned char *buffer, int num_fields, MdbField *fields)
/* fields must be ordered with fixed columns first, then vars, subsorted by
* column number */
static int
mdb_pack_row4(MdbTableDef *table, unsigned char *row_buffer, int num_fields, MdbField *fields)
mdb_pack_row4(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fields, MdbField *fields)
{
unsigned int pos = 0;
unsigned int var_cols = 0;
@ -487,11 +487,11 @@ mdb_pack_row4(MdbTableDef *table, unsigned char *row_buffer, int num_fields, Mdb
}
static int
mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, int num_fields, MdbField *fields)
mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, unsigned int num_fields, MdbField *fields)
{
unsigned int pos = 0;
unsigned int var_cols = 0;
int i;
unsigned int i;
row_buffer[pos++] = num_fields;
@ -518,8 +518,8 @@ mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, int num_fields, Mdb
row_buffer[pos] = pos;
pos++;
for (i=num_fields-1;i>=(int)(num_fields - var_cols);i--) {
row_buffer[pos++] = fields[i].offset % 256;
for (i=num_fields;i>num_fields-var_cols;i--) {
row_buffer[pos++] = fields[i-1].offset % 256;
}
row_buffer[pos++] = var_cols;
@ -529,7 +529,7 @@ mdb_pack_row3(MdbTableDef *table, unsigned char *row_buffer, int num_fields, Mdb
return pos;
}
int
mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, int num_fields, MdbField *fields)
mdb_pack_row(MdbTableDef *table, unsigned char *row_buffer, int unsigned num_fields, MdbField *fields)
{
if (IS_JET4(table->entry->mdb)) {
return mdb_pack_row4(table, row_buffer, num_fields, fields);
@ -581,7 +581,7 @@ mdb_new_data_pg(MdbCatalogEntry *entry)
int
mdb_update_indexes(MdbTableDef *table, int num_fields, MdbField *fields, guint32 pgnum, guint16 rownum)
{
int i;
unsigned int i;
MdbIndex *idx;
for (i=0;i<table->num_idxs;i++) {
@ -741,14 +741,15 @@ int
mdb_update_row(MdbTableDef *table)
{
int row_start, row_end;
int i;
unsigned int i;
MdbColumn *col;
MdbCatalogEntry *entry = table->entry;
MdbHandle *mdb = entry->mdb;
MdbFormatConstants *fmt = mdb->fmt;
MdbField fields[256];
unsigned char row_buffer[4096];
int old_row_size, new_row_size, delta, num_fields;
int old_row_size, new_row_size, delta;
unsigned int num_fields;
if (!mdb->f->writable) {
fprintf(stderr, "File is not open for writing\n");

View File

@ -407,9 +407,9 @@ MdbSQLTable *t;
}
void mdb_sql_dump(MdbSQL *sql)
{
int i;
MdbSQLColumn *c;
MdbSQLTable *t;
unsigned int i;
MdbSQLColumn *c;
MdbSQLTable *t;
for (i=0;i<sql->num_columns;i++) {
c = g_ptr_array_index(sql->columns,i);
@ -422,9 +422,9 @@ MdbSQLTable *t;
}
void mdb_sql_exit(MdbSQL *sql)
{
int i;
MdbSQLColumn *c;
MdbSQLTable *t;
unsigned int i;
MdbSQLColumn *c;
MdbSQLTable *t;
for (i=0;i<sql->num_columns;i++) {
c = g_ptr_array_index(sql->columns,i);
@ -448,9 +448,9 @@ MdbSQLTable *t;
}
void mdb_sql_reset(MdbSQL *sql)
{
int i;
MdbSQLColumn *c;
MdbSQLTable *t;
unsigned int i;
MdbSQLColumn *c;
MdbSQLTable *t;
if (sql->cur_table) {
mdb_index_scan_free(sql->cur_table);
@ -512,7 +512,7 @@ int vlen;
}
void mdb_sql_listtables(MdbSQL *sql)
{
int i;
unsigned int i;
MdbCatalogEntry *entry;
MdbHandle *mdb = sql->mdb;
MdbField fields[1];
@ -576,7 +576,7 @@ void mdb_sql_describe_table(MdbSQL *sql)
MdbSQLTable *sql_tab;
MdbHandle *mdb = sql->mdb;
MdbColumn *col;
int i;
unsigned int i;
MdbField fields[3];
char tmpstr[256];
unsigned char row_buffer[MDB_PGSIZE];
@ -641,7 +641,7 @@ void mdb_sql_describe_table(MdbSQL *sql)
int mdb_sql_find_sargcol(MdbSargNode *node, gpointer data)
{
MdbTableDef *table = data;
int i;
unsigned int i;
MdbColumn *col;
if (!mdb_is_relational_op(node->op)) return 0;
@ -659,7 +659,7 @@ int mdb_sql_find_sargcol(MdbSargNode *node, gpointer data)
void
mdb_sql_select(MdbSQL *sql)
{
int i,j;
unsigned int i,j;
MdbHandle *mdb = sql->mdb;
MdbTableDef *table = NULL;
MdbSQLTable *sql_tab;
@ -737,7 +737,7 @@ mdb_sql_bind_column(MdbSQL *sql, int colnum, char *varaddr)
MdbTableDef *table = sql->cur_table;
MdbSQLColumn *sqlcol;
MdbColumn *col;
int j;
unsigned int j;
/* sql columns are traditionally 1 based, so decrement colnum */
sqlcol = g_ptr_array_index(sql->columns,colnum - 1);
@ -756,7 +756,7 @@ mdb_sql_bind_len(MdbSQL *sql, int colnum, int *len_ptr)
MdbTableDef *table = sql->cur_table;
MdbSQLColumn *sqlcol;
MdbColumn *col;
int j;
unsigned int j;
/* sql columns are traditionally 1 based, so decrement colnum */
sqlcol = g_ptr_array_index(sql->columns,colnum - 1);
@ -772,11 +772,10 @@ int j;
void
mdb_sql_bind_all(MdbSQL *sql)
{
int i;
unsigned int i;
for (i=0;i<sql->num_columns;i++) {
sql->bound_values[i] = (char *) g_malloc(MDB_BIND_SIZE);
sql->bound_values[i][0] = '\0';
sql->bound_values[i] = (char *) g_malloc0(MDB_BIND_SIZE);
mdb_sql_bind_column(sql, i+1, sql->bound_values[i]);
}
}
@ -808,8 +807,8 @@ mdb_sql_fetch_row(MdbSQL *sql, MdbTableDef *table)
void
mdb_sql_dump_results(MdbSQL *sql)
{
int j;
MdbSQLColumn *sqlcol;
unsigned int j;
MdbSQLColumn *sqlcol;
/* print header */
for (j=0;j<sql->num_columns;j++) {

View File

@ -30,7 +30,7 @@
int
main (int argc, char **argv)
{
int j;
unsigned int j;
MdbHandle *mdb;
MdbTableDef *table;
MdbColumn *col;

View File

@ -49,7 +49,7 @@ print_col(gchar *col_val, int quote_text, int col_type)
int
main(int argc, char **argv)
{
int j;
unsigned int j;
MdbHandle *mdb;
MdbTableDef *table;
MdbColumn *col;

View File

@ -35,7 +35,7 @@ void copy_header (FILE *f)
int
main (int argc, char **argv)
{
int i, j, k;
unsigned int i, j, k;
MdbHandle *mdb;
MdbCatalogEntry *entry;
MdbTableDef *table;

View File

@ -109,7 +109,7 @@ prep_row(MdbTableDef *table, unsigned char *line, MdbField *fields, char *delim)
MdbColumn *col;
char delims[20];
char *s;
int file_cols;
unsigned int file_cols;
/*
* pull apart the row and turn it into something respectable

View File

@ -30,7 +30,7 @@ static void generate_table_schema(MdbCatalogEntry *entry, char *namespace, int s
int
main (int argc, char **argv)
{
int i;
unsigned int i;
MdbHandle *mdb;
MdbCatalogEntry *entry;
char *the_relation;
@ -131,7 +131,7 @@ generate_table_schema(MdbCatalogEntry *entry, char *namespace, int sanitize)
{
MdbTableDef *table;
MdbHandle *mdb = entry->mdb;
int i;
unsigned int i;
MdbColumn *col;
/* make sure it's a table (may be redundant) */

View File

@ -167,12 +167,12 @@ do_set_cmd(MdbSQL *sql, char *s)
}
int
read_file(char *s, int line, int *bufsz, char *mybuf)
read_file(char *s, int line, unsigned int *bufsz, char *mybuf)
{
char *fname;
FILE *in;
char buf[256];
int cursz = 0;
unsigned int cursz = 0;
int lines = 0;
fname = s;
@ -252,12 +252,9 @@ int i;
void
dump_results(MdbSQL *sql)
{
int j;
unsigned int j;
MdbSQLColumn *sqlcol;
unsigned long row_count = 0;
int rows, rc, i;
MdbHandle *mdb = sql->mdb;
MdbFormatConstants *fmt = mdb->fmt;
if (headers) {
for (j=0;j<sql->num_columns-1;j++) {
@ -292,12 +289,14 @@ dump_results(MdbSQL *sql)
void
dump_results_pp(MdbSQL *sql)
{
int j;
unsigned int j;
MdbSQLColumn *sqlcol;
unsigned long row_count = 0;
/*
int rows, rc, i;
MdbHandle *mdb = sql->mdb;
MdbFormatConstants *fmt = mdb->fmt;
*/
/* print header */
if (headers) {
@ -381,7 +380,7 @@ char *s;
char prompt[20];
int line = 1;
char *mybuf;
int bufsz = 4096;
unsigned int bufsz = 4096;
int done = 0;
MdbSQL *sql;
int opt;
@ -475,7 +474,7 @@ char *histpath;
} else {
while (strlen(mybuf) + strlen(s) > bufsz) {
bufsz *= 2;
mybuf = (char *) realloc(mybuf, bufsz);
mybuf = (char *) g_realloc(mybuf, bufsz);
}
/* don't record blank lines */
if (strlen(s)) add_history(s);

View File

@ -78,7 +78,7 @@ get_obj_type(char *typename, int *ret)
int
main (int argc, char **argv)
{
int i;
unsigned int i;
MdbHandle *mdb;
MdbCatalogEntry *entry;
char *delimiter = NULL;

View File

@ -26,7 +26,7 @@ void walk_index(MdbHandle *mdb, MdbIndex *idx);
int
main(int argc, char **argv)
{
int j;
unsigned int j;
MdbHandle *mdb;
MdbTableDef *table;
MdbIndex *idx;

View File

@ -65,7 +65,7 @@ main(int argc, char **argv)
void dump_ole(MdbTableDef *table, char *colname, char *sargname)
{
int i, found = 0;
unsigned int i, found = 0;
char ole_data[200000];
int len;
MdbColumn *col;

View File

@ -23,7 +23,7 @@
int
main(int argc, char **argv)
{
int i;
unsigned int i;
MdbHandle *mdb;
MdbCatalogEntry *entry;
int found = 0;

View File

@ -72,8 +72,8 @@ int len;
int bind_column(MdbTableDef *table, char *colname, unsigned char *data, int *len)
{
int i, found = 0;
MdbColumn *col;
unsigned int i, found = 0;
MdbColumn *col;
for (i=0;i<table->num_cols;i++) {
col=g_ptr_array_index(table->columns,i);
@ -91,7 +91,7 @@ void read_to_row(MdbTableDef *table, char *sargname)
{
static MdbSargNode sarg;
char *sargcol, *sargop, *sargval;
int i;
unsigned int i;
MdbColumn *col;