From 7ec83051c05777c0e6e2eea6ef6c71effede9527 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 7 Jun 2012 13:32:57 -0400 Subject: [PATCH] Fix warnings --- util/ansi-print.cc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/util/ansi-print.cc b/util/ansi-print.cc index fde06f105..873bee809 100644 --- a/util/ansi-print.cc +++ b/util/ansi-print.cc @@ -212,34 +212,30 @@ struct biimage_t const char * block_best (const biimage_t &bi, unsigned int *score, bool *inverse) { - unsigned int row_sum[bi.height]; - unsigned int col_sum[bi.width]; - unsigned int row_sum_i[bi.height]; - unsigned int col_sum_i[bi.width]; + assert (bi.width <= CELL_W); + assert (bi.height <= CELL_H); - for (unsigned int i = 0; i < bi.height; i++) - row_sum[i] = row_sum_i[i] = 0; - for (unsigned int i = 0; i < bi.width; i++) - col_sum[i] = col_sum_i[i] = 0; - - unsigned int total = 0; - unsigned int total_i = 0; + unsigned int row_sum[CELL_H] = {0}; + unsigned int col_sum[CELL_W] = {0}; + unsigned int row_sum_i[CELL_H] = {0}; + unsigned int col_sum_i[CELL_W] = {0}; unsigned int quad[2][2] = {{0}}; unsigned int quad_i[2][2] = {{0}}; + unsigned int total = 0; + unsigned int total_i = 0; for (unsigned int y = 0; y < bi.height; y++) for (unsigned int x = 0; x < bi.width; x++) { unsigned int c = bi (x, y); + unsigned int c_i = 255 - c; row_sum[y] += c; + row_sum_i[y] += c_i; col_sum[x] += c; + col_sum_i[x] += c_i; quad[2 * y / bi.height][2 * x / bi.width] += c; - quad_i[2 * y / bi.height][2 * x / bi.width] += 255 - c; + quad_i[2 * y / bi.height][2 * x / bi.width] += c_i; total += c; - total_i += 255 - c; + total_i += c_i; } - for (unsigned int i = 0; i < bi.height; i++) - row_sum_i[i] = 255 * bi.width - row_sum[i]; - for (unsigned int i = 0; i < bi.width; i++) - col_sum_i[i] = 255 * bi.height - col_sum[i]; /* Make the sums cummulative */ for (unsigned int i = 1; i < bi.height; i++) {