Message ID | 20200206163746.431137-2-mc5686@mclink.it |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] Check config file defines a non-zero Sector size | expand |
Hi Mauro, On 06/02/20 17:37, Mauro Condarelli wrote: > Signed-off-by: Mauro Condarelli <mc5686@mclink.it> > --- > src/uboot_env.c | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/src/uboot_env.c b/src/uboot_env.c > index 4c241ab..475ce0c 100644 > --- a/src/uboot_env.c > +++ b/src/uboot_env.c > @@ -1086,6 +1086,7 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) > int ndev = 0; > struct uboot_flash_env *dev; > char *tmp; > + int retval = 0; > > if (!config) > return -EINVAL; > @@ -1118,8 +1119,10 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) > /* > * If size is set but zero, entry is wrong > */ > - if (!dev->envsize) > - return -EINVAL; > + if (!dev->envsize) { > + retval = -EINVAL; > + break; > + } > > if (!ctx->size) > ctx->size = dev->envsize; > @@ -1129,8 +1132,10 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) > free(tmp); > } > > - if (check_env_device(ctx, dev) < 0) > - return -EINVAL; > + if (check_env_device(ctx, dev) < 0) { > + retval = -EINVAL; > + break; > + } > > ndev++; > dev++; > @@ -1138,17 +1143,17 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) > if (ndev >= 2) { > ctx->redundant = true; > if (check_compatible_devices(ctx) < 0) > - return -EINVAL; > + retval = -EINVAL; > break; > } > } > if (ndev == 0) > - return -EINVAL; > + retval = -EINVAL; > > fclose(fp); > free(line); > > - return 0; > + return retval; > } > > static bool libuboot_validate_flags(struct var_entry *entry, const char *value) > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/src/uboot_env.c b/src/uboot_env.c index 4c241ab..475ce0c 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -1086,6 +1086,7 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) int ndev = 0; struct uboot_flash_env *dev; char *tmp; + int retval = 0; if (!config) return -EINVAL; @@ -1118,8 +1119,10 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) /* * If size is set but zero, entry is wrong */ - if (!dev->envsize) - return -EINVAL; + if (!dev->envsize) { + retval = -EINVAL; + break; + } if (!ctx->size) ctx->size = dev->envsize; @@ -1129,8 +1132,10 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) free(tmp); } - if (check_env_device(ctx, dev) < 0) - return -EINVAL; + if (check_env_device(ctx, dev) < 0) { + retval = -EINVAL; + break; + } ndev++; dev++; @@ -1138,17 +1143,17 @@ int libuboot_read_config(struct uboot_ctx *ctx, const char *config) if (ndev >= 2) { ctx->redundant = true; if (check_compatible_devices(ctx) < 0) - return -EINVAL; + retval = -EINVAL; break; } } if (ndev == 0) - return -EINVAL; + retval = -EINVAL; fclose(fp); free(line); - return 0; + return retval; } static bool libuboot_validate_flags(struct var_entry *entry, const char *value)
Signed-off-by: Mauro Condarelli <mc5686@mclink.it> --- src/uboot_env.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)