Browse Source

tdb2: fix gcc -O3 warnings on test/layout.c

Warnings about ignored returns, and uninitialized len after case statement.
Rusty Russell 15 years ago
parent
commit
54c087e9b1
1 changed files with 4 additions and 1 deletions
  1. 4 1
      ccan/tdb2/test/layout.c

+ 4 - 1
ccan/tdb2/test/layout.c

@@ -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. */