tdb2: fix gcc -O3 warnings on test/layout.c
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 3 Nov 2010 00:20:03 +0000 (10:50 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 3 Nov 2010 00:20:03 +0000 (10:50 +1030)
Warnings about ignored returns, and uninitialized len after case statement.

ccan/tdb2/test/layout.c

index 27c2d0459d1439fdbe9af7cd4e8bc1866023b70c..04111b4a697dd2d7bdbe43701e91cd21a6760caa 100644 (file)
@@ -237,6 +237,8 @@ struct tdb_context *tdb_layout_get(struct tdb_layout *layout)
                case HASHTABLE:
                        len = hashtable_len(&e->hashtable);
                        break;
+               default:
+                       abort();
                }
                off += len;
                assert(zone_left >= len);
@@ -311,7 +313,8 @@ struct tdb_context *tdb_layout_get(struct tdb_layout *layout)
                              0600);
                if (fd < 0)
                        err(1, "opening %s for writing", layout->filename);
-               write(fd, tdb->map_ptr, tdb->map_size);
+               if (write(fd, tdb->map_ptr, tdb->map_size) != tdb->map_size)
+                       err(1, "writing %s", layout->filename);
                close(fd);
                tdb_close(tdb);
                /* NOMMAP is for lockcheck. */