]> git.cworth.org Git - mnemon/commitdiff
More cleanup of "unsigned vs. signed" integer comparison.
authorCarl Worth <cworth@cworth.org>
Mon, 26 Sep 2011 05:18:25 +0000 (22:18 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 26 Sep 2011 05:18:25 +0000 (22:18 -0700)
I keep missing these because a super-module using the mnemon library
has more warning flags enabled than mnemon itself has.

mnemon.c
mnemon.h

index 7b057db25a5c44c18cddd22aa07529951442dbab..ac31422cba7c4eb2f8757e9ed07425250d07ef78 100644 (file)
--- a/mnemon.c
+++ b/mnemon.c
@@ -146,7 +146,7 @@ category_init (category_t *category,
 static void
 category_fini (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]);
 
     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)
 {
 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)
 
     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)
 {
 category_print (category_t     *category,
                FILE            *file)
 {
-    int i;
+    unsigned int i;
     item_t *item;
 
     fprintf (file, "order = %s\n\n",
     item_t *item;
 
     fprintf (file, "order = %s\n\n",
@@ -289,7 +289,7 @@ static int
 bin_item_index (bin_t  *bin,
                item_t  *item)
 {
 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)
 
     for (i = 0; i < bin->num_items; i++)
        if (bin->items[i] == item)
index b66bb44ec6d4ca7d1449fb197f583933e868afb8..27e02a075b52db8b352db442e3211c1bac68486d 100644 (file)
--- a/mnemon.h
+++ b/mnemon.h
@@ -32,8 +32,8 @@ typedef struct _item {
 
 typedef struct _bin {
     int score;
 
 typedef struct _bin {
     int score;
-    int items_size;
-    int num_items;
+    unsigned int items_size;
+    unsigned int num_items;
     item_t **items;
 } bin_t;
 
     item_t **items;
 } bin_t;
 
@@ -44,15 +44,15 @@ typedef enum {
 
 typedef struct _category {
     char *name;
 
 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;
     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) */
     /* 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;
 
 typedef struct _mnemon {
     char *dir_name;
 
-    int categories_size;
-    int num_categories;
+    unsigned int categories_size;
+    unsigned int num_categories;
     category_t *categories;
 
     category_t *categories;
 
-    int bins_size;
-    int num_bins;
+    unsigned int bins_size;
+    unsigned int num_bins;
     bin_t *bins;
 } mnemon_t;
 
     bin_t *bins;
 } mnemon_t;