probonopd / MiniDexed

Dexed FM synthesizer similar to 8x DX7 (TX816/TX802) running on a bare metal Raspberry Pi (without a Linux kernel or operating system)
https://github.com/probonopd/MiniDexed/wiki
962 stars 72 forks source link

Warnings about truncated strings related to VoiceName #648

Closed diyelectromusic closed 1 month ago

diyelectromusic commented 2 months ago

The build is producing these warnings:

minidexed.cpp: In member function 'void CMiniDexed::SetVoiceName(std::string, unsigned int)':
minidexed.cpp:1771:9: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 10 equals destination size [-Wstringop-truncation]
 1771 |  strncpy(Name, VoiceName.c_str(),10);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Synth_Dexed/src/dexed.cpp: In member function 'void Dexed::setName(char*)':
../Synth_Dexed/src/dexed.cpp:1699:10: warning: 'char* strncpy(char*, const char*, size_t)' output may be truncated copying 10 bytes from a string of length 155 [-Wstringop-truncation]
 1699 |   strncpy(name, (char*)&data[DEXED_VOICE_OFFSET + DEXED_NAME], 10);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Should probably have a look into that at some point - I think it's fine, but it would be good to get rid of the warnings if so!

Kevin

probonopd commented 1 month ago

Should hopefully be fixed now; comment here if it is not. Thanks!