Skip to content

Commit

Permalink
Prevent chipdb array type narrowing conversion issues
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Gabriel Somlo <[email protected]>
  • Loading branch information
gsomlo authored and whitequark committed Feb 1, 2025
1 parent 7718761 commit e4115e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bba/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit e4115e8

Please sign in to comment.