]> git.ozlabs.org Git - ccan/commitdiff
Remove compile warnings of tests under Ubuntu (return value ignored)
authorRusty Russell <rusty@rustcorp.com.au>
Sat, 15 Nov 2008 10:39:38 +0000 (21:09 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Sat, 15 Nov 2008 10:39:38 +0000 (21:09 +1030)
ccan/alloc/test/run-testsize.c
ccan/alloc/test/run.c
ccan/tap/test/run.c

index bb063c24cfa4ea228dec8ff1531b01642316982f..9071cb6d348951c44b5656d442751a32aa7aa839 100644 (file)
@@ -3,6 +3,7 @@
 #include "alloc/alloc.c"
 #include <stdlib.h>
 #include <stdbool.h>
 #include "alloc/alloc.c"
 #include <stdlib.h>
 #include <stdbool.h>
+#include <err.h>
 
 #define POOL_ORD 16
 #define POOL_SIZE (1 << POOL_ORD)
 
 #define POOL_ORD 16
 #define POOL_SIZE (1 << POOL_ORD)
@@ -34,7 +35,8 @@ int main(int argc, char *argv[])
        plan_tests(5);
 
        /* FIXME: Needs to be page aligned for now. */
        plan_tests(5);
 
        /* FIXME: Needs to be page aligned for now. */
-       posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE);
+       if (posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE) != 0)
+               errx(1, "Failed allocating aligned memory"); 
 
        alloc_init(mem, POOL_SIZE);
 
 
        alloc_init(mem, POOL_SIZE);
 
index bf8ab479e6b74cb90286fc0a7f4ec5fc3a8907df..8247122eaa4041b8ebf643d2e5077605019f64ce 100644 (file)
@@ -2,6 +2,7 @@
 #include "tap/tap.h"
 #include "alloc/alloc.c"
 #include <stdlib.h>
 #include "tap/tap.h"
 #include "alloc/alloc.c"
 #include <stdlib.h>
+#include <err.h>
 
 #define POOL_ORD 16
 #define POOL_SIZE (1 << POOL_ORD)
 
 #define POOL_ORD 16
 #define POOL_SIZE (1 << POOL_ORD)
@@ -52,7 +53,8 @@ int main(int argc, char *argv[])
        plan_tests(178);
 
        /* FIXME: Needs to be page aligned for now. */
        plan_tests(178);
 
        /* FIXME: Needs to be page aligned for now. */
-       posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE);
+       if (posix_memalign(&mem, 1 << POOL_ORD, POOL_SIZE) != 0)
+               errx(1, "Failed allocating aligned memory"); 
 
        /* Small pool, all allocs fail, even 0-length. */
        alloc_init(mem, 0);
 
        /* Small pool, all allocs fail, even 0-length. */
        alloc_init(mem, 0);
index 2f718cc27fbbf0e6c8e7fb61de6d114bf42141b7..26957fb5c04b601bca73f7a19b26b90949f1d080 100644 (file)
 /* We dup stderr to here. */
 static int stderrfd;
 
 /* We dup stderr to here. */
 static int stderrfd;
 
+/* write_all inlined here to avoid circular dependency. */
+static void write_all(int fd, const void *data, size_t size)
+{
+       while (size) {
+               ssize_t done;
+
+               done = write(fd, data, size);
+               if (done <= 0)
+                       _exit(1);
+               data += done;
+               size -= done;
+       }
+}
+
 /* Simple replacement for err() */
 static void failmsg(const char *fmt, ...)
 {
 /* Simple replacement for err() */
 static void failmsg(const char *fmt, ...)
 {
@@ -27,9 +41,9 @@ static void failmsg(const char *fmt, ...)
        vsprintf(buf, fmt, ap);
        va_end(ap);
 
        vsprintf(buf, fmt, ap);
        va_end(ap);
 
-       write(stderrfd, "# ", 2);
-       write(stderrfd, buf, strlen(buf));
-       write(stderrfd, "\n", 1);
+       write_all(stderrfd, "# ", 2);
+       write_all(stderrfd, buf, strlen(buf));
+       write_all(stderrfd, "\n", 1);
        _exit(1);
 }
 
        _exit(1);
 }
 
@@ -113,6 +127,7 @@ int main(int argc, char *argv[])
        expect(p[0], "# Looks like you failed 2 tests of 9.\n");
 #endif
 
        expect(p[0], "# Looks like you failed 2 tests of 9.\n");
 #endif
 
-       write(stdoutfd, "ok 1 - All passed\n", strlen("ok 1 - All passed\n"));
+       write_all(stdoutfd, "ok 1 - All passed\n",
+                 strlen("ok 1 - All passed\n"));
        _exit(0);
 }
        _exit(0);
 }