altos: Make sure ao_storage_config is set before reading config block
authorKeith Packard <keithp@keithp.com>
Mon, 18 Jun 2012 02:11:35 +0000 (19:11 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 18 Jun 2012 02:11:35 +0000 (19:11 -0700)
ao_storage_read does in fact call ao_storage_setup, but we need the
value of ao_storage_config *before* calling ao_storage_read, so call
ao_storage_setup first.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_config.c

index a4877b069387eb54359c737bc8601be88a374e62..cc580d666ede29b97dce87cccbec54b205719485 100644 (file)
@@ -81,6 +81,11 @@ _ao_config_get(void)
        if (ao_config_loaded)
                return;
 #if HAS_EEPROM
+       /* Yes, I know ao_storage_read calls ao_storage_setup,
+        * but ao_storage_setup *also* sets ao_storage_config, which we
+        * need before calling ao_storage_read here
+        */
+       ao_storage_setup();
        ao_storage_read(ao_storage_config, &ao_config, sizeof (ao_config));
 #endif
        if (ao_config.major != AO_CONFIG_MAJOR) {