altos: Clear callsign on initial config load
authorKeith Packard <keithp@keithp.com>
Fri, 26 Aug 2011 01:02:45 +0000 (18:02 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 26 Aug 2011 01:08:00 +0000 (18:08 -0700)
Before being written the first time, ao_config will get set to 0xff
when the config storage is read. This leaves the tail of the callsign
filled with invalid bytes. Zero the whole thing before loading the
default callsign to make sure any extra bytes are set correctly.

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

index eb1eea3fa843bcbd68833b2035ff068260a73bbd..0c10e60894e57569d18a07d870610717da95c1cb 100644 (file)
@@ -74,6 +74,7 @@ _ao_config_get(void)
                ao_config.minor = 0;
                ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY;
                ao_config.radio_channel = AO_CONFIG_DEFAULT_RADIO_CHANNEL;
                ao_config.minor = 0;
                ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY;
                ao_config.radio_channel = AO_CONFIG_DEFAULT_RADIO_CHANNEL;
+               memset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
                memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
                       sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
        }
                memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
                       sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
        }