Skip to content

Commit 36ec4f8

Browse files
authored
Fix issues after CPPcheck 1.88 update (#1308)
1 parent 8dd893c commit 36ec4f8

File tree

27 files changed

+181
-177
lines changed

27 files changed

+181
-177
lines changed

.ci/static_analysis.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def cppCheck(config) {
55
sh """#!/bin/bash +x
66
cd ${config.repository_root}
77
echo "Doing cppcheck for AVR..."
8-
find . -type f \\( -iname \\*.c -o -iname \\*.cpp -o -iname \\*.ino \\) | cppcheck -j 4 --force --file-list=- --enable=style,information --platform=.mystools/cppcheck/config/avr.xml --suppressions-list=.mystools/cppcheck/config/suppressions.cfg --includes-file=.mystools/cppcheck/config/includes.cfg --language=c++ --inline-suppr --xml --xml-version=2 2> cppcheck-avr.xml
8+
find . -type f \\( -iname \\*.c -o -iname \\*.cpp -o -iname \\*.ino \\) | cppcheck -j 4 --force --file-list=- --enable=style,portability,performance --platform=.mystools/cppcheck/config/avr.xml --suppressions-list=.mystools/cppcheck/config/suppressions.cfg --includes-file=.mystools/cppcheck/config/includes.cfg --language=c++ --inline-suppr --xml --xml-version=2 2> cppcheck-avr.xml
99
cppcheck-htmlreport --file="cppcheck-avr.xml" --title="cppcheck-avr" --report-dir=cppcheck-avr_cppcheck_reports --source-dir=."""
1010

1111
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true,

.mystools/bootstrap-dev.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ check_tool_prerequisite()
1818
function ver { printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' '); }
1919

2020
if is_installed ${1} ; then
21-
#local version=$(${1} --version 2>&1 | sed -e 's/[[:alpha:]|(|[:space:]]//g')
22-
local version=$(${1} --version 2>&1 | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
21+
local version=$(${1} --version 2>&1 | sed -nre 's/^[^0-9]*(([0-9]+\.)*[0-9]+).*/\1/p')
2322
if [ $(ver ${version}) -lt $(ver ${2}) ]; then
2423
warn "Found ${1} ${version} however, version ${2} or greater is required..."
2524
return 1
25+
else
26+
log "Found ${1} ${version}"
2627
fi
2728
else
2829
warn "${1} not installed or not in current path."
@@ -73,8 +74,8 @@ check_git_remote "upstream" "${mysrepo}" || {
7374

7475
#3
7576
log "Checking tool/utility prerequisites..."
76-
check_tool_prerequisite "astyle" "2.0.5" || err "Install AStyle 2.0.5 or greater and re-run ${0}"
77-
check_tool_prerequisite "cppcheck" "1.76" || err "Install Cppcheck 1.76 or greater and re-run ${0}"
77+
check_tool_prerequisite "astyle" "3.1" || err "Install AStyle 3.1 or greater and re-run ${0}"
78+
check_tool_prerequisite "cppcheck" "1.88" || err "Install Cppcheck 1.88 or greater and re-run ${0}"
7879
check_tool_prerequisite "git" "2.0" || err "Install git 2.0 or greater and re-run ${0}"
7980

8081
#4
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
.
2-
hal/architecture/Linux/drivers/core
3-
hal/architecture/Linux/drivers/BCM
4-
hal/crypto/generic/drivers/AES
5-
core
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
ConfigurationNotChecked
2-
unmatchedSuppression
3-
// This suppression is because the problem is in an in-lined macro so in-line-suppressions does not appear to take effect
4-
unreadVariable:*/MyHwNRF5.cpp
1+
// inline suppression doesn't work
2+
*:hal/architecture/NRF5/drivers/Flash.cpp
3+
*:drivers/NVM/NVRAM.cpp
4+
*:hal\transport\RFM69\driver\old\RFM69_old.cpp
5+
// 3rd party
6+
*:hal/architecture/Linux/drivers/BCM/bcm2835.c
7+
*:hal/architecture/Linux/drivers/core/Client.h
8+
*:hal/architecture/Linux/drivers/core/EthernetClient.cpp
9+
*:hal/architecture/Linux/drivers/core/EthernetClient.h
10+
*:hal/architecture/Linux/drivers/core/EthernetServer.cpp
11+
*:hal/architecture/Linux/drivers/core/EthernetServer.h
12+
*:hal/architecture/Linux/drivers/core/SerialPort.h
13+
*:hal/architecture/Linux/drivers/core/StdInOutStream.h

.mystools/cppcheck/config/unix32.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.mystools/cppcheck/options.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22

3-
OPTIONS="--quiet \
4-
--error-exitcode=1 \
5-
--force \
6-
--enable=style,information \
7-
-DCPPCHECK \
8-
--language=c++ \
9-
--library=${LIBRARY:-avr} \
10-
--platform="${TOOLCONFIG}"/${PLATFORM:-avr.xml} \
3+
OPTIONS="--quiet \
4+
--error-exitcode=1 \
5+
--force \
6+
--enable=style,portability,performance \
7+
-DCPPCHECK \
8+
--language=c++ \
9+
--library=${LIBRARY:-avr} \
10+
--platform="${TOOLCONFIG}"/${PLATFORM:-avr.xml} \
1111
--includes-file="${TOOLCONFIG}"/includes.cfg \
12-
--inline-suppr \
12+
--inline-suppr \
1313
--suppressions-list="${TOOLCONFIG}"/suppressions.cfg"
1414

1515
echo $OPTIONS

MyConfig.h

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,56 @@
15531553
/** @}*/ // End of GatewaySettingGrpPub group
15541554

15551555
/**
1556-
* @defgroup lEDSettingGrpPub LED
1556+
* @defgroup GSMSettingGrpPub GSM
1557+
* @ingroup MyConfigGrp
1558+
* @brief These options control GSM specific configurations.
1559+
* @{
1560+
*/
1561+
/**
1562+
* @def MY_GSM_APN
1563+
* @brief APN from your cell carrier / mobile provider. Example: 4g.tele2.se
1564+
*/
1565+
//#define MY_GSM_APN
1566+
/**
1567+
* @def MY_GSM_BAUDRATE
1568+
* @brief Baudrate for your GSM modem. If left undefined, TinyGSM will try to auto detect the correct rate
1569+
*/
1570+
//#define MY_GSM_BAUDRATE (9600u)
1571+
/**
1572+
* @def MY_GSM_PIN
1573+
* @brief PIN code for your SIM card, if PIN lock is active.
1574+
*/
1575+
//#define MY_GSM_PIN
1576+
/**
1577+
* @def MY_GSM_PSW
1578+
* @brief If using a GSM modem, this is the password supplied by your cell carrier / mobile provider. If using ESP8266 as a WiFi modem, this is your WiFi network password
1579+
*/
1580+
//#define MY_GSM_PSW
1581+
/**
1582+
* @def MY_GSM_RX
1583+
* @brief If defined, uses softSerial using defined pins (must also define MY_GSM_TX)
1584+
*/
1585+
//#define MY_GSM_RX
1586+
/**
1587+
* @def MY_GSM_SSID
1588+
* @brief If using ESP8266 as WiFi modem, this is your network SSID
1589+
*/
1590+
//#define MY_GSM_SSID
1591+
/**
1592+
* @def MY_GSM_TX
1593+
* @brief If defined, uses softSerial using defined pins (must also define MY_GSM_RX)
1594+
*/
1595+
//#define MY_GSM_TX
1596+
/**
1597+
* @def MY_GSM_USR
1598+
* @brief Supplied by your cell carrier / mobile operator. If not required, leave undefined.
1599+
*/
1600+
//#define MY_GSM_USR
1601+
1602+
/** @}*/ // End of GSMSettingGrpPub group
1603+
1604+
/**
1605+
* @defgroup LEDSettingGrpPub LED
15571606
* @ingroup MyConfigGrp
15581607
* @brief These options control LED specific configurations.
15591608
* @{
@@ -2238,47 +2287,14 @@
22382287
#define MY_CONTROLLER_IP_ADDRESS
22392288
#define MY_CONTROLLER_URL_ADDRESS
22402289
// TinyGSM
2241-
/**
2242-
* @def MY_GSM_APN
2243-
* @brief APN from your cell carrier / mobile provider. Example: 4g.tele2.se
2244-
*/
22452290
#define MY_GSM_APN
2246-
/**
2247-
* @def MY_GSM_BAUDRATE
2248-
* @brief Baudrate for your GSM modem. If left undefined, TinyGSM will try to auto detect the correct rate
2249-
*/
22502291
#define MY_GSM_BAUDRATE
2251-
/**
2252-
* @def MY_GSM_PIN
2253-
* @brief PIN code for your SIM card, if PIN lock is active.
2254-
*/
22552292
#define MY_GSM_PIN
2256-
/**
2257-
* @def MY_GSM_PSW
2258-
* @brief If using a GSM modem, this is the password supplied by your cell carrier / mobile provider. If using ESP8266 as a WiFi modem, this is your WiFi network password
2259-
*/
22602293
#define MY_GSM_PSW
2261-
/**
2262-
* @def MY_GSM_RX
2263-
* @brief If defined, uses softSerial using defined pins (must also define MY_GSM_TX)
2264-
*/
22652294
#define MY_GSM_RX
2266-
/**
2267-
* @def MY_GSM_SSID
2268-
* @brief If using ESP8266 as WiFi modem, this is your network SSID
2269-
*/
22702295
#define MY_GSM_SSID
2271-
/**
2272-
* @def MY_GSM_TX
2273-
* @brief If defined, uses softSerial using defined pins (must also define MY_GSM_RX)
2274-
*/
22752296
#define MY_GSM_TX
2276-
/**
2277-
* @def MY_GSM_USR
2278-
* @brief Supplied by your cell carrier / mobile operator. If not required, leave undefined.
2279-
*/
22802297
#define MY_GSM_USR
2281-
22822298
// LED
22832299
#define MY_DEFAULT_ERR_LED_PIN
22842300
#define MY_DEFAULT_TX_LED_PIN

core/MyGatewayTransportEthernet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool gatewayTransportInit(void)
248248
bool gatewayTransportSend(MyMessage &message)
249249
{
250250
int nbytes = 0;
251-
char *_ethernetMsg = protocolMyMessage2Serial(message);
251+
char *_ethernetMessage = protocolMyMessage2Serial(message);
252252

253253
setIndication(INDICATION_GW_TX);
254254

@@ -260,7 +260,7 @@ bool gatewayTransportSend(MyMessage &message)
260260
#else
261261
_ethernetServer.beginPacket(_ethernetControllerIP, MY_PORT);
262262
#endif /* End of MY_CONTROLLER_URL_ADDRESS */
263-
_ethernetServer.write((uint8_t *)_ethernetMsg, strlen(_ethernetMsg));
263+
_ethernetServer.write((uint8_t *)_ethernetMessage, strlen(_ethernetMessage));
264264
// returns 1 if the packet was sent successfully
265265
nbytes = _ethernetServer.endPacket();
266266
#else /* Else part of MY_USE_UDP */
@@ -283,18 +283,18 @@ bool gatewayTransportSend(MyMessage &message)
283283
return false;
284284
}
285285
}
286-
nbytes = client.write((const uint8_t*)_ethernetMsg, strlen(_ethernetMsg));
286+
nbytes = client.write((const uint8_t *)_ethernetMessage, strlen(_ethernetMessage));
287287
#endif /* End of MY_USE_UDP */
288288
#else /* Else part of MY_GATEWAY_CLIENT_MODE */
289289
// Send message to connected clients
290290
#if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)
291291
for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) {
292292
if (clients[i] && clients[i].connected()) {
293-
nbytes += clients[i].write((uint8_t *)_ethernetMsg, strlen(_ethernetMsg));
293+
nbytes += clients[i].write((uint8_t *)_ethernetMessage, strlen(_ethernetMessage));
294294
}
295295
}
296296
#else /* Else part of MY_GATEWAY_ESPxx*/
297-
nbytes = _ethernetServer.write(_ethernetMsg);
297+
nbytes = _ethernetServer.write(_ethernetMessage);
298298
#endif /* End of MY_GATEWAY_ESPxx */
299299
#endif /* End of MY_GATEWAY_CLIENT_MODE */
300300
_w5100_spi_en(false);

core/MyOTAFirmwareUpdate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ LOCAL bool firmwareOTAUpdateProcess(void)
141141
#ifdef MCUBOOT_PRESENT
142142
if (_msg.type == ST_FIRMWARE_CONFIRM) {
143143
if (*(uint16_t *)MCUBOOT_IMAGE_0_MAGIC_ADDR == ((uint16_t)MCUBOOT_IMAGE_MAGIC)) {
144-
if (*(uint8_t*)(MCUBOOT_IMAGE_0_IMG_OK_ADDR)!=MCUBOOT_IMAGE_0_IMG_OK_BYTE) {
144+
if (*(uint8_t *)(MCUBOOT_IMAGE_0_IMG_OK_ADDR) != MCUBOOT_IMAGE_0_IMG_OK_BYTE) {
145145
// Calculate data word to write
146-
uint32_t *img_ok_base_addr = (uint32_t*)(MCUBOOT_IMAGE_0_IMG_OK_ADDR & ~3); // align word wise
146+
uint32_t *img_ok_base_addr = (uint32_t *)(MCUBOOT_IMAGE_0_IMG_OK_ADDR & ~3); // align word wise
147147
uint32_t img_ok_data = *img_ok_base_addr;
148148
// Set copy of MCUBOOT_IMAGE_0_IMG_OK_ADDR to MCUBOOT_IMAGE_0_IMG_OK_BYTE (0x01)
149-
uint8_t * img_ok_array = (uint8_t*)(&img_ok_data);
150-
img_ok_array[MCUBOOT_IMAGE_0_IMG_OK_ADDR % 4] = MCUBOOT_IMAGE_0_IMG_OK_BYTE;
149+
uint8_t *img_ok_array = (uint8_t *)&img_ok_data;
150+
*(img_ok_array + (MCUBOOT_IMAGE_0_IMG_OK_ADDR % 4)) = MCUBOOT_IMAGE_0_IMG_OK_BYTE;
151151
// Write word back
152152
Flash.write(img_ok_base_addr, img_ok_data);
153153
}

core/MySigning.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ bool signerCheckTimer(void)
195195

196196
bool signerSignMsg(MyMessage &msg)
197197
{
198-
bool ret;
199198
#if defined(MY_SIGNING_FEATURE)
199+
bool ret;
200200
// If destination is known to require signed messages and we are the sender,
201201
// sign this message unless it is identified as an exception
202202
if (DO_SIGN(msg.destination) && msg.sender == getNodeId()) {
@@ -255,11 +255,12 @@ bool signerSignMsg(MyMessage &msg)
255255
getNodeId()); // Will not sign message since it was from someone else
256256
ret = true;
257257
}
258+
return ret;
258259
#else
259260
(void)msg;
260-
ret = true;
261+
return true;
261262
#endif // MY_SIGNING_FEATURE
262-
return ret;
263+
263264
}
264265

265266
bool signerVerifyMsg(MyMessage &msg)

0 commit comments

Comments
 (0)