#include <common.h>
#include <log.h>
#include <part.h>
+#include <malloc.h>
enum bcb_cmd {
BCB_CMD_LOAD,
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;
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;
}
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;
#define __BCB_H__
#if CONFIG_IS_ENABLED(CMD_BCB)
-int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp);
+int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp);
#else
#include <linux/errno.h>
-static inline int bcb_write_reboot_reason(int devnum, char *partp, char *reasonp)
+static inline int bcb_write_reboot_reason(int devnum, char *partp, const char *reasonp)
{
return -EOPNOTSUPP;
}