last_slash = strrchr(bootfile, '/');
- if (last_slash == NULL )
+ if (!last_slash)
goto ret;
path_len = (last_slash - bootfile) + 1;
if (bootfile_path_size < path_len) {
printf("bootfile_path too small. (%zd < %zd)\n",
- bootfile_path_size, path_len);
+ bootfile_path_size, path_len);
return -1;
}
* Returns 1 for success, or < 0 on error.
*/
static int get_relfile(cmd_tbl_t *cmdtp, const char *file_path,
- unsigned long file_addr)
+ unsigned long file_addr)
{
size_t path_len;
- char relfile[MAX_TFTP_PATH_LEN+1];
+ char relfile[MAX_TFTP_PATH_LEN + 1];
char addr_buf[18];
int err;
path_len += strlen(relfile);
if (path_len > MAX_TFTP_PATH_LEN) {
- printf("Base path too long (%s%s)\n",
- relfile,
- file_path);
+ printf("Base path too long (%s%s)\n", relfile, file_path);
return -ENAMETOOLONG;
}
* Returns 1 on success, or < 0 for error.
*/
int get_pxe_file(cmd_tbl_t *cmdtp, const char *file_path,
- unsigned long file_addr)
+ unsigned long file_addr)
{
unsigned long config_file_size;
char *tftp_filesize;
#define PXELINUX_DIR "pxelinux.cfg/"
-
/*
* Retrieves a file in the 'pxelinux.cfg' folder. Since this uses get_pxe_file
* to do the hard work, the location of the 'pxelinux.cfg' folder is generated
* Returns 1 on success or < 0 on error.
*/
int get_pxelinux_path(cmd_tbl_t *cmdtp, const char *file,
- unsigned long pxefile_addr_r)
+ unsigned long pxefile_addr_r)
{
size_t base_len = strlen(PXELINUX_DIR);
- char path[MAX_TFTP_PATH_LEN+1];
+ char path[MAX_TFTP_PATH_LEN + 1];
if (base_len + strlen(file) > MAX_TFTP_PATH_LEN) {
printf("path (%s%s) too long, skipping\n",
- PXELINUX_DIR, file);
+ PXELINUX_DIR, file);
return -ENAMETOOLONG;
}
*
* Returns 1 on success or < 0 on error.
*/
-static int get_relfile_envaddr(cmd_tbl_t *cmdtp, const char *file_path, const char *envaddr_name)
+static int get_relfile_envaddr(cmd_tbl_t *cmdtp, const char *file_path,
+ const char *envaddr_name)
{
unsigned long file_addr;
char *envaddr;
return 0;
}
- if (label->kernel == NULL) {
+ if (!label->kernel) {
printf("No kernel given, skipping %s\n",
- label->name);
+ label->name);
return 1;
}
if (label->initrd) {
if (get_relfile_envaddr(cmdtp, label->initrd, "ramdisk_addr_r") < 0) {
printf("Skipping %s for failure retrieving initrd\n",
- label->name);
+ label->name);
return 1;
}
if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
printf("Skipping %s for failure retrieving kernel\n",
- label->name);
+ label->name);
return 1;
}
#ifdef CONFIG_CMD_NET
if (label->ipappend & 0x2) {
int err;
+
strcpy(mac_str, " BOOTIF=");
err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8);
if (err < 0)
strlen(ip_str), strlen(mac_str),
sizeof(bootargs));
return 1;
- } else {
- if (label->append)
- strncpy(bootargs, label->append,
- sizeof(bootargs));
- strcat(bootargs, ip_str);
- strcat(bootargs, mac_str);
-
- cli_simple_process_macros(bootargs, finalbootargs);
- env_set("bootargs", finalbootargs);
- printf("append: %s\n", finalbootargs);
}
+
+ if (label->append)
+ strncpy(bootargs, label->append, sizeof(bootargs));
+
+ strcat(bootargs, ip_str);
+ strcat(bootargs, mac_str);
+
+ cli_simple_process_macros(bootargs, finalbootargs);
+ env_set("bootargs", finalbootargs);
+ printf("append: %s\n", finalbootargs);
}
bootm_argv[1] = env_get("kernel_addr_r");
}
if (fdtfile) {
- int err = get_relfile_envaddr(cmdtp, fdtfile, "fdt_addr_r");
+ int err = get_relfile_envaddr(cmdtp, fdtfile,
+ "fdt_addr_r");
+
free(fdtfilefree);
if (err < 0) {
printf("Skipping %s for failure retrieving fdt\n",
- label->name);
+ label->name);
goto cleanup;
}
} else {
* e is incremented until we find the ending delimiter, or a NUL byte
* is reached. Then, we take e - b to find the length of the token.
*/
- b = e = *p;
+ b = *p;
+ e = *p;
while (*e) {
if ((delim == ' ' && isspace(*e)) || delim == *e)
}
static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, unsigned long base,
- struct pxe_menu *cfg, int nest_level);
+ struct pxe_menu *cfg, int nest_level);
/*
* Parse an include statement, and retrieve and parse the file it mentions.
* incremented here.
*/
static int handle_include(cmd_tbl_t *cmdtp, char **c, unsigned long base,
- struct pxe_menu *cfg, int nest_level)
+ struct pxe_menu *cfg, int nest_level)
{
char *include_path;
char *s = *c;
err = parse_sliteral(c, &include_path);
if (err < 0) {
- printf("Expected include path: %.*s\n",
- (int)(*c - s), s);
+ printf("Expected include path: %.*s\n", (int)(*c - s), s);
return err;
}
* a file it includes, 3 when parsing a file included by that file, and so on.
*/
static int parse_menu(cmd_tbl_t *cmdtp, char **c, struct pxe_menu *cfg,
- unsigned long base, int nest_level)
+ unsigned long base, int nest_level)
{
struct token t;
char *s = *c;
break;
case T_INCLUDE:
- err = handle_include(cmdtp, c, base, cfg,
- nest_level + 1);
+ err = handle_include(cmdtp, c, base, cfg, nest_level + 1);
break;
case T_BACKGROUND:
default:
printf("Ignoring malformed menu command: %.*s\n",
- (int)(*c - s), s);
+ (int)(*c - s), s);
}
if (err < 0)
* Handles parsing a 'menu line' when we're parsing a label.
*/
static int parse_label_menu(char **c, struct pxe_menu *cfg,
- struct pxe_label *label)
+ struct pxe_label *label)
{
struct token t;
char *s;
break;
default:
printf("Ignoring malformed menu command: %.*s\n",
- (int)(*c - s), s);
+ (int)(*c - s), s);
}
eol_or_eof(c);
* Returns 1 on success, < 0 on error.
*/
static int parse_pxefile_top(cmd_tbl_t *cmdtp, char *p, unsigned long base,
- struct pxe_menu *cfg, int nest_level)
+ struct pxe_menu *cfg, int nest_level)
{
struct token t;
char *s, *b, *label_name;
case T_MENU:
cfg->prompt = 1;
err = parse_menu(cmdtp, &p, cfg,
- base + ALIGN(strlen(b) + 1, 4),
- nest_level);
+ base + ALIGN(strlen(b) + 1, 4),
+ nest_level);
break;
case T_TIMEOUT:
case T_INCLUDE:
err = handle_include(cmdtp, &p,
- base + ALIGN(strlen(b), 4), cfg,
- nest_level + 1);
+ base + ALIGN(strlen(b), 4), cfg,
+ nest_level + 1);
break;
case T_PROMPT:
default:
printf("Ignoring unknown command: %.*s\n",
- (int)(p - s), s);
+ (int)(p - s), s);
eol_or_eof(&p);
}
if (cfg->default_label &&
(strcmp(label->name, cfg->default_label) == 0))
default_num = label->num;
-
}
/*