On Wed, Apr 12, 2023 at 1:22 PM Ashok Reddy Soma <ashok.reddy.s...@amd.com> wrote: > > For sf commands, when '0' length is passed for erase, update, write or > read, there might be undesired results. Ideally '0' length means nothing to > do. > > So print 'ERROR: Invalid size 0' and return cmd failure when length '0' is > passed to sf commands. Same thing applies for nand commands also. > > Example: > > ZynqMP> sf erase 0 0 > ERROR: Invalid size 0 > ZynqMP> sf write 10000 0 0 > ERROR: Invalid size 0 > ZynqMP> sf read 10000 0 0 > ERROR: Invalid size 0 > ZynqMP> sf update 1000 10000 0 > ERROR: Invalid size 0 > ZynqMP> > > Signed-off-by: Ashok Reddy Soma <ashok.reddy.s...@amd.com> > --- > > Changes in v2: > - Changed print from 'size is 0' to Invalid size 0 without quites. > - Modified description to be imperative > - Fixed typo in description from "samething" to "same thing" > > cmd/legacy-mtd-utils.c | 5 +++++ > cmd/sf.c | 5 +++++ > 2 files changed, 10 insertions(+) > > diff --git a/cmd/legacy-mtd-utils.c b/cmd/legacy-mtd-utils.c > index ac7139f84d..61987918a4 100644 > --- a/cmd/legacy-mtd-utils.c > +++ b/cmd/legacy-mtd-utils.c > @@ -88,6 +88,11 @@ int mtd_arg_off_size(int argc, char *const argv[], int > *idx, loff_t *off, > return -1; > } > > + if (*size == 0) { > + printf("ERROR: Invalid size 0\n"); > + return -1; > + } > + > print: > printf("device %d ", *idx); > if (*size == chipsize) > diff --git a/cmd/sf.c b/cmd/sf.c > index 11b9c25896..a6aadc2b00 100644 > --- a/cmd/sf.c > +++ b/cmd/sf.c > @@ -353,6 +353,11 @@ static int do_spi_flash_erase(int argc, char *const > argv[]) > if (ret != 1) > return CMD_RET_USAGE; > > + if (size == 0) { > + printf("ERROR: Invalid size 0\n"); > + return CMD_RET_FAILURE; > + }
I feel it is too verbose and if erase happened it shows the log otherwise it shows nothing, and that is enough. Jagan.