altos: Fix printf format mis-matches
[fw/altos] / src / kernel / ao_config.c
index e4fc73c99059aadac5c7e9360f702a43770fb7d6..217b0ab1a8cd5145dbc6470f2c95bede280144f1 100644 (file)
@@ -367,6 +367,8 @@ ao_config_send_frequency_set(void)
 
 #if HAS_FLIGHT
 
+#if HAS_BARO
+
 static void
 ao_config_main_deploy_show(void) 
 {
@@ -385,6 +387,8 @@ ao_config_main_deploy_set(void)
        _ao_config_edit_finish();
 }
 
+#endif
+
 #if HAS_ACCEL
 static void
 ao_config_accel_calibrate_show(void) 
@@ -502,6 +506,7 @@ ao_config_accel_calibrate_set(void)
 }
 #endif /* HAS_ACCEL */
 
+#if HAS_BARO
 static void
 ao_config_apogee_delay_show(void) 
 {
@@ -537,6 +542,7 @@ ao_config_apogee_lockout_set(void)
        ao_config.apogee_lockout = r;
        _ao_config_edit_finish();
 }
+#endif
 
 #endif /* HAS_FLIGHT */
 
@@ -623,26 +629,26 @@ static void
 ao_config_log_set(void) 
 {
 #if FLIGHT_LOG_APPEND
-       printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10);
+       printf("Flight log fixed size %u kB\n", (unsigned) (ao_storage_log_max >> 10));
 #else
-       uint16_t        block = (uint16_t) (ao_storage_block >> 10);
-       uint16_t        log_max = (uint16_t) (ao_storage_log_max >> 10);
        uint32_t        r;
 
        r = ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
-       if (ao_log_present())
-               printf("Storage must be empty before changing log size\n");
-       else if (block > 1024 && (r & (block - 1)))
-               printf("Flight log size must be multiple of %d kB\n", block);
-       else if (r > log_max)
-               printf("Flight log max %d kB\n", log_max);
-       else {
-               _ao_config_edit_start();
-               ao_config.flight_log_max = r << 10;
-               _ao_config_edit_finish();
+       r = r << 10;
+       if (ao_log_present()) {
+               if (r != ao_config.flight_log_max)
+                       printf("Storage must be empty before changing log size\n");
+               return;
        }
+       if (r > ao_storage_log_max) {
+               printf("Flight log max %u kB\n", (unsigned) (ao_storage_log_max >> 10));
+               return;
+       }
+       _ao_config_edit_start();
+       ao_config.flight_log_max = r & ~(ao_storage_block - 1);
+       _ao_config_edit_finish();
 #endif
 }
 #endif /* HAS_LOG */
@@ -988,7 +994,7 @@ ao_config_save(void);
 #endif
 
 const struct ao_config_var ao_config_vars[] = {
-#if HAS_FLIGHT
+#if HAS_FLIGHT && HAS_BARO
        { "m <meters>\0Main deploy (m)",
          ao_config_main_deploy_set,    ao_config_main_deploy_show, },
        { "d <delay>\0Apogee delay (s)",