summaryrefslogtreecommitdiff
path: root/avr/cmd_attach.c
diff options
context:
space:
mode:
Diffstat (limited to 'avr/cmd_attach.c')
-rw-r--r--avr/cmd_attach.c37
1 files changed, 4 insertions, 33 deletions
diff --git a/avr/cmd_attach.c b/avr/cmd_attach.c
index fcc4f49..0949687 100644
--- a/avr/cmd_attach.c
+++ b/avr/cmd_attach.c
@@ -15,34 +15,6 @@
#include "getopt-min.h"
-static const FLASH char * const FLASH rc_messages[] = {
- FSTR("OK"),
- FSTR("Unknown error"),
- FSTR("Disk number out of range 0..7"),
- FSTR("Disk allready attached"),
- FSTR("Disk not attached"),
- FSTR("File not found"),
- FSTR("Not enough memory"),
- FSTR("Error opening file"),
- FSTR("File allready attached to other drive"),
- };
-
-static
-void printerror(int rc, uint8_t unit, char *fn)
-{
- if (rc < 0 || (unsigned) rc >= ARRAY_SIZE(rc_messages))
- rc = 1;
-
-#if GCC_BUG_61443
- printf_P(PSTR("Attachment of '%s' to dsk%d failed: "), fn, unit);
- my_puts_P(rc_messages[rc]);
- my_puts_P(PSTR("!\n"));
-#else
- printf_P(PSTR("Attachment of '%s' to dsk%d failed: %S!\n"),
- fn, unit, rc_messages[rc]);
-#endif
-}
-
/*
* attach [[options] [unit [diskfile]]]
*
@@ -58,7 +30,7 @@ void printerror(int rc, uint8_t unit, char *fn)
command_ret_t do_attach(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
{
- uint8_t unit;
+ uint8_t unit = 0;
char *filename = NULL;
bool detach = false;
bool detach_all = false;
@@ -134,8 +106,7 @@ command_ret_t do_attach(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
strncmp_P(argv[optind], PSTR("dsk"), 3) ||
(unit = argv[optind][3] - '0') >= CONFIG_CPM_MAX_DRIVE)) {
- printf_P(PSTR("Unknown device: '%s'\n"), argv[optind]);
- return CMD_RET_FAILURE;
+ cmd_error(CMD_RET_FAILURE, 0, PSTR("Invalid device: '%s'"), argv[optind]);
}
if (detach) {
@@ -152,7 +123,7 @@ command_ret_t do_attach(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
res = drv_attach(unit, filename, options);
if (res)
- printerror(res, unit, filename);
+ cmd_error(CMD_RET_FAILURE, res, PSTR("Attachment of '%s' to dsk%d failed"), filename, unit);
- return res ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
+ return CMD_RET_SUCCESS;
}