From: Oleksij Rempel Date: Tue, 23 Apr 2013 17:13:31 +0000 (+0200) Subject: dbg: add db_incorect_format X-Git-Tag: 1.3.2~3^2~3 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=0daf1f48384f37635730f1e5410028e11a1be8db;p=open-ath9k-htc-firmware.git dbg: add db_incorect_format Replace duplicated code with db_incorect_format function. ram usage before patch: >info ram ALLOCRAM Current Addr 0x5352bc ALLOCRAM Remaining Bytes 42308 after patch: >info ram ALLOCRAM Current Addr 0x535234 ALLOCRAM Remaining Bytes 42444 Signed-off-by: Oleksij Rempel --- diff --git a/target_firmware/magpie_fw_dev/target/cmnos/dbg_api.c b/target_firmware/magpie_fw_dev/target/cmnos/dbg_api.c index 7ba3c9b..42215df 100755 --- a/target_firmware/magpie_fw_dev/target/cmnos/dbg_api.c +++ b/target_firmware/magpie_fw_dev/target/cmnos/dbg_api.c @@ -118,6 +118,11 @@ int cmd_not_found; uint16_t gvLen; int pressed_time; +static void db_incorect_format(void) +{ + A_PRINTF("Error! Incorrect format.\n\r"); +} + static void zf_debug_init(void) { uint8_t ch; @@ -431,12 +436,9 @@ static int db_ldr_cmd(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("%s : %s\n\r", addr_str, val_str); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + db_incorect_format(); + return -1; } static int db_str_cmd(char *cmd, char *param1, char *param2, char *param3) @@ -479,12 +481,9 @@ static int db_str_cmd(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("%s : %s\n\r", addr_str, val_str); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + db_incorect_format(); + return -1; } LOCAL void dbg_timer_func(A_HANDLE alarm, void *data) @@ -797,11 +796,9 @@ static int db_cmd_sferase(char *cmd, char *param1, char *param2, char *param3) return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } else if (strcmp(param2, "b") == 0) { @@ -813,11 +810,10 @@ static int db_cmd_sferase(char *cmd, char *param1, char *param2, char *param3) return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; + } else if (strcmp(param1, "c") == 0) { @@ -850,11 +846,9 @@ static int db_cmd_sfpg(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("\n\r"); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } /* Serial Flash -> Read, Fast Read to UART */ @@ -894,11 +888,9 @@ static int db_cmd_sfru(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("\n\r"); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } /* Serial Flash -> Read, Fast Read to Memory */ @@ -932,11 +924,9 @@ static int db_cmd_sfrm(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("\n\r"); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } /* Serial Flash -> Read Status Register */ @@ -965,11 +955,9 @@ static int db_cmd_memcmp(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("memcmp(buf1, buf2, len) = %d\n\r", A_MEMCMP(buf1, buf2, len)); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } /* Memory Dump */ @@ -996,11 +984,9 @@ static int db_cmd_memdump(char *cmd, char *param1, char *param2, char *param3) A_PRINTF("\n\r"); return 0; } - else - { - A_PRINTF("Error! Incorrect format.\n\r"); - return -1; - } + + db_incorect_format(); + return -1; } void cmnos_dbg_module_install(struct dbg_api *apis) {