]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-tests: fix build and some warnings
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 16 Jan 2009 18:53:42 +0000 (20:53 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 16 Jan 2009 18:53:42 +0000 (20:53 +0200)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
tests/ubi-tests/Makefile
tests/ubi-tests/common.c
tests/ubi-tests/common.h
tests/ubi-tests/integ.c
tests/ubi-tests/io_basic.c
tests/ubi-tests/io_paral.c
tests/ubi-tests/io_update.c

index d122c8bf9126f35ccf3ce59ab1180de1e987ae80..0ce99d8ee77b98d568c3db721db959dcd77f8d8c 100644 (file)
@@ -1,45 +1,25 @@
 LIBUBI_PATH=../../ubi-utils/new-utils/
 LIBUBI_SRC_PATH=../../ubi-utils/new-utils/src/
 LIBUBI_HEADER_PATH=../../ubi-utils/new-utils/include
-UBI_HEADERS_PATH=../../include/
 UBIUTILS_PATH=../../ubi-utils/new-utils/
 
-CC := $(CROSS)gcc
+LIBUBI_PATH=../../ubi-utils/new-utils/
+KERNELHDR := ../../include
 
-TESTS=io_update volrefcnt integ io_paral io_read io_basic \
+LIBS = libubi
+TARGETS=io_update volrefcnt integ io_paral io_read io_basic \
           mkvol_basic mkvol_bad mkvol_paral rsvol
 
-# Because of implicite rules we use make treats .o files as intermediate, thus
-# it removes the. If you want to prevent the removal, uncomment the below
-#.SECONDARY: $(addsuffix .o, $(TESTS)) $(addsuffix .o, $(HELPERS))
-
-CFLAGS += -Wall -I$(LIBUBI_HEADER_PATH) -I $(UBI_HEADERS_PATH) -L. -O2
+CFLAGS += -I$(LIBUBI_HEADER_PATH) -I $(KERNELHDR) -lpthread
 
-all: ubi-utils libubi $(TESTS)
+include ../../common.mk
 
 # Compile ubilib with the udevsettle hack
-libubi: $(LIBUBI_SRC_PATH)/libubi.c  $(LIBUBI_HEADER_PATH)/libubi.h  $(LIBUBI_SRC_PATH)/libubi_int.h
+libubi.a: $(LIBUBI_SRC_PATH)/libubi.c  $(LIBUBI_HEADER_PATH)/libubi.h  $(LIBUBI_SRC_PATH)/libubi_int.h
        $(CC) $(CFLAGS) -I $(LIBUBI_SRC_PATH) -I../../include -DUDEV_SETTLE_HACK -c $(LIBUBI_SRC_PATH)/libubi.c -o libubi.o
        ar cr libubi.a libubi.o
 
-# The below cancels existing implicite rule to make programs from .c files,
-# in order to force make using our rule defined below
-%: %.c
-
-# The below is the rule to get an .o file from a .c file
-%.o: %.c
-       $(CC) $(CFLAGS) $< -c -o $@
-
-# And the below is the rule to get final test executable from its .o and common.o
-%: %.o common.o
-       $(CC) $(CFLAGS) $^ -lubi -o $@
-
-# *paral tests require libpthread, thus the below rule for them
-%paral: %paral.o common.o
-       $(CC) $(CFLAGS) $^ -lubi -lpthread -o $@
-
-ubi-utils:
-       make -C $(UBIUTILS_PATH)
+$(TARGETS): $(addprefix $(BUILDDIR)/, common.o) libubi.a
 
-clean:
-       rm -f $(TESTS) $(addsuffix .o, $(TESTS)) libubi.* $(HELPERS) $(addsuffix .o, $(HELPERS))
+clean::
+       rm -f $(TARGETS) $(addsuffix .o, $(TESTS)) libubi.*
index e785b91343bbefc61664ce0f6fb50e0e1b4f3e4d..59b30a76c878bad3b99a0130bf98e0cbb2cd8a50 100644 (file)
@@ -203,8 +203,7 @@ int __check_volume(libubi_t libubi, struct ubi_dev_info *dev_info,
 /**
  * __check_vol_patt - check that volume contains certain data
  *
- * @libubi    libubi descriptor
- * @dev_info  UBI device description
+ * @libubi  libubi descriptor
  * @test    test name
  * @func    function name
  * @line    line number
@@ -214,9 +213,8 @@ int __check_volume(libubi_t libubi, struct ubi_dev_info *dev_info,
  * This function returns %0 if the volume contains only @byte bytes, and %-1 if
  * not.
  */
-int __check_vol_patt(libubi_t libubi, struct ubi_dev_info *dev_info,
-                    const char *test, const char *func, int line,
-                    const char *node, uint8_t byte)
+int __check_vol_patt(libubi_t libubi, const char *test, const char *func,
+                    int line, const char *node, uint8_t byte)
 {
        int ret, fd;
        long long bytes = 0;
index 3e8ada80837d44648026d22a9b5a6820b8adf181..faa2865bf299bcea31e5366166b832acb75377f7 100644 (file)
@@ -49,8 +49,7 @@ extern "C" {
                       __LINE__, vol_id, req)
 
 #define check_vol_patt(node, byte)                                             \
-       __check_vol_patt(libubi, &dev_info, TESTNAME, __FUNCTION__, __LINE__,  \
-                        node, byte)
+       __check_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__, node, byte)
 
 #define update_vol_patt(node, bytes, byte)                                     \
        __update_vol_patt(libubi, TESTNAME, __FUNCTION__, __LINE__,            \
@@ -89,9 +88,8 @@ int __initial_check(const char *test, int argc, char * const argv[]);
 int __check_volume(libubi_t libubi, struct ubi_dev_info *dev_info,
                   const char *test, const char *func, int line, int vol_id,
                   const struct ubi_mkvol_request *req);
-int __check_vol_patt(libubi_t libubi, struct ubi_dev_info *dev_info,
-                    const char *test, const char *func, int line,
-                    const char *node, uint8_t byte);
+int __check_vol_patt(libubi_t libubi, const char *test, const char *func,
+                    int line, const char *node, uint8_t byte);
 int __update_vol_patt(libubi_t libubi, const char *test, const char *func,
                      int line, const char *node, long long bytes,
                      uint8_t byte);
index f78c280c740dcb6f5806566e25f8ab0ffdbc20b5..9958466e3d992f716bce62c2e8ae37ee8a9bd218 100644 (file)
@@ -81,7 +81,7 @@ static uint64_t total_written = 0;
 static uint64_t total_space = 0;
 
 static struct open_volume_fd *open_volumes;
-static size_t open_volume_count = 0;
+static int open_volume_count = 0;
 
 static const char *ubi_module_load_string;
 
@@ -237,7 +237,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
                if (w->offset + w->size < gap_end) {
                        /* There is a gap. Check all 0xff */
                        off64_t gap_start = w->offset + w->size;
-                       size_t size = gap_end - gap_start;
+                       ssize_t size = gap_end - gap_start;
                        if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
                                error_exit("lseek64 failed");
                        memset(read_buffer, 0 , size);
@@ -273,7 +273,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
        if (gap_end > erase_block->offset) {
                /* Check all 0xff */
                off64_t gap_start = erase_block->offset;
-               size_t size = gap_end - gap_start;
+               ssize_t size = gap_end - gap_start;
                if (lseek64(fd, gap_start, SEEK_SET) != gap_start)
                        error_exit("lseek64 failed");
                memset(read_buffer, 0 , size);
@@ -535,7 +535,7 @@ static void get_ubi_devices_info(void)
 {
        int i, ubi_pos = 0;
        char dev_name[1024];
-       size_t buf_size = 1024 * 128;
+       ssize_t buf_size = 1024 * 128;
 
        if (ubi_get_info(libubi, &info))
                error_exit("ubi_get_info failed");
index e10f8db95ffbab39346ebad35e38b1a2c2d920e4..819893c70f088bdce75083ccc8ca1d2bff5d79ce 100644 (file)
@@ -93,7 +93,7 @@ remove:
  */
 static int test_aligned(int type)
 {
-       int i, ebsz;
+       unsigned int i, ebsz;
        struct ubi_mkvol_request req;
        const char *name = TESTNAME ":test_aligned()";
        char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
index f98618c6133d3846c075e17eaf9d166745e10aba..ed0cbe061c44820b543de733fb2fd86133d5e8cf 100644 (file)
@@ -60,7 +60,7 @@ static long long memory_limit(void)
  *
  * @ptr  thread number
  */
-static void * the_thread(void *ptr)
+static void *the_thread(void *ptr)
 {
        int fd, iter = iterations, vol_id = (int)ptr;
        unsigned char *wbuf, *rbuf;
@@ -219,7 +219,7 @@ int main(int argc, char * const argv[])
        }
 
        for (i = 0; i < THREADS_NUM; i++) {
-               ret = pthread_create(&threads[i], NULL, &the_thread, (void*)i);
+               ret = pthread_create(&threads[i], NULL, &the_thread, (void *)i);
                if (ret) {
                        failed("pthread_create");
                        goto remove;
index a86b005b9f2c6fbc10e0925907f58763b3f6b788..24c056346e73ee583c9a6196d38a945dfc977267 100644 (file)
@@ -211,7 +211,7 @@ static int test_update(int type)
        int alignments[] = ALIGNMENTS(dev_info.leb_size);
        struct ubi_vol_info vol_info;
        char vol_node[strlen(UBI_VOLUME_PATTERN) + 100];
-       int i;
+       unsigned int i;
 
        for (i = 0; i < sizeof(alignments)/sizeof(int); i++) {
                int leb_size;