From 072bef16666e0ec397b8236e92722b2f1347b59b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 23 Jan 2019 13:28:39 +1300 Subject: [PATCH] shearwater: properly initialize the string caches The merge with Jef's upstream ended up taking a lot of Jef's changes to how the Shearwater PNF parsing was done, and in the process inadvertdly lost some of the code from our side of the branch that Jef hadn't taken. In particular, the initialization of the string cache, and the logversion string. Put them back. Signed-off-by: Linus Torvalds --- src/shearwater_predator_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 332c3fd..19abbec 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -442,6 +442,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) if (parser->cached) { return DC_STATUS_SUCCESS; } + memset(parser->strings, 0, sizeof(parser->strings)); // Verify the minimum length. if (size < 2) { @@ -577,6 +578,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) // Log versions before 6 weren't reliably stored in the data, but // 6 is also the oldest version that we assume in our code unsigned int logversion = data[parser->opening[4] + (pnf ? 16 : 127)]; + add_string_fmt(parser, "Logversion", "%d%s", logversion, pnf ? "(PNF)" : ""); // The transmitter battery levels are only valid for logversion 7+ if (logversion < 7) {