discover/grub2: Use script_env_set when initialising the environment
authorJeremy Kerr <jk@ozlabs.org>
Tue, 28 Jan 2014 01:48:48 +0000 (09:48 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 03:54:01 +0000 (11:54 +0800)
No need to duplicate the environment-adding code in init_env, as we can
just use script_env_set.

Since script_env_set does its own talloc, we don't need to talloc our
strings here either.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/grub2/script.c

index aeb59783e1b48c38d8b7aa9ed5fdf0f90c9bd7c8..c4f58d92bacb27395647a23d9c4f9feb5d8d6016 100644 (file)
@@ -432,13 +432,9 @@ static void init_env(struct grub2_script *script)
                                        sep - script->filename);
        }
 
                                        sep - script->filename);
        }
 
-       env->name = talloc_strdup(env, "prefix");
+       script_env_set(script, "prefix", prefix ? : default_prefix);
        if (prefix)
        if (prefix)
-               env->value = prefix;
-       else
-               env->value = talloc_strdup(env, default_prefix);
-
-       list_add(&script->environment, &env->list);
+               talloc_free(prefix);
 }
 
 void script_register_function(struct grub2_script *script,
 }
 
 void script_register_function(struct grub2_script *script,