diff --git a/dist/tools/cppcheck/README.md b/dist/tools/cppcheck/README.md index 92a32b68b4929ee59e0abb54572bc9155cf8a187..732cde1b3329d7297c6e85691b171a88c1a9ce63 100644 --- a/dist/tools/cppcheck/README.md +++ b/dist/tools/cppcheck/README.md @@ -15,12 +15,19 @@ Check all files changed in the current branch against the branch named Check all files but ignore warnings about unused struct members: - ./dist/tools/cppcheck/check.sh --suppress=unusedStructMember + ./dist/tools/cppcheck/check.sh --suppress=unassignedVariable Check all files changed in the current branch against the branch named -'master', ignoring warnings about unused struct members: +'master', ignoring warnings about unassigned variables: - ./dist/tools/cppcheck/check.sh master --suppress=unusedStructMember --suppress=unassignedVariable + ./dist/tools/cppcheck/check.sh master --suppress=unassignedVariable + +# Default options + +This script suppresses warnings of the type "unusedStructMember" by default. If +you want to get warnings about "unusedStructMembers" run the script with the +--show-unused-struct option: + ./dist/tools/cppcheck/check.sh --show-unused-struct [BRANCH] [options to be passed] # What to do about the findings diff --git a/dist/tools/cppcheck/check.sh b/dist/tools/cppcheck/check.sh index 065552a3d68880c4c30090b9069174cc757bc0f8..d8de0c5f9f54263b71fdc7bb19c44129123bf53c 100755 --- a/dist/tools/cppcheck/check.sh +++ b/dist/tools/cppcheck/check.sh @@ -1,6 +1,14 @@ #!/bin/sh -CHECKROOT=$(dirname "${0}") +# Don't show warnings about unusedStructMembers by default +DEFAULT_SUPPRESSIONS="${1}" +if echo "${DEFAULT_SUPPRESSIONS}" | grep -q '^--show-unused-struct'; then + DEFAULT_SUPPRESSIONS="" + shift 1 +else + DEFAULT_SUPPRESSIONS=--suppress="unusedStructMember" +fi + BRANCH=${1} FILEREGEX='\.([sScHh]|cpp)$' @@ -33,6 +41,5 @@ if [ -z "${FILES}" ]; then fi cppcheck --std=c99 --enable=style --force --error-exitcode=2 --quiet -j 8 \ - --inline-suppr --suppressions ${CHECKROOT}/vendor_suppressions.txt \ - --template "{file}:{line}: {severity} ({id}): {message}" \ - ${@} ${FILES} + --template "{file}:{line}: {severity} ({id}): {message}" \ + --inline-suppr ${DEFAULT_SUPPRESSIONS} ${@} ${FILES} diff --git a/dist/tools/cppcheck/vendor_suppressions.txt b/dist/tools/cppcheck/vendor_suppressions.txt deleted file mode 100644 index eb0ed89675cadc631434c908b56d774b1b76bccb..0000000000000000000000000000000000000000 --- a/dist/tools/cppcheck/vendor_suppressions.txt +++ /dev/null @@ -1,23 +0,0 @@ -unusedStructMember:boards/chronos/drivers/include/display.h -unusedStructMember:boards/x86-multiboot-common/include/multiboot.h -unusedStructMember:cpu/atmega_common/avr-libc-extra/time.h -unusedStructMember:cpu/cc2538/include/cc2538-gpio.h -unusedStructMember:cpu/cc2538/include/cc2538-uart.h -unusedStructMember:cpu/cc2538/include/gptimer.h -unusedStructMember:cpu/cc2538/include/rfcore.h -unusedStructMember:cpu/cc2538/include/soc-adc.h -unusedStructMember:cpu/cortex-m0_common/include/core_*.h -unusedStructMember:cpu/cortex-m3_common/include/core_*.h -unusedStructMember:cpu/cortex-m4_common/include/core_*.h -unusedStructMember:cpu/lpc1768/include/LPC17xx.h -unusedStructMember:cpu/lpc1768/include/core_cm3.h -unusedStructMember:cpu/sam3x8e/include/sam3x8e.h -unusedStructMember:cpu/samd21/include/component/component_*.h -unusedStructMember:cpu/samd21/include/samd21.h -unusedStructMember:cpu/stm32f0/include/stm32f051x8.h -unusedStructMember:cpu/stm32f1/include/stm32f10x.h -unusedStructMember:cpu/stm32f3/include/stm32f303xc.h -unusedStructMember:cpu/stm32f4/include/stm32f407xx.h -unusedStructMember:cpu/stm32f4/include/stm32f415xx.h -unusedStructMember:tests/unittests/embunit/embUnit/RepeatedTest.h -unusedStructMember:tests/unittests/embunit/embUnit/Test*.h diff --git a/drivers/include/netdev/802154.h b/drivers/include/netdev/802154.h index 9e0660efb174d26943195ca8e3cb6e12bc57bfb4..e949fe60693c50bc2ab4abf1c76b136437378d83 100644 --- a/drivers/include/netdev/802154.h +++ b/drivers/include/netdev/802154.h @@ -139,8 +139,6 @@ typedef struct { /** * @see netdev_driver_t::init */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*init)(netdev_t *dev); /** @@ -148,8 +146,6 @@ typedef struct { * * @see netdev_driver_t::send_data */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*send_data)(netdev_t *dev, void *dest, size_t dest_len, netdev_hlist_t *upper_layer_hdrs, void *data, size_t data_len); @@ -157,15 +153,11 @@ typedef struct { /** * @see netdev_driver_t::add_receive_data_callback */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*add_receive_data_callback)(netdev_t *dev, netdev_rcv_data_cb_t cb); /** * @see netdev_driver_t::rem_receive_data_callback */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*rem_receive_data_callback)(netdev_t *dev, netdev_rcv_data_cb_t cb); /** @@ -182,8 +174,6 @@ typedef struct { * NETDEV_OPT_TX_POWER | int | >= 4 * NETDEV_OPT_MAX_PACKET_SIZE | uint8_t | >= 1 */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*get_option)(netdev_t *dev, netdev_opt_t opt, void *value, size_t *value_len); @@ -202,30 +192,22 @@ typedef struct { * * NETDEV_OPT_MAX_PACKET_SIZE can not be set. */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*set_option)(netdev_t *dev, netdev_opt_t opt, void *value, size_t value_len); /** * @see netdev_driver_t::get_state */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*get_state)(netdev_t *dev, netdev_state_t *state); /** * @see netdev_driver_t::set_state */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (*set_state)(netdev_t *dev, netdev_state_t state); /** * @see netdev_driver_t::event */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ void (*event)(netdev_t *dev, uint32_t event_type); /** @@ -256,8 +238,6 @@ typedef struct { * @return The outcome of this packet's transmission. * @see netdev_802154_tx_status_t */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ netdev_802154_tx_status_t (* load_tx)(netdev_t *dev, netdev_802154_pkt_kind_t kind, netdev_802154_node_addr_t *dest, @@ -275,8 +255,6 @@ typedef struct { * @return The outcome of this packet's transmission. * @see netdev_802154_tx_status_t */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ netdev_802154_tx_status_t (* transmit)(netdev_t *dev); /** @@ -308,8 +286,6 @@ typedef struct { * @return The outcome of this packet's transmission. * @see netdev_802154_tx_status_t */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ netdev_802154_tx_status_t (* send)(netdev_t *dev, netdev_802154_pkt_kind_t kind, netdev_802154_node_addr_t *dest, @@ -338,8 +314,6 @@ typedef struct { * @return -ENOBUFS, if maximum number of registrable callbacks is exceeded * @return -ENODEV, if *dev* is not recognized */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (* add_receive_raw_callback)(netdev_t *dev, netdev_802154_raw_packet_cb_t recv_func); /** @@ -353,8 +327,6 @@ typedef struct { * @return 0, on success * @return -ENODEV, if *dev* is not recognized */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (* rem_receive_raw_callback)(netdev_t *dev, netdev_802154_raw_packet_cb_t recv_func); /** @@ -367,8 +339,6 @@ typedef struct { * @return 0 if another transmission is already running. * @return -ENODEV, if *dev* is not recognized */ - /* suppress because interface is not used yet */ - /* cppcheck-suppress unusedStructMember */ int (* channel_is_clear)(netdev_t *dev); } netdev_802154_driver_t; diff --git a/sys/include/config.h b/sys/include/config.h index 03b84d86e1f0b728ff3b7e234a2b3d1bae44b6e1..905eb913ce90c37f0ba1a491b4a63abb4068e1e0 100644 --- a/sys/include/config.h +++ b/sys/include/config.h @@ -40,14 +40,12 @@ extern char configmem[]; * @brief Stores configuration data of the node. */ typedef struct { - /* cppcheck-suppress unusedStructMember : is used in sys/shell/commands/sc_id.c */ uint16_t id; /**< unique node identifier */ #ifdef FEATURE_TRANSCEIVER radio_address_t radio_address; /**< address for radio communication */ uint8_t radio_channel; /**< current frequency */ uint16_t radio_pan_id; /**< PAN id for radio communication */ #endif - /* cppcheck-suppress unusedStructMember : useful for debug purposes */ char name[CONFIG_NAME_LEN]; /**< name of the node */ } config_t; @@ -55,7 +53,6 @@ typedef struct { * @brief Element to store in flashrom. */ typedef struct { - /* cppcheck-suppress unusedStructMember : magic_key is only read directly from ROM */ uint16_t magic_key; /**< validity check */ config_t config; /**< the node's configuration */ } configmem_t;