]> Git Repo - J-u-boot.git/blobdiff - cmd/bcb.c
cmd: sf: Display errno on erase failure
[J-u-boot.git] / cmd / bcb.c
index 5da3526142ada8ae3f06241319ea34b72e58f97c..6b6f1e9a2f10ca4f2ed6c10e203059f218c8aa43 100644 (file)
--- a/cmd/bcb.c
+++ b/cmd/bcb.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <log.h>
 #include <part.h>
+#include <malloc.h>
 
 enum bcb_cmd {
        BCB_CMD_LOAD,
@@ -179,10 +180,10 @@ static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
        return __bcb_load(devnum, argv[2]);
 }
 
-static int __bcb_set(char *fieldp, char *valp)
+static int __bcb_set(char *fieldp, const char *valp)
 {
        int size, len;
-       char *field, *str, *found;
+       char *field, *str, *found, *tmp;
 
        if (bcb_field_get(fieldp, &field, &size))
                return CMD_RET_FAILURE;
@@ -193,14 +194,20 @@ static int __bcb_set(char *fieldp, char *valp)
                       valp, len, size, fieldp);
                return CMD_RET_FAILURE;
        }
-       str = valp;
+       str = strdup(valp);
+       if (!str) {
+               printf("Error: Out of memory while strdup\n");
+               return CMD_RET_FAILURE;
+       }
 
+       tmp = str;
        field[0] = '\0';
-       while ((found = strsep(&str, ":"))) {
+       while ((found = strsep(&tmp, ":"))) {
                if (field[0] != '\0')
                        strcat(field, "\n");
                strcat(field, found);
        }
+       free(str);
 
        return CMD_RET_SUCCESS;
 }
@@ -308,7 +315,7 @@ static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc,
        return __bcb_store();
 }
 
-int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp)
+int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp)
 {
        int ret;
 
This page took 0.027198 seconds and 4 git commands to generate.