Whamcloud - gitweb
badblocks: Use unsigned int instead of unsigned long for test patterns
authorTheodore Ts'o <tytso@mit.edu>
Mon, 22 Oct 2007 13:51:50 +0000 (09:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Oct 2007 15:55:19 +0000 (11:55 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/badblocks.c

index 29c5a5c..155fb77 100644 (file)
@@ -67,7 +67,7 @@ static int s_flag = 0;                        /* show progress of test */
 static int force = 0;                  /* force check of mounted device */
 static int t_flag = 0;                 /* number of test patterns */
 static int t_max = 0;                  /* allocated test patterns */
-static unsigned long *t_patts = NULL;  /* test patterns */
+static unsigned int *t_patts = NULL;   /* test patterns */
 static int current_O_DIRECT = 0;       /* Current status of O_DIRECT flag */
 static int exclusive_ok = 0;
 
@@ -221,13 +221,13 @@ static void set_o_direct(int dev, unsigned char *buffer, size_t size,
 }
 
 
-static void pattern_fill(unsigned char *buffer, unsigned long pattern,
+static void pattern_fill(unsigned char *buffer, unsigned int pattern,
                         size_t n)
 {
        unsigned int    i, nb;
        unsigned char   bpattern[sizeof(pattern)], *ptr;
        
-       if (pattern == (unsigned long) ~0) {
+       if (pattern == (unsigned int) ~0) {
                for (ptr = buffer; ptr < buffer + n; ptr++) {
                        (*ptr) = random() % (1 << (8 * sizeof(char)));
                }
@@ -435,8 +435,8 @@ static unsigned int test_rw (int dev, unsigned long last_block,
                             unsigned long blocks_at_once)
 {
        unsigned char *buffer, *read_buffer;
-       const unsigned long patterns[] = {0xaa, 0x55, 0xff, 0x00};
-       const unsigned long *pattern;
+       const unsigned int patterns[] = {0xaa, 0x55, 0xff, 0x00};
+       const unsigned int *pattern;
        int i, try, got, nr_pattern, pat_idx;
        unsigned int bb_count = 0;
 
@@ -562,8 +562,8 @@ static unsigned int test_nd (int dev, unsigned long last_block,
        unsigned char *blkbuf, *save_ptr, *test_ptr, *read_ptr;
        unsigned char *test_base, *save_base, *read_base;
        int try, i;
-       const unsigned long patterns[] = { ~0 };
-       const unsigned long *pattern;
+       const unsigned int patterns[] = { ~0 };
+       const unsigned int *pattern;
        int nr_pattern, pat_idx;
        long got, used2, written, save_currently_testing;
        struct saved_blk_record *test_record;
@@ -830,7 +830,7 @@ int main (int argc, char ** argv)
        int passes_clean = 0;
        int dev;
        errcode_t errcode;
-       unsigned long pattern;
+       unsigned int pattern;
        unsigned int (*test_func)(int, unsigned long,
                                  int, unsigned long,
                                  unsigned long);
@@ -920,7 +920,7 @@ int main (int argc, char ** argv)
                        break;
                case 't':
                        if (t_flag + 1 > t_max) {
-                               unsigned long *t_patts_new;
+                               unsigned int *t_patts_new;
 
                                t_patts_new = realloc(t_patts, t_max + T_INC);
                                if (!t_patts_new) {
@@ -943,7 +943,7 @@ int main (int argc, char ** argv)
                                                optarg);
                                        exit(1);
                                }
-                               if (pattern == (unsigned long) ~0)
+                               if (pattern == (unsigned int) ~0)
                                        pattern = 0xffff;
                                t_patts[t_flag++] = pattern;
                        }
@@ -962,7 +962,7 @@ int main (int argc, char ** argv)
                          "in read-only mode"));
                        exit(1);
                }
-               if (t_patts && (t_patts[0] == (unsigned long) ~0)) {
+               if (t_patts && (t_patts[0] == (unsigned int) ~0)) {
                        com_err(program_name, 0,
                        _("Random test_pattern is not allowed "
                          "in read-only mode"));