Whamcloud - gitweb
Change the xattr entry hash to use an unsighed char by default
[tools/e2fsprogs.git] / lib / ext2fs / badblocks.c
index 9fda70c..0f23983 100644 (file)
@@ -1,14 +1,15 @@
 /*
  * badblocks.c --- routines to manipulate the bad block structure
- * 
+ *
  * Copyright (C) 1994, 1995, 1996 Theodore Ts'o.
  *
  * %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #if HAVE_UNISTD_H
@@ -34,18 +35,17 @@ static errcode_t make_u32_list(int size, int num, __u32 *list,
 {
        ext2_u32_list   bb;
        errcode_t       retval;
-       
-       retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list),
-                               (void **) &bb);
+
+       retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb);
        if (retval)
                return retval;
        memset(bb, 0, sizeof(struct ext2_struct_u32_list));
        bb->magic = EXT2_ET_MAGIC_BADBLOCKS_LIST;
        bb->size = size ? size : 10;
        bb->num = num;
-       retval = ext2fs_get_mem(bb->size * sizeof(blk_t), (void **) &bb->list);
-       if (!bb->list) {
-               ext2fs_free_mem((void **) &bb);
+       retval = ext2fs_get_array(bb->size, sizeof(blk_t), &bb->list);
+       if (retval) {
+               ext2fs_free_mem(&bb);
                return retval;
        }
        if (list)
@@ -55,7 +55,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list,
        *ret = bb;
        return 0;
 }
-       
+
 
 /*
  * This procedure creates an empty u32 list.
@@ -80,7 +80,7 @@ errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size)
 errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest)
 {
        errcode_t       retval;
-       
+
        retval = make_u32_list(src->size, src->num, src->list, dest);
        if (retval)
                return retval;
@@ -117,7 +117,7 @@ errcode_t ext2fs_u32_list_add(ext2_u32_list bb, __u32 blk)
                old_size = bb->size * sizeof(__u32);
                bb->size += 100;
                retval = ext2fs_resize_mem(old_size, bb->size * sizeof(__u32),
-                                          (void **) &bb->list);
+                                          &bb->list);
                if (retval) {
                        bb->size -= 100;
                        return retval;
@@ -178,7 +178,7 @@ int ext2fs_u32_list_find(ext2_u32_list bb, __u32 blk)
                return high;
 
        while (low < high) {
-               mid = (low+high)/2;
+               mid = ((unsigned)low + (unsigned)high)/2;
                if (mid == low || mid == high)
                        break;
                if (blk == bb->list[mid])
@@ -242,8 +242,7 @@ errcode_t ext2fs_u32_list_iterate_begin(ext2_u32_list bb,
 
        EXT2_CHECK_MAGIC(bb, EXT2_ET_MAGIC_BADBLOCKS_LIST);
 
-       retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_iterate),
-                             (void **) &iter);
+       retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_iterate), &iter);
        if (retval)
                return retval;
 
@@ -273,11 +272,11 @@ int ext2fs_u32_list_iterate(ext2_u32_iterate iter, __u32 *blk)
 
        if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
                return 0;
-       
+
        if (iter->ptr < bb->num) {
                *blk = bb->list[iter->ptr++];
                return 1;
-       } 
+       }
        *blk = 0;
        return 0;
 }
@@ -295,7 +294,7 @@ void ext2fs_u32_list_iterate_end(ext2_u32_iterate iter)
                return;
 
        iter->bb = 0;
-       ext2fs_free_mem((void **) &iter);
+       ext2fs_free_mem(&iter);
 }
 
 void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter)