dediprog: Split device type and version parsing
Parse the device type with a separate sscanf() call. This will make
support for newer programmers easier that are identified by more than
a simple number.
Change-Id: I2bb4cb3f88b2e18092458508eb872a668887cf3a
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/93
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/dediprog.c b/dediprog.c
index 28ac7fb..82364e8 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -838,8 +838,9 @@
unsigned int sfnum;
unsigned int fw[3];
- if (sscanf(buf, "SF%u V:%u.%u.%u ", &sfnum, &fw[0], &fw[1], &fw[2]) != 4 ||
- sfnum != dp_data->devicetype) {
+ if (sscanf(buf, "SF%u", &sfnum) != 1 ||
+ sfnum != dp_data->devicetype ||
+ sscanf(buf, "SF%*s V:%u.%u.%u ", &fw[0], &fw[1], &fw[2]) != 3) {
msg_perr("Unexpected firmware version string '%s'\n", buf);
return 1;
}