Replace --mainboard with -p internal:mainboard
NOTE:
The --list-supported-wiki output changed to use -p internal:mainboard=
instead of -m
The --list-supported output changed the heading of the mainboard list
from
Vendor Board Status Required option
to
Vendor Board Status Required value for
-p internal:mainboard=
Fix lb_vendor_dev_from_string() not to write to the supplied string.
Corresponding to flashrom svn r1483.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
diff --git a/cbtable.c b/cbtable.c
index ea8964a..4495d9d 100644
--- a/cbtable.c
+++ b/cbtable.c
@@ -33,18 +33,27 @@
char *lb_part = NULL, *lb_vendor = NULL;
int partvendor_from_cbtable = 0;
-void lb_vendor_dev_from_string(char *boardstring)
+/* Parse the [<vendor>:]<board> string specified by the user as part of
+ * -p internal:mainboard=[<vendor>:]<board> and set lb_vendor and lb_part
+ * to the extracted values.
+ * Note: strtok modifies the original string, so we work on a copy and allocate
+ * memory for lb_vendor and lb_part with strdup.
+ */
+void lb_vendor_dev_from_string(const char *boardstring)
{
+ /* strtok may modify the original string. */
+ char *tempstr = strdup(boardstring);
char *tempstr2 = NULL;
- strtok(boardstring, ":");
+ strtok(tempstr, ":");
tempstr2 = strtok(NULL, ":");
if (tempstr2) {
- lb_vendor = boardstring;
- lb_part = tempstr2;
+ lb_vendor = strdup(tempstr);
+ lb_part = strdup(tempstr2);
} else {
lb_vendor = NULL;
- lb_part = boardstring;
+ lb_part = strdup(tempstr);
}
+ free(tempstr);
}
static unsigned long compute_checksum(void *addr, unsigned long length)