We already mention it on loadenv, but it makes sense to do it on saveenv too to assist with debugging.
As this removes the only user of envfs_save that passes a NULL as first argument, disallow that going forward by returning an error. Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- v1 -> v2: - remove NULL check for default_environment_path_get() (Sascha) - remove default_environment_path_get() fallback from envfs_save (Sascha) Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- commands/saveenv.c | 7 +++++-- common/environment.c | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/commands/saveenv.c b/commands/saveenv.c index 203729efbb1a..ae9e8da9ce2b 100644 --- a/commands/saveenv.c +++ b/commands/saveenv.c @@ -13,9 +13,8 @@ static int do_saveenv(int argc, char *argv[]) { int ret, opt; unsigned envfs_flags = 0; - char *filename = NULL, *dirname = NULL; + const char *filename = NULL, *dirname = NULL; - printf("saving environment\n"); while ((opt = getopt(argc, argv, "z")) > 0) { switch (opt) { case 'z': @@ -33,6 +32,10 @@ static int do_saveenv(int argc, char *argv[]) /* destination only given? */ if (argc - optind > 0) filename = argv[optind]; + if (!filename) + filename = default_environment_path_get(); + + printf("saving environment to %s\n", filename); ret = envfs_save(filename, dirname, envfs_flags); diff --git a/common/environment.c b/common/environment.c index 37adb5d67870..33ab4c43295d 100644 --- a/common/environment.c +++ b/common/environment.c @@ -307,10 +307,8 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) struct action_data data = {}; void *buf = NULL, *wbuf; struct envfs_entry *env; - const char *defenv_path = default_environment_path_get(); + __maybe_unused const char *defenv_path; - if (!filename) - filename = defenv_path; if (!filename) return -ENOENT; @@ -419,6 +417,7 @@ int envfs_save(const char *filename, const char *dirname, unsigned flags) ret = 0; #ifdef CONFIG_NVVAR + defenv_path = default_environment_path_get(); if (defenv_path && !strcmp(filename, defenv_path)) nv_var_set_clean(); #endif -- 2.39.5