[PATCH] datatrak.c: don't use POSIX %m format for sscanf() in dtrak_prepare_data()
Lubomir I. Ivanov
neolit123 at gmail.com
Fri Jun 9 15:25:17 PDT 2017
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
The format option "%m" doesn't work for MINGW/Windows and is reported as
an unknown conversation type and this sscanf() call would not work.
The alternative is to malloc() enough space manually - e.g.
strlen(input) + 1.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
Salva, please have a look if you have a minute to verify my change
as i don't know how to test this code.
strdup() should be another way of doing it, given
we aren't doing any parsing - e.g. ignoring digits with:
%[A-Za-z]
---
core/datatrak.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/core/datatrak.c b/core/datatrak.c
index e61e5c1..2f827c1 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -115,7 +115,8 @@ static int dtrak_prepare_data(int model, device_data_t *dev_data)
while (model != g_models[i].model_num && g_models[i].model_num != 0xEE)
i++;
dev_data->model = copy_string(g_models[i].name);
- sscanf(g_models[i].name,"%m[A-Za-z] ", &dev_data->vendor);
+ dev_data->vendor = (const char *)malloc(strlen(g_models[i].name) + 1);
+ sscanf(g_models[i].name, "%[A-Za-z] ", (char *)dev_data->vendor);
dev_data->product = copy_string(strchr(g_models[i].name, ' ') + 1);
d = get_descriptor(g_models[i].type, g_models[i].libdc_num);
--
1.7.11.msysgit.0
More information about the subsurface
mailing list