From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] cmd: mtd: Don't use with negative return codes for shell commands
Date: Mon, 6 Aug 2018 17:12:52 +0200 [thread overview]
Message-ID: <20180806151253.31205-3-sr@denx.de> (raw)
In-Reply-To: <20180806151253.31205-1-sr@denx.de>
When negative return codes are used in commands (do_foo()), the shell
prints these messages:
exit not allowed from main input shell.
Change the return codes in the new mtd commands to use only positive
values and these annoying warnings are gone.
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Jagan Teki <jagan@openedev.com>
---
cmd/mtd.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmd/mtd.c b/cmd/mtd.c
index 221b12500f..38a89736cf 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -188,7 +188,7 @@ static int do_mtd_list(void)
if (!dev_nb) {
printf("No MTD device found\n");
- return -EINVAL;
+ return EINVAL;
}
return 0;
@@ -269,13 +269,13 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (mtd_is_aligned_with_min_io_size(mtd, off)) {
printf("Offset not aligned with a page (0x%x)\n",
mtd->writesize);
- return -EINVAL;
+ return EINVAL;
}
if (mtd_is_aligned_with_min_io_size(mtd, len)) {
printf("Size not a multiple of a page (0x%x)\n",
mtd->writesize);
- return -EINVAL;
+ return EINVAL;
}
if (dump)
@@ -285,7 +285,7 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (!buf) {
printf("Could not map/allocate the user buffer\n");
- return -ENOMEM;
+ return ENOMEM;
}
printf("%s %lldB (%d page(s)) at offset 0x%08llx%s%s\n",
@@ -306,7 +306,7 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (ret) {
printf("%s on %s failed with error %d\n",
read ? "Read" : "Write", mtd->name, ret);
- return ret;
+ return -ret;
}
if (dump) {
@@ -346,13 +346,13 @@ static int do_mtd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (mtd_is_aligned_with_block_size(mtd, off)) {
printf("Offset not aligned with a block (0x%x)\n",
mtd->erasesize);
- return -EINVAL;
+ return EINVAL;
}
if (mtd_is_aligned_with_block_size(mtd, len)) {
printf("Size not a multiple of a block (0x%x)\n",
mtd->erasesize);
- return -EINVAL;
+ return EINVAL;
}
erase_op.mtd = mtd;
--
2.18.0
next prev parent reply other threads:[~2018-08-06 15:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 15:12 [U-Boot] [PATCH 1/4] spi: spi-mem: Add optional half-duplex SPI transfer mode Stefan Roese
2018-08-06 15:12 ` [U-Boot] [PATCH 2/4] mtd: nand: Don't abort erase operation when a bad block is detected Stefan Roese
2018-08-06 20:06 ` Boris Brezillon
2018-08-07 5:25 ` Stefan Roese
2018-08-06 15:12 ` Stefan Roese [this message]
2018-08-06 20:38 ` [U-Boot] [PATCH 3/4] cmd: mtd: Don't use with negative return codes for shell commands Boris Brezillon
2018-08-07 5:07 ` Stefan Roese
2018-08-06 15:12 ` [U-Boot] [PATCH 4/4] cmd: mtd: Add info text to mtd erase subcommand Stefan Roese
2018-08-06 20:41 ` Boris Brezillon
2018-08-07 5:08 ` Stefan Roese
2018-08-06 19:53 ` [U-Boot] [PATCH 1/4] spi: spi-mem: Add optional half-duplex SPI transfer mode Boris Brezillon
2018-08-07 5:06 ` Stefan Roese
2018-08-07 5:53 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180806151253.31205-3-sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox