]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tools/tdbtorture.c
tdb2: fix tools warnings with -Wshadow and -Wcast-qual.
[ccan] / ccan / tdb2 / tools / tdbtorture.c
index 89c2609967b425a4bdd8d71c8763fc4949576d2e..c6b71de51c407d6aaa8aa90da4a8bad60769479f 100644 (file)
@@ -60,14 +60,15 @@ static void tdb_log(struct tdb_context *tdb, enum tdb_log_level level,
 
 #include "../private.h"
 
-static void segv_handler(int signal, siginfo_t *info, void *p)
+static void segv_handler(int sig, siginfo_t *info, void *p)
 {
        char string[100];
 
-       sprintf(string, "%u: death at %p (map_ptr %p, map_size %llu)\n",
-               getpid(), info->si_addr, db->map_ptr, db->map_size);
-       write(2, string, strlen(string));
-       sleep(60);
+       sprintf(string, "%u: death at %p (map_ptr %p, map_size %zu)\n",
+               getpid(), info->si_addr, db->file->map_ptr,
+               (size_t)db->file->map_size);
+       if (write(2, string, strlen(string)) > 0)
+               sleep(60);
        _exit(11);
 }      
 
@@ -243,7 +244,8 @@ static void usage(void)
 static void send_count_and_suicide(int sig)
 {
        /* This ensures our successor can continue where we left off. */
-       write(count_pipe, &loopnum, sizeof(loopnum));
+       if (write(count_pipe, &loopnum, sizeof(loopnum)) != sizeof(loopnum))
+               exit(2);
        /* This gives a unique signature. */
        kill(getpid(), SIGUSR2);
 }
@@ -433,8 +435,11 @@ int main(int argc, char * const *argv)
                            || WTERMSIG(status) == SIGUSR1) {
                                /* SIGUSR2 means they wrote to pipe. */
                                if (WTERMSIG(status) == SIGUSR2) {
-                                       read(pfds[0], &done[j],
-                                            sizeof(done[j]));
+                                       if (read(pfds[0], &done[j],
+                                                sizeof(done[j]))
+                                           != sizeof(done[j]))
+                                               err(1,
+                                                   "Short read from child?");
                                }
                                pids[j] = fork();
                                if (pids[j] == 0)