* [PATCH v2] commands: saveenv: mention where environment is saved to
@ 2025-04-14 10:26 Ahmad Fatoum
2025-04-14 10:55 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-04-14 10:26 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] commands: saveenv: mention where environment is saved to
2025-04-14 10:26 [PATCH v2] commands: saveenv: mention where environment is saved to Ahmad Fatoum
@ 2025-04-14 10:55 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-04-14 10:55 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 14 Apr 2025 12:26:28 +0200, Ahmad Fatoum wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] commands: saveenv: mention where environment is saved to
https://git.pengutronix.de/cgit/barebox/commit/?id=62f60c776367 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-14 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-14 10:26 [PATCH v2] commands: saveenv: mention where environment is saved to Ahmad Fatoum
2025-04-14 10:55 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox