Whamcloud - gitweb
ext2fs: declare struct_io_manager at end of file
authorAndreas Dilger <adilger@dilger.ca>
Tue, 18 Feb 2014 23:31:36 +0000 (18:31 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 18 Feb 2014 23:31:43 +0000 (18:31 -0500)
Declare struct_io_manager at the end of unix_io.c, undo_io.c, and
test_io.c files so that there isn't a need to forward declare every
member of this structure.  That avoids a lot of redundant code
at the start of every one of these files.

Move the test_flush() function above test_abort() to avoid the need
for a forward declaration.

Fix a few instances of space before tab in these files.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/test_io.c
lib/ext2fs/undo_io.c
lib/ext2fs/unix_io.c

index cac6721..2f1c4f6 100644 (file)
@@ -63,45 +63,6 @@ struct test_private_data {
        void (*write_blk64)(unsigned long long block, int count, errcode_t err);
 };
 
-static errcode_t test_open(const char *name, int flags, io_channel *channel);
-static errcode_t test_close(io_channel channel);
-static errcode_t test_set_blksize(io_channel channel, int blksize);
-static errcode_t test_read_blk(io_channel channel, unsigned long block,
-                              int count, void *data);
-static errcode_t test_write_blk(io_channel channel, unsigned long block,
-                               int count, const void *data);
-static errcode_t test_read_blk64(io_channel channel, unsigned long long block,
-                              int count, void *data);
-static errcode_t test_write_blk64(io_channel channel, unsigned long long block,
-                               int count, const void *data);
-static errcode_t test_flush(io_channel channel);
-static errcode_t test_write_byte(io_channel channel, unsigned long offset,
-                                int count, const void *buf);
-static errcode_t test_set_option(io_channel channel, const char *option,
-                                const char *arg);
-static errcode_t test_get_stats(io_channel channel, io_stats *stats);
-static errcode_t test_discard(io_channel channel, unsigned long long block,
-                             unsigned long long count);
-
-static struct struct_io_manager struct_test_manager = {
-       EXT2_ET_MAGIC_IO_MANAGER,
-       "Test I/O Manager",
-       test_open,
-       test_close,
-       test_set_blksize,
-       test_read_blk,
-       test_write_blk,
-       test_flush,
-       test_write_byte,
-       test_set_option,
-       test_get_stats,
-       test_read_blk64,
-       test_write_blk64,
-       test_discard,
-};
-
-io_manager test_io_manager = &struct_test_manager;
-
 /*
  * These global variable can be set by the test program as
  * necessary *before* calling test_open
@@ -151,6 +112,28 @@ static void test_dump_block(io_channel channel,
        }
 }
 
+/*
+ * Flush data buffers to disk.
+ */
+static errcode_t test_flush(io_channel channel)
+{
+       struct test_private_data        *data;
+       errcode_t                       retval = 0;
+
+       EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
+       data = (struct test_private_data *)channel->private_data;
+       EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
+
+       if (data->real)
+               retval = io_channel_flush(data->real);
+
+       if (data->flags & TEST_FLAG_FLUSH)
+               fprintf(data->outfile, "Test_io: flush() returned %s\n",
+                       retval ? error_message(retval) : "OK");
+
+       return retval;
+}
+
 static void test_abort(io_channel channel, unsigned long block)
 {
        struct test_private_data *data;
@@ -224,14 +207,15 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
                                                       &data->real);
                if (retval)
                        goto cleanup;
-       } else
+       } else {
                data->real = 0;
-       data->read_blk =        test_io_cb_read_blk;
-       data->write_blk =       test_io_cb_write_blk;
-       data->set_blksize =     test_io_cb_set_blksize;
-       data->write_byte =      test_io_cb_write_byte;
-       data->read_blk64 =      test_io_cb_read_blk64;
-       data->write_blk64 =     test_io_cb_write_blk64;
+       }
+       data->read_blk =        test_io_cb_read_blk;
+       data->write_blk =       test_io_cb_write_blk;
+       data->set_blksize =     test_io_cb_set_blksize;
+       data->write_byte =      test_io_cb_write_byte;
+       data->read_blk64 =      test_io_cb_read_blk64;
+       data->write_blk64 =     test_io_cb_write_blk64;
 
        data->outfile = NULL;
        if ((value = safe_getenv("TEST_IO_LOGFILE")) != NULL)
@@ -447,28 +431,6 @@ static errcode_t test_write_byte(io_channel channel, unsigned long offset,
        return retval;
 }
 
-/*
- * Flush data buffers to disk.
- */
-static errcode_t test_flush(io_channel channel)
-{
-       struct test_private_data *data;
-       errcode_t       retval = 0;
-
-       EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
-       data = (struct test_private_data *) channel->private_data;
-       EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL);
-
-       if (data->real)
-               retval = io_channel_flush(data->real);
-
-       if (data->flags & TEST_FLAG_FLUSH)
-               fprintf(data->outfile, "Test_io: flush() returned %s\n",
-                       retval ? error_message(retval) : "OK");
-
-       return retval;
-}
-
 static errcode_t test_set_option(io_channel channel, const char *option,
                                 const char *arg)
 {
@@ -529,3 +491,22 @@ static errcode_t test_discard(io_channel channel, unsigned long long block,
                        block, count, retval ? error_message(retval) : "OK");
        return retval;
 }
+
+static struct struct_io_manager struct_test_manager = {
+       EXT2_ET_MAGIC_IO_MANAGER,
+       "Test I/O Manager",
+       test_open,
+       test_close,
+       test_set_blksize,
+       test_read_blk,
+       test_write_blk,
+       test_flush,
+       test_write_byte,
+       test_set_option,
+       test_get_stats,
+       test_read_blk64,
+       test_write_blk64,
+       test_discard,
+};
+
+io_manager test_io_manager = &struct_test_manager;
index 56b0eeb..0e05c93 100644 (file)
@@ -71,42 +71,7 @@ struct undo_private_data {
        ext2_loff_t offset;
 };
 
-static errcode_t undo_open(const char *name, int flags, io_channel *channel);
-static errcode_t undo_close(io_channel channel);
-static errcode_t undo_set_blksize(io_channel channel, int blksize);
-static errcode_t undo_read_blk64(io_channel channel, unsigned long long block,
-                                int count, void *data);
-static errcode_t undo_write_blk64(io_channel channel, unsigned long long block,
-                                 int count, const void *data);
-static errcode_t undo_read_blk(io_channel channel, unsigned long block,
-                              int count, void *data);
-static errcode_t undo_write_blk(io_channel channel, unsigned long block,
-                               int count, const void *data);
-static errcode_t undo_flush(io_channel channel);
-static errcode_t undo_write_byte(io_channel channel, unsigned long offset,
-                               int size, const void *data);
-static errcode_t undo_set_option(io_channel channel, const char *option,
-                                const char *arg);
-static errcode_t undo_get_stats(io_channel channel, io_stats *stats);
-
-static struct struct_io_manager struct_undo_manager = {
-       EXT2_ET_MAGIC_IO_MANAGER,
-       "Undo I/O Manager",
-       undo_open,
-       undo_close,
-       undo_set_blksize,
-       undo_read_blk,
-       undo_write_blk,
-       undo_flush,
-       undo_write_byte,
-       undo_set_option,
-       undo_get_stats,
-       undo_read_blk64,
-       undo_write_blk64,
-};
-
-io_manager undo_io_manager = &struct_undo_manager;
-static io_manager undo_io_backing_manager ;
+static io_manager undo_io_backing_manager;
 static char *tdb_file;
 static int actual_size;
 
@@ -621,3 +586,21 @@ static errcode_t undo_get_stats(io_channel channel, io_stats *stats)
 
        return retval;
 }
+
+static struct struct_io_manager struct_undo_manager = {
+       EXT2_ET_MAGIC_IO_MANAGER,
+       "Undo I/O Manager",
+       undo_open,
+       undo_close,
+       undo_set_blksize,
+       undo_read_blk,
+       undo_write_blk,
+       undo_flush,
+       undo_write_byte,
+       undo_set_option,
+       undo_get_stats,
+       undo_read_blk64,
+       undo_write_blk64,
+};
+
+io_manager undo_io_manager = &struct_undo_manager;
index 0cc0f52..c3185b6 100644 (file)
@@ -1,13 +1,13 @@
 /*
  * unix_io.c --- This is the Unix (well, really POSIX) implementation
- *     of the I/O manager.
+ *     of the I/O manager.
  *
  * Implements a one-block write-through cache.
  *
  * Includes support for Windows NT support under Cygwin.
  *
  * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002 by Theodore Ts'o.
+ *     2002 by Theodore Ts'o.
  *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Library
@@ -97,51 +97,9 @@ struct unix_private_data {
 #define IS_ALIGNED(n, align) ((((unsigned long) n) & \
                               ((unsigned long) ((align)-1))) == 0)
 
-static errcode_t unix_open(const char *name, int flags, io_channel *channel);
-static errcode_t unix_close(io_channel channel);
-static errcode_t unix_set_blksize(io_channel channel, int blksize);
-static errcode_t unix_read_blk(io_channel channel, unsigned long block,
-                              int count, void *data);
-static errcode_t unix_write_blk(io_channel channel, unsigned long block,
-                               int count, const void *data);
-static errcode_t unix_flush(io_channel channel);
-static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
-                               int size, const void *data);
-static errcode_t unix_set_option(io_channel channel, const char *option,
-                                const char *arg);
-static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
-;
-static void reuse_cache(io_channel channel, struct unix_private_data *data,
-                struct unix_cache *cache, unsigned long long block);
-static errcode_t unix_read_blk64(io_channel channel, unsigned long long block,
-                              int count, void *data);
-static errcode_t unix_write_blk64(io_channel channel, unsigned long long block,
-                               int count, const void *data);
-static errcode_t unix_discard(io_channel channel, unsigned long long block,
-                             unsigned long long count);
-
-static struct struct_io_manager struct_unix_manager = {
-       EXT2_ET_MAGIC_IO_MANAGER,
-       "Unix I/O Manager",
-       unix_open,
-       unix_close,
-       unix_set_blksize,
-       unix_read_blk,
-       unix_write_blk,
-       unix_flush,
-       unix_write_byte,
-       unix_set_option,
-       unix_get_stats,
-       unix_read_blk64,
-       unix_write_blk64,
-       unix_discard,
-};
-
-io_manager unix_io_manager = &struct_unix_manager;
-
 static errcode_t unix_get_stats(io_channel channel, io_stats *stats)
 {
-       errcode_t       retval = 0;
+       errcode_t       retval = 0;
 
        struct unix_private_data *data;
 
@@ -476,7 +434,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
        int             f_nocache = 0;
        ext2fs_struct_stat st;
 #ifdef __linux__
-       struct          utsname ut;
+       struct          utsname ut;
 #endif
 
        if (name == 0)
@@ -963,3 +921,22 @@ static errcode_t unix_discard(io_channel channel, unsigned long long block,
 unimplemented:
        return EXT2_ET_UNIMPLEMENTED;
 }
+
+static struct struct_io_manager struct_unix_manager = {
+       EXT2_ET_MAGIC_IO_MANAGER,
+       "Unix I/O Manager",
+       unix_open,
+       unix_close,
+       unix_set_blksize,
+       unix_read_blk,
+       unix_write_blk,
+       unix_flush,
+       unix_write_byte,
+       unix_set_option,
+       unix_get_stats,
+       unix_read_blk64,
+       unix_write_blk64,
+       unix_discard,
+};
+
+io_manager unix_io_manager = &struct_unix_manager;