From: Carl Worth Date: Mon, 26 Sep 2011 05:18:25 +0000 (-0700) Subject: More cleanup of "unsigned vs. signed" integer comparison. X-Git-Url: https://git.cworth.org/git?p=mnemon;a=commitdiff_plain;h=5ae11041e3b0f7c5a04795c71fe3794d663eb195 More cleanup of "unsigned vs. signed" integer comparison. I keep missing these because a super-module using the mnemon library has more warning flags enabled than mnemon itself has. --- diff --git a/mnemon.c b/mnemon.c index 7b057db..ac31422 100644 --- a/mnemon.c +++ b/mnemon.c @@ -146,7 +146,7 @@ category_init (category_t *category, static void category_fini (category_t *category) { - int i; + unsigned int i; for (i = 0; i < category->num_items; i++) item_fini (&category->items[i]); @@ -191,7 +191,7 @@ category_add_item (category_t *category, static item_t * category_next_bin_zero_item (category_t *category) { - int *i = &category->bin_zero_head; + unsigned int *i = &category->bin_zero_head; for ( ; *i < category->num_items; *i = *i + 1) if (category->items[*i].score == 0) @@ -204,7 +204,7 @@ static void category_print (category_t *category, FILE *file) { - int i; + unsigned int i; item_t *item; fprintf (file, "order = %s\n\n", @@ -289,7 +289,7 @@ static int bin_item_index (bin_t *bin, item_t *item) { - int i; + unsigned int i; for (i = 0; i < bin->num_items; i++) if (bin->items[i] == item) diff --git a/mnemon.h b/mnemon.h index b66bb44..27e02a0 100644 --- a/mnemon.h +++ b/mnemon.h @@ -32,8 +32,8 @@ typedef struct _item { typedef struct _bin { int score; - int items_size; - int num_items; + unsigned int items_size; + unsigned int num_items; item_t **items; } bin_t; @@ -44,15 +44,15 @@ typedef enum { typedef struct _category { char *name; - int items_size; - int num_items; + unsigned int items_size; + unsigned int num_items; item_t *items; /* Support sequential introduction of items from bin 0 */ category_order_t order; /* Support categories where responses are timed (0.0 == disable). */ double time_limit; - int bin_zero_head; + unsigned int bin_zero_head; /* Support challenges of non-text types (image, audio, etc.) */ char *challenge_type; /* Whether to repeat afterwards (for a little extra reinforcement) */ @@ -62,12 +62,12 @@ typedef struct _category { typedef struct _mnemon { char *dir_name; - int categories_size; - int num_categories; + unsigned int categories_size; + unsigned int num_categories; category_t *categories; - int bins_size; - int num_bins; + unsigned int bins_size; + unsigned int num_bins; bin_t *bins; } mnemon_t;