Message ID | 1555495279-7617-1-git-send-email-mark.jonas@de.bosch.com |
---|---|
State | Accepted |
Headers | show |
Series | [libubootenv,1/2] Fix missing return zero in libuboot_load_file | expand |
On 17/04/19 12:01, Mark Jonas wrote: > From: Leo Ruan <tingquan.ruan@cn.bosch.com> > > The fw_utils load environment variables from a persistent storage > (e.g. SPI flash) at first. If there is no valid environment in the > persistent storage, fw_utils accept a file which contains an initial > environment of U-Boot. > If no valid environment can be found from the persistent storage and > given file, fw_utils continue to work on an empty environment. > Specially, fw_setenv stores the environment to persistent storage. > This leads problem on booting. > > This commit fixes the problem by making fw_utils return error in > case of no valid environment in persistent storage and given file. > Agree - this is a more correct behavior as to try to work in any case. > Signed-off-by: Leo Ruan <tingquan.ruan@cn.bosch.com> > Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com> > --- > src/fw_printenv.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/fw_printenv.c b/src/fw_printenv.c > index a561db4..8dbaf01 100644 > --- a/src/fw_printenv.c > +++ b/src/fw_printenv.c > @@ -123,7 +123,10 @@ int main (int argc, char **argv) { > > if ((ret = libuboot_open(ctx)) < 0) { > fprintf(stderr, "Cannot read environment, using default\n"); > - libuboot_load_file(ctx, defenvfile); > + if ((ret = libuboot_load_file(ctx, defenvfile)) < 0) { > + fprintf(stderr, "Cannot read default environment from file\n"); > + exit (ret); > + } > } > > if (!is_setenv) { > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/src/fw_printenv.c b/src/fw_printenv.c index a561db4..8dbaf01 100644 --- a/src/fw_printenv.c +++ b/src/fw_printenv.c @@ -123,7 +123,10 @@ int main (int argc, char **argv) { if ((ret = libuboot_open(ctx)) < 0) { fprintf(stderr, "Cannot read environment, using default\n"); - libuboot_load_file(ctx, defenvfile); + if ((ret = libuboot_load_file(ctx, defenvfile)) < 0) { + fprintf(stderr, "Cannot read default environment from file\n"); + exit (ret); + } } if (!is_setenv) {