From c6aa266a8631c44f5eb30a6b24a838f60ada9532 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Wed, 30 Jul 2014 09:35:08 +0200 Subject: [PATCH] tableprinter: code cleanup --- ucw/table.c | 9 ++++----- ucw/table.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ucw/table.c b/ucw/table.c index 183e9548..a787d587 100644 --- a/ucw/table.c +++ b/ucw/table.c @@ -49,9 +49,8 @@ struct table *table_init(const struct table_template *tbl_template) // initialize column_order if(tbl_template->column_order) { - int cols_to_output = 0; - for(; ; cols_to_output++) { - if(tbl_template->column_order[cols_to_output].idx == (uint) ~0) break; + for(int cols_to_output = 0; ; cols_to_output++) { + if(tbl_template->column_order[cols_to_output].idx == ~0U) break; } new_inst->column_order = mp_alloc_zero(new_inst->pool, sizeof(struct table_col_instance) * cols_to_output); @@ -180,13 +179,13 @@ void table_set_col_order(struct table *tbl, const struct table_col_instance *col { uint cols_to_output = 0; for(; ; cols_to_output++) { - if(col_order[cols_to_output].idx == (uint) ~0) break; + if(col_order[cols_to_output].idx == ~0U) break; ASSERT_MSG(col_order[cols_to_output].idx < (uint) tbl->column_count, "Column %d does not exist; column number should be between 0 and %d(including).", col_order[cols_to_output].idx, tbl->column_count - 1); } tbl->cols_to_output = cols_to_output; - tbl->column_order = mp_alloc_zero(tbl->pool, sizeof(struct table_col_instance) * cols_to_output); + tbl->column_order = mp_alloc(tbl->pool, sizeof(struct table_col_instance) * cols_to_output); memcpy(tbl->column_order, col_order, sizeof(struct table_col_instance) * cols_to_output); for(uint i = 0; i < cols_to_output; i++) { int col_def_idx = tbl->column_order[i].idx; // this is given in col_order diff --git a/ucw/table.h b/ucw/table.h index 6bcc1334..2fdadbbf 100644 --- a/ucw/table.h +++ b/ucw/table.h @@ -194,7 +194,7 @@ struct table { **/ #define TBL_COL(_idx) { .idx = _idx, .fmt = XTYPE_FMT_DEFAULT, .next_column = -1 } #define TBL_COL_FMT(_idx, _fmt) { .idx = _idx, .fmt = _fmt, .next_column = -1 } -#define TBL_COL_ORDER_END { .col_def = 0, .idx = (uint) ~0, .fmt = 0, .next_column = -1 } +#define TBL_COL_ORDER_END { .col_def = 0, .idx = ~0U, .fmt = 0, .next_column = -1 } /** * These macros are aliases to various kinds of table formats. -- 2.39.2