Misc/Microtonal: fix gcc compiler warning
commitcd41eac2ae76cdd9aeba7a2d47d2c7b1473f0937
authorJulien Olivain <ju.o@free.fr>
Fri, 31 Dec 2021 11:57:46 +0000 (31 12:57 +0100)
committerMark McCurry <mark.d.mccurry@gmail.com>
Fri, 31 Dec 2021 16:44:17 +0000 (31 11:44 -0500)
tree221f772f9ae70dee5b73db444b8d13fef30ad17e
parent24b272e243a4b766a4cb3bee290a083d708cc3d1
Misc/Microtonal: fix gcc compiler warning

gcc warns about possible unintended string operation truncation. This commit
change the code to make it detected by gcc as an intended string truncation,
thus fixing the warning.

This commit fixes the warning:

    src/Misc/Microtonal.cpp: In static member function ‘static int zyn::Microtonal::loadscl(zyn::SclInfo&, const char*)’:
    src/Misc/Microtonal.cpp:640:12: warning: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated copying 119 bytes from a string of length 499 [-Wstringop-truncation]
      640 |     strncpy(scl.Pname,    tmp, MICROTONAL_MAX_NAME_LEN);
          |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/Misc/Microtonal.cpp:641:12: warning: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated copying 119 bytes from a string of length 499 [-Wstringop-truncation]
      641 |     strncpy(scl.Pcomment, tmp, MICROTONAL_MAX_NAME_LEN);
          |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: this warning is reported by gcc 11.2.1, on Fedora 35.

Signed-off-by: Julien Olivain <ju.o@free.fr>
src/Misc/Microtonal.cpp