diff options
author | Michal Simek <michal.simek@xilinx.com> | 2018-04-25 11:10:34 +0200 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2018-05-11 09:23:43 +0200 |
commit | 0478b0b9b674da35948d7500b595ae14387068ac (patch) | |
tree | a483ba9eacf7297ab562ae47eeab0d860ed06e87 /board/xilinx | |
parent | 0678941ae54b3f1bbd8024c8d74fb282f0c1b590 (diff) | |
download | u-boot-0478b0b9b674da35948d7500b595ae14387068ac.tar.gz |
arm64: zynqmp: Simplify boot_target variable composition
Call calloc for space allocation only at one location and include if/else
to sprintf. This will simplify run time device adding based on id aliases.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'board/xilinx')
-rw-r--r-- | board/xilinx/zynqmp/zynqmp.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 911cd52e0c..57c0d93aa1 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -453,6 +453,7 @@ int board_late_init(void) { u32 reg = 0; u8 bootmode; + int env_targets_len = 0; const char *mode; char *new_targets; char *env_targets; @@ -529,14 +530,13 @@ int board_late_init(void) * and default boot_targets */ env_targets = env_get("boot_targets"); - if (env_targets) { - new_targets = calloc(1, strlen(mode) + - strlen(env_targets) + 2); - sprintf(new_targets, "%s %s", mode, env_targets); - } else { - new_targets = calloc(1, strlen(mode) + 2); - sprintf(new_targets, "%s", mode); - } + if (env_targets) + env_targets_len = strlen(env_targets); + + new_targets = calloc(1, strlen(mode) + env_targets_len + 2); + + sprintf(new_targets, "%s %s", mode, + env_targets ? env_targets : ""); env_set("boot_targets", new_targets); |