summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-08-08 08:20:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-09 06:37:02 +0200
commitb5a386522d9cc72be551706b7ff9d84f87b15f7b (patch)
treedb818dff7d4cccc67f00bd62b2840b71d52d54b4
parent7b62fbc63218e1093594da7cd5ae577392bf088e (diff)
downloadbarebox-b5a386522d9cc72be551706b7ff9d84f87b15f7b.tar.gz
barebox-b5a386522d9cc72be551706b7ff9d84f87b15f7b.tar.xz
common: machine_id: simplify early exit
We don't need the goto if we haven't done anything to clean up anyway. also globalvar_add_simple("machine_id", NULL) is a no-op when we have just called globalvar_add_simple above with an actual argument. It doesn't clean the parameter, nor should it, because the code is executed for the successful code as well and there is nothing that can fail that late. This slightly alters behavior: Whereas before $global.machine_id was always defined when CONFIG_MACHINE_ID is enabled, it's now only defined when it's non-empty. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220808062010.390394-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/machine_id.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/common/machine_id.c b/common/machine_id.c
index 6480806cd2..a530fdeb1d 100644
--- a/common/machine_id.c
+++ b/common/machine_id.c
@@ -30,11 +30,11 @@ static int machine_id_set_globalvar(void)
unsigned char machine_id[SHA1_DIGEST_SIZE];
char hex_machine_id[MACHINE_ID_LENGTH];
char *env_machine_id;
- int ret = 0;
+ int ret;
/* nothing to do if no hashable information provided */
if (!__machine_id_hashable)
- goto out;
+ return 0;
digest = digest_alloc_by_algo(HASH_ALGO_SHA1);
ret = digest_init(digest);
@@ -58,8 +58,6 @@ static int machine_id_set_globalvar(void)
free(env_machine_id);
out:
- globalvar_add_simple("machine_id", NULL);
-
digest_free(digest);
return ret;