From e4115e85f734a6dc2d59654308eb2474375a7370 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Fri, 31 Jan 2025 13:25:26 -0500 Subject: [PATCH] Prevent chipdb array type narrowing conversion issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When -Wnarrowing is enabled, compilation of generated chipdb*.bin.cc files produces a large number of messages: "narrowing conversion of ... from ‘int’ to ‘const char’ [-Wnarrowing]" Explicitly using uint8_t instead of char when referencing embedded chipdb arrays resolves these issues. Suggested-by: Catherine Signed-off-by: Gabriel Somlo --- bba/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bba/main.cc b/bba/main.cc index 50d2c89974..735dc4993e 100644 --- a/bba/main.cc +++ b/bba/main.cc @@ -409,7 +409,7 @@ int main(int argc, char **argv) for (auto &s : preText) fprintf(fileOut, "%s\n", s.c_str()); - fprintf(fileOut, "const char %s[%d] =\n\"", streams[0].name.c_str(), int(data.size()) + 1); + fprintf(fileOut, "const uint8_t %s[%d] =\n\"", streams[0].name.c_str(), int(data.size()) + 1); cursor = 1; for (int i = 0; i < int(data.size()); i++) { @@ -451,7 +451,7 @@ int main(int argc, char **argv) for (auto &s : preText) fprintf(fileOut, "%s\n", s.c_str()); - fprintf(fileOut, "const char %s[%d] = {\n", streams[0].name.c_str(), int(data.size()) + 1); + fprintf(fileOut, "const uint8_t %s[%d] = {\n", streams[0].name.c_str(), int(data.size()) + 1); fprintf(fileOut, "#embed \"%s\"\n", boost::filesystem::path(files.at(2)).c_str()); fprintf(fileOut, "};\n");