cppcheck 2.6 suggests to use const for num array in the code below:
#include <inttypes.h> #include <stdio.h> #include <sstream> uint32_t str_to_ip(const char * ip_str) { uint16_t num[4]; std::istringstream ss(ip_str); char ch; ss >> num[3] >> ch >> num[2] >> ch >> num[1] >> ch >> num[0]; return (num[3] & 0xFF) << 24 | (num[2] & 0xFF) << 16 | (num[1] & 0xFF) << 8 | (num[0] & 0xFF); } int main() { printf("%u\n", str_to_ip("127.0.0.1")); return 0; }
[test.cpp:7]: (style) Variable 'num' can be declared with const
Have you tried with current head? I can't reproduce it there.
Yes, issue not reproduced with cppcheck from main branch (hash: 4f9a563570980a2022785b90825c8ea7690b2cbb)
Log in to post a comment.
cppcheck 2.6 suggests to use const for num array in the code below:
Have you tried with current head? I can't reproduce it there.
Yes, issue not reproduced with cppcheck from main branch (hash: 4f9a563570980a2022785b90825c8ea7690b2cbb)