Skip to content

Commit

Permalink
Merge pull request collectd#4262 from eero-t/gcc-pedantic-func
Browse files Browse the repository at this point in the history
[collectd 6, WIP] Fix more GCC "-Wpedantic" warnings
  • Loading branch information
octo authored Jan 31, 2024
2 parents be50c50 + a9fd34c commit 61a1e35
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 78 deletions.
12 changes: 6 additions & 6 deletions src/dcpmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static void add_metric(const char *plugin_inst, const char *type,
} /* void add_metric */

static int dcpmm_read(__attribute__((unused)) user_data_t *ud) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

int i, ret = 0;
char dimm_num[16];
Expand Down Expand Up @@ -167,12 +167,12 @@ static int dcpmm_read(__attribute__((unused)) user_data_t *ud) {
} /* int dcpmm_read */

static int dcpmm_stop(void) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

int ret = 0;

if (skip_stop) {
DEBUG(PLUGIN_NAME ": %s:%d skipping stop function", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d skipping stop function", __func__, __LINE__);

return ret;
}
Expand All @@ -186,7 +186,7 @@ static int dcpmm_stop(void) {
} /* int dcpmm_stop */

static int dcpmm_shutdown(void) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

int ret = 0;

Expand All @@ -198,7 +198,7 @@ static int dcpmm_shutdown(void) {
} /* int dcpmm_shutdown */

static int dcpmm_init(void) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

int ret = 0;

Expand Down Expand Up @@ -239,7 +239,7 @@ static int dcpmm_init(void) {
} /* int dcpmm_init */

static int dcpmm_config(oconfig_item_t *ci) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

int ret = 0;

Expand Down
12 changes: 6 additions & 6 deletions src/dpdk_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static char g_dpdk_path[BUF_SIZE];
static int dpdk_telemetry_config(oconfig_item_t *ci) {
int ret, i;

DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

for (i = 0; i < ci->children_num; i++) {
oconfig_item_t *child = ci->children + i;
Expand All @@ -85,7 +85,7 @@ static int dpdk_telemetry_config(oconfig_item_t *ci) {
}

if (ret < 0) {
INFO(PLUGIN_NAME ": %s:%d ret =%d", __FUNCTION__, __LINE__, ret);
INFO(PLUGIN_NAME ": %s:%d ret =%d", __func__, __LINE__, ret);
return ret;
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ static int dpdk_telemetry_cleanup(void) {
}

static int dpdk_telemetry_socket_init(void) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);
char message[BUF_SIZE];

/* Here we look up the length of the g_dpdk_path string
Expand Down Expand Up @@ -319,7 +319,7 @@ static int dpdk_telemetry_socket_init(void) {
}

static int dpdk_telemetry_shutdown(void) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);
char msg[BUF_SIZE];
int ret;

Expand All @@ -338,7 +338,7 @@ static int dpdk_telemetry_shutdown(void) {
}

static int dpdk_telemetry_read(user_data_t *ud) {
DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);
char buffer[BUF_SIZE];
int bytes = 0, ret;
char *json_string[MAX_COMMANDS] = {"{\"action\":0,\"command\":"
Expand Down Expand Up @@ -378,7 +378,7 @@ static int dpdk_telemetry_read(user_data_t *ud) {

static int dpdk_telemetry_init(void) {

DEBUG(PLUGIN_NAME ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PLUGIN_NAME ": %s:%d", __func__, __LINE__);

client.s_send = -1;
client.s_recv = -1;
Expand Down
8 changes: 4 additions & 4 deletions src/dpdkevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ typedef enum {
#define DPDK_EVENTS_CTX_GET(a) ((dpdk_events_ctx_t *)dpdk_helper_priv_get(a))

#define DPDK_EVENTS_TRACE() \
DEBUG("%s:%s:%d pid=%u", DPDK_EVENTS_PLUGIN, __FUNCTION__, __LINE__, getpid())
DEBUG("%s:%s:%d pid=%u", DPDK_EVENTS_PLUGIN, __func__, __LINE__, getpid())

static dpdk_helper_ctx_t *g_hc;
static dpdk_events_cfg_status g_state;
Expand Down Expand Up @@ -497,7 +497,7 @@ static void dpdk_events_gauge_submit(const char *plugin_instance,

static int dpdk_events_link_status_dispatch(dpdk_helper_ctx_t *phc) {
dpdk_events_ctx_t *ec = DPDK_EVENTS_CTX_GET(phc);
DEBUG(DPDK_EVENTS_PLUGIN ": %s:%d ports=%u", __FUNCTION__, __LINE__,
DEBUG(DPDK_EVENTS_PLUGIN ": %s:%d ports=%u", __func__, __LINE__,
ec->nb_ports);

/* dispatch Link Status values to collectd */
Expand Down Expand Up @@ -552,7 +552,7 @@ static void dpdk_events_keep_alive_dispatch(dpdk_helper_ctx_t *phc) {
} else {
WARNING(DPDK_EVENTS_PLUGIN
": %s:%d Core id %u is out of 0 to %u range, skipping",
__FUNCTION__, __LINE__, i, INT64_BIT_SIZE * 2);
__func__, __LINE__, i, INT64_BIT_SIZE * 2);
continue;
}

Expand Down Expand Up @@ -639,7 +639,7 @@ static int dpdk_events_read(user_data_t *ud) {
if (ka_ret) {
ERROR(DPDK_EVENTS_PLUGIN
": %s : error %d in dpdk_event_keep_alive_shm_open()",
__FUNCTION__, ka_ret);
__func__, ka_ret);
} else
dpdk_events_keep_alive_dispatch(g_hc);
}
Expand Down
10 changes: 5 additions & 5 deletions src/dpdkstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define DPDK_STATS_NAME "dpdk_collectd_stats"

#define DPDK_STATS_TRACE() \
DEBUG("%s:%s:%d pid=%u", DPDK_STATS_PLUGIN, __FUNCTION__, __LINE__, getpid())
DEBUG("%s:%s:%d pid=%u", DPDK_STATS_PLUGIN, __func__, __LINE__, getpid())

struct dpdk_stats_config_s {
cdtime_t interval;
Expand Down Expand Up @@ -266,7 +266,7 @@ static int dpdk_helper_stats_count_get(dpdk_helper_ctx_t *phc) {
stats_count += len;
}

DPDK_CHILD_LOG("%s:%s:%d stats_count=%d\n", DPDK_STATS_PLUGIN, __FUNCTION__,
DPDK_CHILD_LOG("%s:%s:%d stats_count=%d\n", DPDK_STATS_PLUGIN, __func__,
__LINE__, stats_count);

return stats_count;
Expand Down Expand Up @@ -301,7 +301,7 @@ int dpdk_helper_command_handler(dpdk_helper_ctx_t *phc, enum DPDK_CMD cmd) {
DPDK_CHILD_LOG(
DPDK_STATS_PLUGIN
":%s:%d not enough space for stats (available=%d, needed=%d)\n",
__FUNCTION__, __LINE__, (int)dpdk_stats_get_size(phc), stats_size);
__func__, __LINE__, (int)dpdk_stats_get_size(phc), stats_size);
return -ENOBUFS;
}

Expand Down Expand Up @@ -384,7 +384,7 @@ static int dpdk_stats_counters_dispatch(dpdk_helper_ctx_t *phc) {

/* dispatch stats values to collectd */

DEBUG("%s:%s:%d ports=%u", DPDK_STATS_PLUGIN, __FUNCTION__, __LINE__,
DEBUG("%s:%s:%d ports=%u", DPDK_STATS_PLUGIN, __func__, __LINE__,
ctx->ports_count);

int stats_count = 0;
Expand Down Expand Up @@ -429,7 +429,7 @@ static int dpdk_stats_reinit_helper() {
size_t data_size = sizeof(dpdk_stats_ctx_t) +
(ctx->stats_count * DPDK_STATS_CTX_GET_XSTAT_SIZE);

DEBUG("%s:%d helper reinit (new_size=%" PRIsz ")", __FUNCTION__, __LINE__,
DEBUG("%s:%d helper reinit (new_size=%" PRIsz ")", __func__, __LINE__,
data_size);

dpdk_stats_ctx_t tmp_ctx;
Expand Down
14 changes: 7 additions & 7 deletions src/intel_pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static int pmu_config_hw_events(oconfig_item_t *ci, intel_pmu_entity_t *ent) {

static int pmu_config(oconfig_item_t *ci) {

DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PMU_PLUGIN ": %s:%d", __func__, __LINE__);

for (int i = 0; i < ci->children_num; i++) {
int ret = 0;
Expand Down Expand Up @@ -257,7 +257,7 @@ static int pmu_config(oconfig_item_t *ci) {
}

if (ret != 0) {
DEBUG(PMU_PLUGIN ": %s:%d ret=%d", __FUNCTION__, __LINE__, ret);
DEBUG(PMU_PLUGIN ": %s:%d ret=%d", __func__, __LINE__, ret);
return ret;
}
}
Expand Down Expand Up @@ -427,18 +427,18 @@ static void pmu_dispatch_data(intel_pmu_entity_t *ent) {

static int pmu_read(user_data_t *ud) {
if (ud == NULL) {
ERROR(PMU_PLUGIN ": ud is NULL! %s:%d", __FUNCTION__, __LINE__);
ERROR(PMU_PLUGIN ": ud is NULL! %s:%d", __func__, __LINE__);
return -1;
}
if (ud->data == NULL) {
ERROR(PMU_PLUGIN ": ud->data is NULL! %s:%d", __FUNCTION__, __LINE__);
ERROR(PMU_PLUGIN ": ud->data is NULL! %s:%d", __func__, __LINE__);
return -1;
}
intel_pmu_entity_t *ent = (intel_pmu_entity_t *)ud->data;
int ret;
struct event *e;

DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PMU_PLUGIN ": %s:%d", __func__, __LINE__);

/* read all events only for configured cores */
for (e = ent->event_list->eventlist; e; e = e->next) {
Expand Down Expand Up @@ -703,7 +703,7 @@ static int pmu_read_all_events(void *data, char *name, char *event,
static int pmu_init(void) {
int ret;

DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PMU_PLUGIN ": %s:%d", __func__, __LINE__);

if (g_ctx.entl == NULL) {
ERROR(PMU_PLUGIN ": No events were setup in configuration.");
Expand Down Expand Up @@ -861,7 +861,7 @@ static int pmu_init(void) {

static int pmu_shutdown(void) {

DEBUG(PMU_PLUGIN ": %s:%d", __FUNCTION__, __LINE__);
DEBUG(PMU_PLUGIN ": %s:%d", __func__, __LINE__);

for (intel_pmu_entity_t *ent = g_ctx.entl; ent != NULL;) {
intel_pmu_entity_t *tmp = ent;
Expand Down
2 changes: 1 addition & 1 deletion src/ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ static void smi_event_handler(ipmi_con_t __attribute__((unused)) * ipmi,
unsigned int type = ipmi_event_get_type(event);
ipmi_domain_t *domain = cb_data;

DEBUG("%s: Event received: type %u", __FUNCTION__, type);
DEBUG("%s: Event received: type %u", __func__, type);

if (type != 0x02)
/* It's not a standard IPMI event. */
Expand Down
6 changes: 3 additions & 3 deletions src/mcelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static int socket_write(socket_adapter_t *self, const char *msg,

static void mcelog_dispatch_notification(notification_t *n) {
if (!n) {
ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __FUNCTION__);
ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __func__);
return;
}

Expand Down Expand Up @@ -401,7 +401,7 @@ static int mcelog_dispatch_mem_notifications(const mcelog_memory_rec_t *mr) {
static int mcelog_submit(const mcelog_memory_rec_t *mr) {

if (!mr) {
ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __FUNCTION__);
ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __func__);
return -1;
}

Expand Down Expand Up @@ -656,7 +656,7 @@ static int get_memory_machine_checks(void) {
}

static int mcelog_read(__attribute__((unused)) user_data_t *ud) {
DEBUG(MCELOG_PLUGIN ": %s", __FUNCTION__);
DEBUG(MCELOG_PLUGIN ": %s", __func__);

if (get_memory_machine_checks() != 0)
ERROR(MCELOG_PLUGIN ": MACHINE CHECK INFO NOT AVAILABLE");
Expand Down
13 changes: 7 additions & 6 deletions src/mdevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define DAEMON_NAME "mdadm"

#define MD_EVENTS_ERROR(err_msg, ...) \
ERROR(MD_EVENTS_PLUGIN ": %s: " err_msg, __FUNCTION__, ##__VA_ARGS__)
ERROR(MD_EVENTS_PLUGIN ": %s: " err_msg, __func__, ##__VA_ARGS__)

// Syslog can be located under different paths on various linux distros;
// The following two cover the debian-based and redhat distros
Expand Down Expand Up @@ -213,9 +213,9 @@ static int md_events_config(const char *key, const char *value) {

static void md_events_handle_regex_error(int rc, regex_t *regex,
const char *func_name) {
char buf[MAX_ERROR_MSG] = {};
char buf[MAX_ERROR_MSG];

regerror(rc, regex, buf, MAX_ERROR_MSG);
regerror(rc, regex, buf, sizeof(buf));
DEBUG("%s() failed with '%s'\n", func_name, buf);
}

Expand Down Expand Up @@ -284,16 +284,17 @@ static void md_events_copy_match(char *buf, const char *line,
}

static int md_events_match_regex(regex_t *regex, const char *to_match) {
regmatch_t matches[MAX_MATCHES] = {};
regmatch_t matches[MAX_MATCHES];
int status, severity;
md_events_event_t event = {};

status = regexec(regex, to_match, MAX_MATCHES, matches, 0);
status = regexec(regex, to_match, STATIC_ARRAY_SIZE(matches), matches, 0);
if (status) {
md_events_handle_regex_error(status, regex, "regexec");
return -1;
}

md_events_event_t event = {0};

// each element from matches array contains the indexes (start/end) within
// the string that we ran regexp on; use them to retrieve the substrings
md_events_copy_match(event.event_name, to_match, matches[EVENT]);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cmds/cmds_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ DEF_TEST(parse) {
"cmd_parse(\"%s\", opts=%p) = "
"%d (type=%d [%s]); want %d "
"(type=%d [%s])",
parse_data[i].input, parse_data[i].opts, status, cmd.type,
parse_data[i].input, (void *)parse_data[i].opts, status, cmd.type,
CMD_TO_STRING(cmd.type), parse_data[i].expected_status,
parse_data[i].expected_type,
CMD_TO_STRING(parse_data[i].expected_type));
Expand Down
Loading

0 comments on commit 61a1e35

Please sign in to comment.