Skip to content

Commit

Permalink
Revert "Remove pragmas to disable -Wstringop-truncation"
Browse files Browse the repository at this point in the history
I was compiling with Clang, and not GCC.  Put the warning back in!

This reverts commit 659eeae.
  • Loading branch information
lpereira committed May 19, 2024
1 parent 8455a52 commit 58dae65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bin/tools/mimegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,11 @@ int main(int argc, char *argv[])
for (i = 0; i < hash_get_count(ext_mime); i++) {
uint64_t ext_lower = 0;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
/* See lwan_determine_mime_type_for_file_name() in lwan-tables.c */
strncpy((char *)&ext_lower, exts[i], 8);
#pragma GCC diagnostic pop

ext_lower &= ~0x2020202020202020ull;
ext_lower = htobe64(ext_lower);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/lwan-tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,14 @@ const char *lwan_determine_mime_type_for_file_name(const char *file_name)
if (LIKELY(last_dot && *last_dot)) {
uint64_t key = 0;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
/* Data is stored with NULs on strings up to 7 chars, and no NULs
* for 8-char strings, because that's implicit. So truncation is
* intentional here: comparison in compare_mime_entry() always loads
* 8 bytes per extension. */
strncpy((char *)&key, last_dot + 1, 8);
#pragma GCC diagnostic pop

return bsearch_mime_type(htobe64(key & ~0x2020202020202020ull));
}
Expand Down

0 comments on commit 58dae65

Please sign in to comment.