diff options
author | Simon Glass <sjg@chromium.org> | 2017-08-03 12:22:09 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-16 08:22:18 -0400 |
commit | 382bee57f19b4454e2015bc19a010bc2d0ab9337 (patch) | |
tree | 8c13efda2a6539cdbf1ac76fc458ffef1e9c966d /cmd | |
parent | 01510091de905c46620757b9027b2e55c4b3b313 (diff) | |
download | u-boot-382bee57f19b4454e2015bc19a010bc2d0ab9337.tar.gz |
env: Rename setenv() to env_set()
We are now using an env_ prefix for environment functions. Rename setenv()
for consistency. Also add function comments in common.h.
Suggested-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/fdt.c | 25 | ||||
-rw-r--r-- | cmd/gpt.c | 4 | ||||
-rw-r--r-- | cmd/ini.c | 2 | ||||
-rw-r--r-- | cmd/md5sum.c | 2 | ||||
-rw-r--r-- | cmd/mtdparts.c | 26 | ||||
-rw-r--r-- | cmd/net.c | 34 | ||||
-rw-r--r-- | cmd/nvedit.c | 8 | ||||
-rw-r--r-- | cmd/part.c | 8 | ||||
-rw-r--r-- | cmd/pxe.c | 6 | ||||
-rw-r--r-- | cmd/qfw.c | 2 | ||||
-rw-r--r-- | cmd/setexpr.c | 4 |
11 files changed, 62 insertions, 59 deletions
@@ -49,15 +49,15 @@ void set_working_fdt_addr(ulong addr) /* * Get a value from the fdt and format it to be set in the environment */ -static int fdt_value_setenv(const void *nodep, int len, const char *var) +static int fdt_value_env_set(const void *nodep, int len, const char *var) { if (is_printable_string(nodep, len)) - setenv(var, (void *)nodep); + env_set(var, (void *)nodep); else if (len == 4) { char buf[11]; sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep)); - setenv(var, buf); + env_set(var, buf); } else if (len%4 == 0 && len <= 20) { /* Needed to print things like sha1 hashes. */ char buf[41]; @@ -66,7 +66,7 @@ static int fdt_value_setenv(const void *nodep, int len, const char *var) for (i = 0; i < len; i += sizeof(unsigned int)) sprintf(buf + (i * 2), "%08x", *(unsigned int *)(nodep + i)); - setenv(var, buf); + env_set(var, buf); } else { printf("error: unprintable value\n"); return 1; @@ -358,10 +358,12 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (curDepth == startDepth + 1) curIndex++; if (subcmd[0] == 'n' && curIndex == reqIndex) { - const char *nodeName = fdt_get_name( - working_fdt, nextNodeOffset, NULL); + const char *node_name; - setenv(var, (char *)nodeName); + node_name = fdt_get_name(working_fdt, + nextNodeOffset, + NULL); + env_set(var, node_name); return 0; } nextNodeOffset = fdt_next_node( @@ -382,13 +384,14 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) working_fdt, nodeoffset, prop, &len); if (len == 0) { /* no property value */ - setenv(var, ""); + env_set(var, ""); return 0; } else if (nodep && len > 0) { if (subcmd[0] == 'v') { int ret; - ret = fdt_value_setenv(nodep, len, var); + ret = fdt_value_env_set(nodep, len, + var); if (ret != 0) return ret; } else if (subcmd[0] == 'a') { @@ -396,13 +399,13 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char buf[11]; sprintf(buf, "0x%p", nodep); - setenv(var, buf); + env_set(var, buf); } else if (subcmd[0] == 's') { /* Get size */ char buf[11]; sprintf(buf, "0x%08X", len); - setenv(var, buf); + env_set(var, buf); } else return CMD_RET_USAGE; return 0; @@ -60,7 +60,7 @@ static int extract_env(const char *str, char **env) #ifdef CONFIG_RANDOM_UUID debug("%s unset. ", str); gen_rand_uuid_str(uuid_str, UUID_STR_FORMAT_GUID); - setenv(s, uuid_str); + env_set(s, uuid_str); e = getenv(s); if (e) { @@ -626,7 +626,7 @@ static int do_disk_guid(struct blk_desc *dev_desc, char * const namestr) return CMD_RET_FAILURE; if (namestr) - setenv(namestr, disk_guid); + env_set(namestr, disk_guid); else printf("%s\n", disk_guid); @@ -219,7 +219,7 @@ static int ini_handler(void *user, char *section, char *name, char *value) for (i = 0; i < strlen(value); i++) value[i] = tolower(value[i]); #endif - setenv(name, value); + env_set(name, value); printf("ini: Imported %s as %s\n", name, value); } diff --git a/cmd/md5sum.c b/cmd/md5sum.c index 23bb81e88c..1b2352ea55 100644 --- a/cmd/md5sum.c +++ b/cmd/md5sum.c @@ -35,7 +35,7 @@ static void store_result(const u8 *sum, const char *dest) sprintf(str_ptr, "%02x", sum[i]); str_ptr += 2; } - setenv(dest, str_output); + env_set(dest, str_output); } } diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index 683c48bdad..a2433503c4 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -246,12 +246,12 @@ static void index_partitions(void) } part = mtd_part_info(current_mtd_dev, current_mtd_partnum); - setenv("mtddevname", part->name); + env_set("mtddevname", part->name); debug("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name); } else { - setenv("mtddevnum", NULL); - setenv("mtddevname", NULL); + env_set("mtddevnum", NULL); + env_set("mtddevname", NULL); debug("=> mtddevnum NULL\n=> mtddevname NULL\n"); } @@ -270,12 +270,12 @@ static void current_save(void) sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_mtd_dev->id->type), current_mtd_dev->id->num, current_mtd_partnum); - setenv("partition", buf); + env_set("partition", buf); strncpy(last_partition, buf, 16); debug("=> partition %s\n", buf); } else { - setenv("partition", NULL); + env_set("partition", NULL); last_partition[0] = '\0'; debug("=> partition NULL\n"); @@ -1213,9 +1213,9 @@ static int generate_mtdparts_save(char *buf, u32 buflen) ret = generate_mtdparts(buf, buflen); if ((buf[0] != '\0') && (ret == 0)) - setenv("mtdparts", buf); + env_set("mtdparts", buf); else - setenv("mtdparts", NULL); + env_set("mtdparts", NULL); return ret; } @@ -1764,7 +1764,7 @@ int mtdparts_init(void) if (mtdids_default) { debug("mtdids variable not defined, using default\n"); ids = mtdids_default; - setenv("mtdids", (char *)ids); + env_set("mtdids", (char *)ids); } else { printf("mtdids not defined, no default present\n"); return 1; @@ -1780,7 +1780,7 @@ int mtdparts_init(void) if (!parts) { if (mtdparts_default && use_defaults) { parts = mtdparts_default; - if (setenv("mtdparts", (char *)parts) == 0) + if (env_set("mtdparts", (char *)parts) == 0) use_defaults = 0; } else printf("mtdparts variable not set, see 'help mtdparts'\n"); @@ -1956,9 +1956,9 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, { if (argc == 2) { if (strcmp(argv[1], "default") == 0) { - setenv("mtdids", NULL); - setenv("mtdparts", NULL); - setenv("partition", NULL); + env_set("mtdids", NULL); + env_set("mtdparts", NULL); + env_set("partition", NULL); use_defaults = 1; mtdparts_init(); @@ -1967,7 +1967,7 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, /* this may be the first run, initialize lists if needed */ mtdparts_init(); - setenv("mtdparts", NULL); + env_set("mtdparts", NULL); /* mtd_devices_init() calls current_save() */ return mtd_devices_init(); @@ -116,23 +116,23 @@ static void netboot_update_env(void) if (net_gateway.s_addr) { ip_to_string(net_gateway, tmp); - setenv("gatewayip", tmp); + env_set("gatewayip", tmp); } if (net_netmask.s_addr) { ip_to_string(net_netmask, tmp); - setenv("netmask", tmp); + env_set("netmask", tmp); } if (net_hostname[0]) - setenv("hostname", net_hostname); + env_set("hostname", net_hostname); if (net_root_path[0]) - setenv("rootpath", net_root_path); + env_set("rootpath", net_root_path); if (net_ip.s_addr) { ip_to_string(net_ip, tmp); - setenv("ipaddr", tmp); + env_set("ipaddr", tmp); } #if !defined(CONFIG_BOOTP_SERVERIP) /* @@ -141,32 +141,32 @@ static void netboot_update_env(void) */ if (net_server_ip.s_addr) { ip_to_string(net_server_ip, tmp); - setenv("serverip", tmp); + env_set("serverip", tmp); } #endif if (net_dns_server.s_addr) { ip_to_string(net_dns_server, tmp); - setenv("dnsip", tmp); + env_set("dnsip", tmp); } #if defined(CONFIG_BOOTP_DNS2) if (net_dns_server2.s_addr) { ip_to_string(net_dns_server2, tmp); - setenv("dnsip2", tmp); + env_set("dnsip2", tmp); } #endif if (net_nis_domain[0]) - setenv("domain", net_nis_domain); + env_set("domain", net_nis_domain); #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) if (net_ntp_time_offset) { sprintf(tmp, "%d", net_ntp_time_offset); - setenv("timeoffset", tmp); + env_set("timeoffset", tmp); } #endif #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) if (net_ntp_server.s_addr) { ip_to_string(net_ntp_server, tmp); - setenv("ntpserverip", tmp); + env_set("ntpserverip", tmp); } #endif } @@ -291,14 +291,14 @@ static void cdp_update_env(void) printf("CDP offered appliance VLAN %d\n", ntohs(cdp_appliance_vlan)); vlan_to_string(cdp_appliance_vlan, tmp); - setenv("vlan", tmp); + env_set("vlan", tmp); net_our_vlan = cdp_appliance_vlan; } if (cdp_native_vlan != htons(-1)) { printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan)); vlan_to_string(cdp_native_vlan, tmp); - setenv("nvlan", tmp); + env_set("nvlan", tmp); net_native_vlan = cdp_native_vlan; } } @@ -423,14 +423,14 @@ static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc, net_gateway.s_addr = 0; ip_to_string(net_gateway, tmp); - setenv("gatewayip", tmp); + env_set("gatewayip", tmp); ip_to_string(net_netmask, tmp); - setenv("netmask", tmp); + env_set("netmask", tmp); ip_to_string(net_ip, tmp); - setenv("ipaddr", tmp); - setenv("llipaddr", tmp); /* store this for next time */ + env_set("ipaddr", tmp); + env_set("llipaddr", tmp); /* store this for next time */ return CMD_RET_SUCCESS; } diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 4431ef66d8..1b1e9667b5 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -283,7 +283,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag) return 0; } -int setenv(const char *varname, const char *varvalue) +int env_set(const char *varname, const char *varvalue) { const char * const argv[4] = { "setenv", varname, varvalue, NULL }; @@ -309,7 +309,7 @@ int setenv_ulong(const char *varname, ulong value) /* TODO: this should be unsigned */ char *str = simple_itoa(value); - return setenv(varname, str); + return env_set(varname, str); } /** @@ -324,7 +324,7 @@ int setenv_hex(const char *varname, ulong value) char str[17]; sprintf(str, "%lx", value); - return setenv(varname, str); + return env_set(varname, str); } ulong getenv_hex(const char *varname, ulong default_val) @@ -931,7 +931,7 @@ NXTARG: ; return 1; } sprintf(buf, "%zX", (size_t)len); - setenv("filesize", buf); + env_set("filesize", buf); return 0; } diff --git a/cmd/part.c b/cmd/part.c index 8ba05984e4..746bf40b2d 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -38,7 +38,7 @@ static int do_part_uuid(int argc, char * const argv[]) return 1; if (argc > 2) - setenv(argv[2], info.uuid); + env_set(argv[2], info.uuid); else printf("%s\n", info.uuid); @@ -99,7 +99,7 @@ static int do_part_list(int argc, char * const argv[]) sprintf(t, "%s%x", str[0] ? " " : "", p); strcat(str, t); } - setenv(var, str); + env_set(var, str); return 0; } @@ -135,7 +135,7 @@ static int do_part_start(int argc, char * const argv[]) snprintf(buf, sizeof(buf), LBAF, info.start); if (argc > 3) - setenv(argv[3], buf); + env_set(argv[3], buf); else printf("%s\n", buf); @@ -169,7 +169,7 @@ static int do_part_size(int argc, char * const argv[]) snprintf(buf, sizeof(buf), LBAF, info.size); if (argc > 3) - setenv(argv[3], buf); + env_set(argv[3], buf); else printf("%s\n", buf); @@ -591,7 +591,7 @@ static int label_localboot(struct pxe_label *label) char bootargs[CONFIG_SYS_CBSIZE]; cli_simple_process_macros(label->append, bootargs); - setenv("bootargs", bootargs); + env_set("bootargs", bootargs); } debug("running: %s\n", localcmd); @@ -695,7 +695,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label) strcat(bootargs, mac_str); cli_simple_process_macros(bootargs, finalbootargs); - setenv("bootargs", finalbootargs); + env_set("bootargs", finalbootargs); printf("append: %s\n", finalbootargs); } @@ -1674,7 +1674,7 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) filename = getenv("bootfile"); else { filename = argv[5]; - setenv("bootfile", filename); + env_set("bootfile", filename); } if (strstr(argv[3], "ext2")) @@ -55,7 +55,7 @@ static int qemu_fwcfg_setup_kernel(void *load_addr, void *initrd_addr) * when invoking qemu), do not update bootargs */ if (*data_addr != '\0') { - if (setenv("bootargs", data_addr) < 0) + if (env_set("bootargs", data_addr) < 0) printf("warning: unable to change bootargs\n"); } } diff --git a/cmd/setexpr.c b/cmd/setexpr.c index e7194fc4f4..e9058c4a0a 100644 --- a/cmd/setexpr.c +++ b/cmd/setexpr.c @@ -282,11 +282,11 @@ static int regex_sub(const char *name, if (!global) break; } - debug("## FINAL (now setenv()) : %s\n", data); + debug("## FINAL (now env_set()) : %s\n", data); printf("%s=%s\n", name, data); - return setenv(name, data); + return env_set(name, data); } #endif |