Fix beningn GCC 10.2 Wstringop-truncation warnings
authorAndrey Alekseenko <al42and@gmail.com>
Thu, 22 Apr 2021 16:44:08 +0000 (18:44 +0200)
committerAndrey Alekseenko <al42and@gmail.com>
Fri, 23 Apr 2021 09:20:19 +0000 (09:20 +0000)
commit8131144363709eed7325a52dc4c035973b39046e
tree83d743e6eeebbdd65821272c5ed576cbf879f708
parente9d9588e470fc1928bb1e989197e72457abf1076
Fix beningn GCC 10.2 Wstringop-truncation warnings

- `get_pdb_atomnumber`
  GCC was worried that we're copying up to 4 bytes to a buffer of
  length 4, not leaving the space for terminating \0. The source string
  is guaranteed to have length 3 + terminator, so not a problem.
  Changed to strcpy, since it should be safe here.
  While at it, renamed a variable, gave a name to a magic constant,
  added a static_assert to ensure safety.

- `read_vsite_database`
  GCC was complaining that we're copying 4094 bytes from a string of
  length 4094, possibly truncating the terminating \0. The string was
  guaranteed to have a terminator in its first 4093 bytes (fgets2 will
  put it no later than STRLEN-2, and we also skip the first character).
  But to make GCC happy, I see no harm in adding 1 more byte to strncpy.

Another warning from GCC is an actual error, fixed in MR !1487.
src/gromacs/fileio/pdbio.cpp
src/gromacs/gmxpreprocess/gen_vsite.cpp