Skip to content

Commit

Permalink
Merge pull request collectd#4286 from octo/6/strict-prototypes
Browse files Browse the repository at this point in the history
[collectd 6] Enable `-Wstrict-prototypes`.
  • Loading branch information
octo authored Feb 20, 2024
2 parents 974c4e1 + b228a8a commit 82ec9de
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 87 deletions.
50 changes: 27 additions & 23 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ clang_pedantic_task:
# probably always fail
allow_failures: true
skip_notifications: true
git_submodule_script:
- git submodule init -- opentelemetry-proto
- git submodule update -- opentelemetry-proto
configure_script:
- ./build.sh
- clang --version
- >
./configure CC=clang CXX=clang++
$DEFAULT_CONFIG_OPTS
CFLAGS='-gdwarf-4 -Wall
env:
VALGRIND_OPTS: "--errors-for-leak-kinds=definite"
CFLAGS: >-
-gdwarf-4
-Wno-error
-Wall
-Wextra
-Wformat=2
-Wformat-security
Expand All @@ -37,7 +32,6 @@ clang_pedantic_task:
-Wmissing-prototypes
-Wimplicit-function-declaration
-Wmissing-declarations
-Wstrict-prototypes
-Wmissing-noreturn
-Wshadow
-Wendif-labels
Expand All @@ -47,11 +41,18 @@ clang_pedantic_task:
-Wdate-time
-Wnested-externs
-Wno-typedef-redefinition
-Wno-gnu-variable-sized-type-not-at-end'
-Wno-gnu-variable-sized-type-not-at-end
git_submodule_script:
- git submodule init -- opentelemetry-proto
- git submodule update -- opentelemetry-proto
configure_script:
- ./build.sh
- clang --version
- ./configure CC=clang CXX=clang++ $DEFAULT_CONFIG_OPTS
build_script:
- make -j$(nproc) -sk
- make -j$(nproc) -sk CFLAGS="${CFLAGS} -Werror=strict-prototypes"
tests_script:
- VALGRIND_OPTS="--errors-for-leak-kinds=definite" make -j$(nproc) -sk check
- make -j$(nproc) check CFLAGS="${CFLAGS} -Werror=strict-prototypes"
always:
make_check_artifacts:
path: "**/*.log"
Expand All @@ -72,22 +73,23 @@ bleeding_edge_compilers_task:
CC: clang
CC: clang-18
CC: clang-17
VALGRIND_OPTS: "--errors-for-leak-kinds=definite"
git_submodule_script:
- git submodule init -- opentelemetry-proto
- git submodule update -- opentelemetry-proto
configure_script:
- ./build.sh
- $CC --version
- >
./configure CC=$CC
$DEFAULT_CONFIG_OPTS
./configure ${DEFAULT_CONFIG_OPTS}
CC="$CC"
CFLAGS="$(dpkg-buildflags --get CFLAGS)"
CPPLAGS="$(dpkg-buildflags --get CPPFLAGS)"
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"
build_script:
- make -j$(nproc) -sk
- make -j$(nproc) -sk CFLAGS="$(dpkg-buildflags --get CFLAGS) -Werror=strict-prototypes"
tests_script:
- VALGRIND_OPTS="--errors-for-leak-kinds=definite" make -j$(nproc) -sk check
- make -j$(nproc) check CFLAGS="$(dpkg-buildflags --get CFLAGS) -Werror=strict-prototypes"
always:
make_check_artifacts:
path: "**/*.log"
Expand All @@ -97,6 +99,8 @@ FreeBSD_task:
matrix:
- image_family: freebsd-13-2
allow_failures: false
env:
VALGRIND_OPTS: "--errors-for-leak-kinds=definite"
pkg_install_script:
- >
pkg install --yes
Expand All @@ -110,11 +114,11 @@ FreeBSD_task:
- git submodule update -- opentelemetry-proto
configure_script:
- ./build.sh
- ./configure --disable-perl
- ./configure ${DEFAULT_CONFIG_OPTS} --disable-perl
build_script:
- make -j$(nproc) -sk
- make -j$(nproc) -sk CFLAGS="${CFLAGS} -Werror=strict-prototypes"
tests_script:
- VALGRIND_OPTS="--errors-for-leak-kinds=definite" make -j$(nproc) -sk check
- make -j$(nproc) check CFLAGS="${CFLAGS} -Werror=strict-prototypes"
always:
make_check_artifacts:
path: "**/*.log"
Expand All @@ -139,9 +143,9 @@ MacOS_task:
- ./build.sh
- ./configure ${DEFAULT_CONFIG_OPTS}
build_script:
- make -j "${CIRRUS_CPU}" -sk
- make -j "${CIRRUS_CPU}" -sk CFLAGS="${CFLAGS} -Werror=strict-prototypes"
tests_script:
- make -j "${CIRRUS_CPU}" -sk check
- make -j "${CIRRUS_CPU}" -sk check CFLAGS="${CFLAGS} -Werror=strict-prototypes"
always:
make_check_artifacts:
path: "**/*.log"
16 changes: 11 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@ jobs:
- fedora39
- fedora38
configure_flags: ['--enable-compatibility-mode']
cflags: ['']
include:
- container_tag: debian12
configure_flags: '--enable-compatibility-mode --enable-debug'
cflags: ''
- container_tag: debian12
configure_flags: '--enable-compatibility-mode CC=clang CXX=clang++'
# By default clang emits DWARF v5, which Valgrind cannot read yet.
# https://github.com/llvm/llvm-project/issues/56550
configure_flags: '--enable-compatibility-mode CC=clang CXX=clang++ CFLAGS=-gdwarf-4'
cflags: '-gdwarf-4'
env:
CONFIGURE_FLAGS: ${{ matrix.configure_flags }}
CFLAGS: ${{ matrix.cflags }}
# this env var picked up by valgrind during make check phase
VALGRIND_OPTS: "--errors-for-leak-kinds=definite"
steps:
Expand All @@ -64,12 +68,14 @@ jobs:
with:
name: ${{ matrix.container_tag }}
path: config.log
# The configure script relies on the old syntax to check whether functions
# exist, so we can't specify `-Wstrict-prototypes` globally.
- name: Build collectd
run: make -j$(nproc) -sk
run: make -j$(nproc) -sk CFLAGS="${CFLAGS} -Werror=strict-prototypes"
- name: Run make check
run: |
set +e
make $MAKEFLAGS check
make $MAKEFLAGS check CFLAGS="${CFLAGS} -Werror=strict-prototypes"
echo "$?" >make-check.status
continue-on-error: true
- name: Upload log files
Expand Down Expand Up @@ -129,11 +135,11 @@ jobs:
name: ${{ matrix.container_tag }}
path: config.log
- name: Build collectd
run: make -j$(nproc) -sk
run: make -j$(nproc) -sk CFLAGS="${CFLAGS} -Werror=strict-prototypes"
- name: Run make check
run: |
set +e
make $MAKEFLAGS check
make $MAKEFLAGS check CFLAGS="${CFLAGS} -Werror=strict-prototypes"
echo "$?" >make-check.status
continue-on-error: true
- name: Upload log files
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7062,6 +7062,7 @@ fi
if test "x$with_libcurl" != "xyes"; then
plugin_write_http="no (libcurl not found)"
plugin_bind="no (libcurl not found)"
fi
if test "x$with_libyajl2" != "xyes"; then
plugin_write_http="no (libyajl2 not found)"
Expand All @@ -7071,6 +7072,15 @@ if test "x$with_libhiredis" != "xyes"; then
plugin_write_redis="no (libhiredis not found)"
fi
if test "x$with_libxml2" != "xyes"; then
plugin_bind="no (libxml2 not found)"
plugin_curl_xml="no (libxml2 not found)"
fi
if test "x$have_strptime" != "xyes"; then
plugin_bind="no (strptime not found)"
fi
if test "x$with_libyajl" = "xyes"; then
plugin_ceph="yes"
plugin_log_logstash="yes"
Expand Down
6 changes: 3 additions & 3 deletions src/capabilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void cap_logger(__attribute__((unused)) void *arg, char const *fmt,
}

#if defined(MHD_VERSION) && MHD_VERSION >= 0x00090000
static int cap_open_socket() {
static int cap_open_socket(void) {
char service[NI_MAXSERV];
snprintf(service, sizeof(service), "%hu", httpd_port);

Expand Down Expand Up @@ -305,7 +305,7 @@ static int cap_open_socket() {
}
#endif

static struct MHD_Daemon *cap_start_daemon() {
static struct MHD_Daemon *cap_start_daemon(void) {
#if defined(MHD_VERSION) && MHD_VERSION >= 0x00090000
int fd = cap_open_socket();
if (fd == -1) {
Expand Down Expand Up @@ -368,7 +368,7 @@ static int cap_config(oconfig_item_t *ci) {
return status;
}

static int cap_shutdown() {
static int cap_shutdown(void) {
if (httpd != NULL) {
MHD_stop_daemon(httpd);
httpd = NULL;
Expand Down
10 changes: 5 additions & 5 deletions src/connectivity.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static void connectivity_dispatch_notification(const char *interface,
}

// NOTE: Caller MUST hold connectivity_data_lock when calling this function
static void send_interface_status() {
static void send_interface_status(void) {
for (interface_list_t *il = interface_list_head; il != NULL;
il = il->next) /* {{{ */
{
Expand All @@ -642,7 +642,7 @@ static void send_interface_status() {
statuses_to_send = 0;
}

static void read_interface_status() /* {{{ */
static void read_interface_status(void) /* {{{ */
{
pthread_mutex_lock(&connectivity_data_lock);

Expand Down Expand Up @@ -695,7 +695,7 @@ static void *connectivity_dequeue_thread(void *arg) /* {{{ */
return ((void *)0);
} /* }}} void *connectivity_dequeue_thread */

static int nl_connect() {
static int nl_connect(void) {
struct sockaddr_nl sa_nl = {
.nl_family = AF_NETLINK,
.nl_groups = RTMGRP_LINK,
Expand Down Expand Up @@ -884,7 +884,7 @@ static int stop_netlink_thread(int shutdown) /* {{{ */
return thread_status;
}

static int stop_dequeue_thread() /* {{{ */
static int stop_dequeue_thread(void) /* {{{ */
{
pthread_mutex_lock(&connectivity_threads_lock);

Expand Down Expand Up @@ -924,7 +924,7 @@ static int stop_dequeue_thread() /* {{{ */
return status;
} /* }}} int stop_dequeue_thread */

static int stop_threads() /* {{{ */
static int stop_threads(void) /* {{{ */
{
int status = stop_netlink_thread(1);
int status2 = stop_dequeue_thread();
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ EXPORT int plugin_unregister_cache_event(const char *name) {
return 0;
}

static void destroy_cache_event_callbacks() {
static void destroy_cache_event_callbacks(void) {
for (size_t i = 0; i < list_cache_event_num; i++) {
cache_event_func_t *cef = &list_cache_event[i];
if (!cef->callback)
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/utils_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int cache_compare(void const *a, void const *b) {
return strcmp(ea->name, eb->name);
} /* int cache_compare */

static cache_entry_t *cache_alloc() {
static cache_entry_t *cache_alloc(void) {
cache_entry_t *ce;

ce = calloc(1, sizeof(*ce));
Expand Down
4 changes: 2 additions & 2 deletions src/dpdkstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ dpdk_helper_ctx_t *g_hc = NULL;
static char g_shm_name[DATA_MAX_NAME_LEN] = DPDK_STATS_NAME;
static dpdk_stat_cfg_status g_state = DPDK_STAT_STATE_OKAY;

static int dpdk_stats_reinit_helper();
static int dpdk_stats_reinit_helper(void);
static void dpdk_stats_default_config(void) {
dpdk_stats_ctx_t *ec = DPDK_STATS_CTX_GET(g_hc);

Expand Down Expand Up @@ -421,7 +421,7 @@ static int dpdk_stats_counters_dispatch(dpdk_helper_ctx_t *phc) {
return 0;
}

static int dpdk_stats_reinit_helper() {
static int dpdk_stats_reinit_helper(void) {
DPDK_STATS_TRACE();

dpdk_stats_ctx_t *ctx = DPDK_STATS_CTX_GET(g_hc);
Expand Down
4 changes: 2 additions & 2 deletions src/grpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ class CollectdImpl : public collectd::Collectd::Service {
*/
class CollectdServer final {
public:
void Start() {
void Start(void) {
auto auth = grpc::InsecureServerCredentials();

grpc::ServerBuilder builder;
Expand Down Expand Up @@ -553,7 +553,7 @@ class CollectdServer final {
server_ = builder.BuildAndStart();
} /* Start() */

void Shutdown() { server_->Shutdown(); } /* Shutdown() */
void Shutdown(void) { server_->Shutdown(); } /* Shutdown() */

private:
CollectdImpl collectd_service_;
Expand Down
8 changes: 4 additions & 4 deletions src/intel_rdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ static int rdt_refresh_ngroup(rdt_name_group_t *ngroup,
* RETURN VALUE
* 0 on success. Negative number on error.
*/
static int read_pids_data() {
static int read_pids_data(void) {

if (0 == g_rdt->num_ngroups) {
DEBUG(RDT_PLUGIN ": read_pids_data: not configured - PIDs read skipped");
Expand Down Expand Up @@ -858,7 +858,7 @@ static int read_pids_data() {
* DESCRIPTION
* Initialize pids monitoring for all name groups
*/
static void rdt_init_pids_monitoring() {
static void rdt_init_pids_monitoring(void) {
for (size_t group_idx = 0; group_idx < g_rdt->num_ngroups; group_idx++) {
/*
* Each group must have not-null proc_pids array.
Expand Down Expand Up @@ -1206,7 +1206,7 @@ static int rdt_config(oconfig_item_t *ci) {
return 0;
}

static int read_cores_data() {
static int read_cores_data(void) {

if (0 == g_rdt->cores.num_cgroups) {
DEBUG(RDT_PLUGIN ": read_cores_data: not configured - Cores read skipped");
Expand Down Expand Up @@ -1257,7 +1257,7 @@ static int rdt_read(__attribute__((unused)) user_data_t *ud) {
return 0;
}

static void rdt_init_cores_monitoring() {
static void rdt_init_cores_monitoring(void) {
for (size_t i = 0; i < g_rdt->cores.num_cgroups; i++) {
core_group_t *cg = g_rdt->cores.cgroups + i;

Expand Down
2 changes: 1 addition & 1 deletion src/intel_rdt_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int pqos_cap_get_event(const struct pqos_cap *cap,
/***************************************************************************
* helper functions
*/
rdt_ctx_t *stub_rdt_setup() {
rdt_ctx_t *stub_rdt_setup(void) {

rdt_ctx_t *rdt = calloc(1, sizeof(*rdt));
struct pqos_cpuinfo *pqos_cpu = calloc(1, sizeof(*pqos_cpu));
Expand Down
2 changes: 1 addition & 1 deletion src/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ static void *c_ipmi_thread_main(void *user_data) {
return (void *)0;
} /* void *c_ipmi_thread_main */

static c_ipmi_instance_t *c_ipmi_init_instance() {
static c_ipmi_instance_t *c_ipmi_init_instance(void) {
c_ipmi_instance_t *st;

st = calloc(1, sizeof(*st));
Expand Down
Loading

0 comments on commit 82ec9de

Please sign in to comment.