tdb2: clear bogus gcc uninitialized warnings with -O3
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:22 +0000 (22:12 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 17 Mar 2011 11:42:22 +0000 (22:12 +1030)
ccan/tdb2/test/run-11-simple-fetch.c
ccan/tdb2/test/run-12-store.c
ccan/tdb2/test/run-25-hashoverload.c
ccan/tdb2/transaction.c

index 447da9c2b5ee95d281d34f1f051806db1cf893f2..1a68b54e20f5fedb2ed21504d1984448608c8399 100644 (file)
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
                               O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
                ok1(tdb);
                if (tdb) {
-                       struct tdb_data d;
+                       struct tdb_data d = { NULL, 0 }; /* Bogus GCC warning */
 
                        /* fetch should fail. */
                        failtest_suppress = false;
index 2cc3e86b6a50bb2c650ffdf5aff453c6ca8f4c31..8ab9ddc1cc977c06d31cbe06ec0a841a9da11490 100644 (file)
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
                /* We seemed to lose some keys.
                 * Insert and check they're in there! */
                for (j = 0; j < 500; j++) {
-                       struct tdb_data d;
+                       struct tdb_data d = { NULL, 0 }; /* Bogus GCC warning */
                        ok1(tdb_store(tdb, key, data, TDB_REPLACE) == 0);
                        ok1(tdb_fetch(tdb, key, &d) == TDB_SUCCESS);
                        ok1(equal(d, data));
index fced3f3095f8ccd6410f9ded5887368b7af8d1bc..b96a4cc473689fadf1f9f045a8d772e750f38855 100644 (file)
@@ -38,7 +38,7 @@ int main(int argc, char *argv[])
 
        plan_tests(6883);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
-               struct tdb_data d;
+               struct tdb_data d = { NULL, 0 }; /* Bogus GCC warning */
 
                tdb = tdb_open("run-25-hashoverload.tdb", flags[i],
                               O_RDWR|O_CREAT|O_TRUNC, 0600, &hattr);
index a143ee853c67f102407fc461912c6373ec91f79b..2cab4655661768a80e44593211f152dd3c73175c 100644 (file)
@@ -745,11 +745,12 @@ static void set_recovery_header(struct tdb_recovery_record *rec,
 static enum TDB_ERROR transaction_setup_recovery(struct tdb_context *tdb,
                                                 tdb_off_t *magic_offset)
 {
-       tdb_len_t recovery_size;
+       /* Initialized for GCC's 4.4.5 overzealous uninitialized warnings. */
+       tdb_len_t recovery_size = 0;
+       tdb_off_t recovery_offset = 0, recovery_max_size = 0;
        unsigned char *data, *p;
        const struct tdb_methods *methods = tdb->transaction->io_methods;
        struct tdb_recovery_record *rec;
-       tdb_off_t recovery_offset, recovery_max_size;
        tdb_off_t old_map_size = tdb->transaction->old_map_size;
        uint64_t magic, tailer;
        int i;