constParameter - Parameter 'DataToEncrypt' can be declared with const
It isn't recognizing that memcpy can affect the data.
This might be a simpler way to reproduce this one https://sourceforge.net/p/cppcheck/discussion/general/thread/dda510831e/
namespace constParameterCallbackFalsePostive { struct DataToEncrypt { // cppcheck-suppress unusedStructMember - submitted separately static const int ENCRYPTED_DATA_BUF_SIZE = 128; unsigned char EncryptedDataBuf[ENCRYPTED_DATA_BUF_SIZE]; }; void Encrypt(DataToEncrypt& DataToEncrypt) { unsigned char data[] = "asfasd"; memcpy(DataToEncrypt.EncryptedDataBuf, &data, sizeof(data)); } }
Oddly, there is no FP if the source parameter of memcpy is not const void*:
const void*
//void mc(void* dst, const void* src, int size); // FP void mc(void* dst, const char* src, int size); // no FP struct DataToEncrypt { char EncryptedDataBuf[128]; }; void Encrypt(DataToEncrypt& DataToEncrypt) { char data[] = "asfasd"; mc(DataToEncrypt.EncryptedDataBuf, &data, sizeof(data)); }
Ticket is here: https://trac.cppcheck.net/ticket/10483
Log in to post a comment.
constParameter - Parameter 'DataToEncrypt' can be declared with const
It isn't recognizing that memcpy can affect the data.
This might be a simpler way to reproduce this one https://sourceforge.net/p/cppcheck/discussion/general/thread/dda510831e/
Oddly, there is no FP if the source parameter of memcpy is not
const void*
:Ticket is here: https://trac.cppcheck.net/ticket/10483