Merge https://gitlab.denx.de/u-boot/custodians/u-boot-marvell
[oweals/u-boot.git] / tools / env / fw_env_main.c
index 6fdf41c8760422b27fd381b4ba56473f5a6fce4e..1d193bd437d83ddfd78508765959f1c4561923c7 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2000-2008
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -27,6 +26,7 @@
  * of AES key), eg. '-a aabbccddeeff00112233445566778899'.
  */
 
+#include <env.h>
 #include <fcntl.h>
 #include <getopt.h>
 #include <stdio.h>
@@ -46,7 +46,7 @@ static struct option long_options[] = {
        {"config", required_argument, NULL, 'c'},
        {"help", no_argument, NULL, 'h'},
        {"script", required_argument, NULL, 's'},
-       {"noheader", required_argument, NULL, 'n'},
+       {"noheader", no_argument, NULL, 'n'},
        {"lock", required_argument, NULL, 'l'},
        {"version", no_argument, NULL, 'v'},
        {NULL, 0, NULL, 0}
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
        argv += optind;
 
        if (env_opts.lockname) {
-               lockname = malloc(sizeof(env_opts.lockname) +
+               lockname = malloc(strlen(env_opts.lockname) +
                                sizeof(CMD_PRINTENV) + 10);
                if (!lockname) {
                        fprintf(stderr, "Unable allocate memory");