Currently this option is disabled but the number of warnings it
triggers is moderate. This patch fixes all of them and enables the
warning.
OSL_CPPFLAGS += -DOSL_VERSION='"$(VERSION)"'
OSL_CPPFLAGS += -DOSL_VERSION='"$(VERSION)"'
-OSL_CFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
+OSL_CFLAGS += -g -Wunused -Wundef -W
OSL_CFLAGS += -Wredundant-decls
OSL_CFLAGS += -Os
OSL_CFLAGS += -Wall
OSL_CFLAGS += -Wredundant-decls
OSL_CFLAGS += -Os
OSL_CFLAGS += -Wall
*/
static int check_index_ranges(struct osl_table *t)
{
*/
static int check_index_ranges(struct osl_table *t)
{
+ int ret;
+ unsigned k, n;
INFO_LOG("checking for range violations in index\n");
//DEBUG_LOG("%d rows. %d columns\n", t->num_rows, t->desc->num_columns);
t->num_invalid_rows = 0;
INFO_LOG("checking for range violations in index\n");
//DEBUG_LOG("%d rows. %d columns\n", t->num_rows, t->desc->num_columns);
t->num_invalid_rows = 0;
- for (i = 0; i < t->num_rows; i++) {
+ for (n = 0; n < t->num_rows; n++) {
const struct osl_column_description *cd;
const struct osl_column_description *cd;
- if (row_is_invalid(t, i)) {
+ if (row_is_invalid(t, n)) {
t->num_invalid_rows++;
continue;
}
t->num_invalid_rows++;
continue;
}
- FOR_EACH_MAPPED_COLUMN(j, t, cd) {
- ret = check_range(t, i, j);
+ FOR_EACH_MAPPED_COLUMN(k, t, cd) {
+ ret = check_range(t, n, k);
if (ret < 0) {
if (ret != -E_FSCK_RANGE_VIOLATION)
goto err;
if (ret < 0) {
if (ret != -E_FSCK_RANGE_VIOLATION)
goto err;
- ret = fsck_mark_row_invalid(t, i);
+ ret = fsck_mark_row_invalid(t, n);
if (ret < 0)
goto err;
t->num_invalid_rows++;
if (ret < 0)
goto err;
t->num_invalid_rows++;
static int check_for_invalid_objects(struct osl_table *t, uint32_t **lost_bytes)
{
static int check_for_invalid_objects(struct osl_table *t, uint32_t **lost_bytes)
{
+ int ret;
+ unsigned k, n;
const struct osl_column_description *cd;
uint32_t *loss = fsck_malloc(sizeof(uint32_t) * t->desc->num_columns);
INFO_LOG("looking for mapped objects not contained in index\n");
/* first count used bytes */
const struct osl_column_description *cd;
uint32_t *loss = fsck_malloc(sizeof(uint32_t) * t->desc->num_columns);
INFO_LOG("looking for mapped objects not contained in index\n");
/* first count used bytes */
- FOR_EACH_MAPPED_COLUMN(i, t, cd) {
- loss[i] = t->columns[i].data_map.size;
- DEBUG_LOG("column %i data map: %zu bytes\n", i,
- t->columns[i].data_map.size);
- for (j = 0; j < t->num_rows; j++) {
+ FOR_EACH_MAPPED_COLUMN(k, t, cd) {
+ loss[k] = t->columns[k].data_map.size;
+ DEBUG_LOG("column %i data map: %zu bytes\n", k,
+ t->columns[k].data_map.size);
+ for (n = 0; n < t->num_rows; n++) {
- ret = get_mapped_object(t, i, j, &obj);
+ ret = get_mapped_object(t, k, n, &obj);
- FOR_EACH_MAPPED_COLUMN(i, t, cd) {
- if (loss[i]) {
+ FOR_EACH_MAPPED_COLUMN(k, t, cd) {
+ if (loss[k]) {
NOTICE_LOG("column %u contains %u lost bytes\n",
NOTICE_LOG("column %u contains %u lost bytes\n",
/* prune_invalid_rows() must be run on the table before calling this */
static int prune_mapped_column(struct osl_table *t, uint32_t col_num, int fd)
{
/* prune_invalid_rows() must be run on the table before calling this */
static int prune_mapped_column(struct osl_table *t, uint32_t col_num, int fd)
{
uint32_t written = 0;
struct osl_column *col = t->columns + col_num;
INFO_LOG("pruning col %u\n", col_num);
uint32_t written = 0;
struct osl_column *col = t->columns + col_num;
INFO_LOG("pruning col %u\n", col_num);
- for (i = 0; i < t->num_rows; i++) {
+ for (n = 0; n < t->num_rows; n++) {
struct osl_object obj;
char *index_entry;
struct osl_object obj;
char *index_entry;
- DEBUG_LOG("checking row %u/%u\n", i, t->num_rows);
- ret = get_mapped_object(t, col_num, i, &obj);
+ DEBUG_LOG("checking row %u/%u\n", n, t->num_rows);
+ ret = get_mapped_object(t, col_num, n, &obj);
if (ret < 0)
return ret;
ret = _write_all(fd, (char *)(obj.data), obj.size);
if (ret < 0)
return ret;
written += obj.size;
if (ret < 0)
return ret;
ret = _write_all(fd, (char *)(obj.data), obj.size);
if (ret < 0)
return ret;
written += obj.size;
- ret = get_row_index(t, i, &index_entry);
+ ret = get_row_index(t, n, &index_entry);
if (ret < 0)
return ret;
update_cell_index(index_entry, col, written, obj.size);
if (ret < 0)
return ret;
update_cell_index(index_entry, col, written, obj.size);
static int check_disk_storage_presence(struct osl_table *t)
{
static int check_disk_storage_presence(struct osl_table *t)
{
+ int ret;
+ unsigned k, n;
struct osl_object obj, hash_obj = {.size = HASH_SIZE};
char *ds_name;
const struct osl_column_description *cd;
struct osl_object obj, hash_obj = {.size = HASH_SIZE};
char *ds_name;
const struct osl_column_description *cd;
return 1;
hashes = fsck_malloc(t->num_rows * HASH_SIZE);
INFO_LOG("looking for missing disk storage objects\n");
return 1;
hashes = fsck_malloc(t->num_rows * HASH_SIZE);
INFO_LOG("looking for missing disk storage objects\n");
- for (i = 0; i < t->num_rows; i++) {
- if (row_is_invalid(t, i))
+ for (k = 0; k < t->num_rows; k++) {
+ if (row_is_invalid(t, k))
- ret = get_mapped_object(t, dsnc, i, &obj);
+ ret = get_mapped_object(t, dsnc, k, &obj);
- hash_object(&obj, hashes + i * HASH_SIZE);
- hash_obj.data = hashes + i * HASH_SIZE;
+ hash_object(&obj, hashes + k * HASH_SIZE);
+ hash_obj.data = hashes + k * HASH_SIZE;
osl_add_row(hash_tree_table, &hash_obj);
osl_add_row(hash_tree_table, &hash_obj);
- ds_name = disk_storage_name_of_hash(t, hashes + i * HASH_SIZE);
- FOR_EACH_DISK_STORAGE_COLUMN(j, t, cd) {
- ret = check_disk_storage_column(t, i, j, ds_name,
+ ds_name = disk_storage_name_of_hash(t, hashes + k * HASH_SIZE);
+ FOR_EACH_DISK_STORAGE_COLUMN(n, t, cd) {
+ ret = check_disk_storage_column(t, k, n, ds_name,
&missing_objects);
if (ret < 0)
goto err;
&missing_objects);
if (ret < 0)
goto err;
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
char *errctx = NULL;
const char *dd;
char *errctx = NULL;
const char *dd;
ret = check_all_tables(dd);
goto out;
}
ret = check_all_tables(dd);
goto out;
}
- for (i = 0; i < lls_num_inputs(lpr); i++) {
- ret = check_table(dd, lls_input(i, lpr));
+ for (n = 0; n < lls_num_inputs(lpr); n++) {
+ ret = check_table(dd, lls_input(n, lpr));
int row_is_invalid(struct osl_table *t, uint32_t row_num)
{
char *row_index;
int row_is_invalid(struct osl_table *t, uint32_t row_num)
{
char *row_index;
- int i, ret = get_row_index(t, row_num, &row_index);
+ int ret = get_row_index(t, row_num, &row_index);
+ unsigned n;
- for (i = 0; i < t->row_index_size; i++) {
- if ((unsigned char)row_index[i] != 0xff)
+ for (n = 0; n < t->row_index_size; n++) {
+ if ((unsigned char)row_index[n] != 0xff)
return 0;
}
INFO_LOG("row %d is invalid\n", row_num);
return 0;
}
INFO_LOG("row %d is invalid\n", row_num);
*/
int init_rbtrees(struct osl_table *t)
{
*/
int init_rbtrees(struct osl_table *t)
{
const struct osl_column_description *cd;
/* create rbtrees */
const struct osl_column_description *cd;
/* create rbtrees */
- FOR_EACH_RBTREE_COLUMN(i, t, cd)
- t->columns[i].rbtree = RB_ROOT;
+ FOR_EACH_RBTREE_COLUMN(n, t, cd)
+ t->columns[n].rbtree = RB_ROOT;
/* add valid rows to rbtrees */
t->num_invalid_rows = 0;
/* add valid rows to rbtrees */
t->num_invalid_rows = 0;
- for (i = 0; i < t->num_rows; i++) {
+ for (n = 0; n < t->num_rows; n++) {
struct osl_object *volatile_objs;
struct osl_object *volatile_objs;
- ret = row_is_invalid(t, i);
+ ret = row_is_invalid(t, n);
if (ret < 0)
return ret;
if (ret) {
if (ret < 0)
return ret;
if (ret) {
return -E_OSL_NOMEM;
} else
volatile_objs = NULL;
return -E_OSL_NOMEM;
} else
volatile_objs = NULL;
- ret = add_row_to_rbtrees(t, i, volatile_objs, NULL);
+ ret = add_row_to_rbtrees(t, n, volatile_objs, NULL);
if (ret < 0)
return ret;
}
if (ret < 0)
return ret;
}
* \sa FOR_EACH_COLUMN_OF_TYPE, FOR_EACH_MAPPED_COLUMN, FOR_EACH_RBTREE_COLUMN,
* FOR_EACH_DISK_STORAGE_COLUMN, FOR_EACH_VOLATILE_COLUMN, osl_storage_type.
*/
* \sa FOR_EACH_COLUMN_OF_TYPE, FOR_EACH_MAPPED_COLUMN, FOR_EACH_RBTREE_COLUMN,
* FOR_EACH_DISK_STORAGE_COLUMN, FOR_EACH_VOLATILE_COLUMN, osl_storage_type.
*/
-_static_inline_ int next_column_of_type(enum osl_storage_type type, int col_num,
- const struct osl_table *t,
+_static_inline_ unsigned next_column_of_type(enum osl_storage_type type,
+ unsigned col_num, const struct osl_table *t,
const struct osl_column_description **cd)
{
*cd = NULL;
const struct osl_column_description **cd)
{
*cd = NULL;
static void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
{
static void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
{
- int lenW = ctx->size & 63;
+ unsigned lenW = ctx->size & 63;
ctx->size += len;
/* Read the data into W and process blocks as they get full */
if (lenW) {
ctx->size += len;
/* Read the data into W and process blocks as they get full */
if (lenW) {
+ unsigned left = 64 - lenW;
if (len < left)
left = len;
memcpy(lenW + (char *)ctx->W, data, left);
if (len < left)
left = len;
memcpy(lenW + (char *)ctx->W, data, left);
n = vsnprintf(p, size, fmt, ap);
va_end(ap);
/* If that worked, return the string. */
n = vsnprintf(p, size, fmt, ap);
va_end(ap);
/* If that worked, return the string. */
- if (n > -1 && n < size)
+ if (n > -1 && (unsigned)n < size)
break;
/* Else try again with more space. */
if (n > -1) /* glibc 2.1 */
break;
/* Else try again with more space. */
if (n > -1) /* glibc 2.1 */