From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2] commands: saveenv: mention where environment is saved to
Date: Mon, 14 Apr 2025 12:26:28 +0200 [thread overview]
Message-ID: <20250414102628.3156629-1-a.fatoum@pengutronix.de> (raw)
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.fatoum@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.fatoum@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
next reply other threads:[~2025-04-14 10:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 10:26 Ahmad Fatoum [this message]
2025-04-14 10:55 ` Sascha Hauer
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=20250414102628.3156629-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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