Skip to content

Commit e4115e8

Browse files
gsomlowhitequark
authored andcommitted
Prevent chipdb array type narrowing conversion issues
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]>
1 parent 7718761 commit e4115e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bba/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int main(int argc, char **argv)
409409
for (auto &s : preText)
410410
fprintf(fileOut, "%s\n", s.c_str());
411411

412-
fprintf(fileOut, "const char %s[%d] =\n\"", streams[0].name.c_str(), int(data.size()) + 1);
412+
fprintf(fileOut, "const uint8_t %s[%d] =\n\"", streams[0].name.c_str(), int(data.size()) + 1);
413413

414414
cursor = 1;
415415
for (int i = 0; i < int(data.size()); i++) {
@@ -451,7 +451,7 @@ int main(int argc, char **argv)
451451
for (auto &s : preText)
452452
fprintf(fileOut, "%s\n", s.c_str());
453453

454-
fprintf(fileOut, "const char %s[%d] = {\n", streams[0].name.c_str(), int(data.size()) + 1);
454+
fprintf(fileOut, "const uint8_t %s[%d] = {\n", streams[0].name.c_str(), int(data.size()) + 1);
455455
fprintf(fileOut, "#embed \"%s\"\n", boost::filesystem::path(files.at(2)).c_str());
456456
fprintf(fileOut, "};\n");
457457

0 commit comments

Comments
 (0)