Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cppcheck config to pass cleanly #3829

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions daemons/pacemakerd/pcmkd_subdaemons.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,19 @@ start_child(pcmk_child_t * child)
/* parent */
mainloop_child_add(child->pid, 0, name, child, pcmk_child_exit);

crm_info("Forked process %lld using user %lu (%s) and group %lu "
"for subdaemon %s%s",
(long long) child->pid, (unsigned long) uid,
pcmk__s(child->uid, "root"), (unsigned long) gid, name,
use_valgrind ? " (valgrind enabled: " PCMK__VALGRIND_EXEC ")" : "");
if (use_valgrind) {
crm_info("Forked process %lld using user %lu (%s) and group %lu "
"for subdaemon %s (valgrind enabled: %s)",
(long long) child->pid, (unsigned long) uid,
pcmk__s(child->uid, "root"), (unsigned long) gid, name,
PCMK__VALGRIND_EXEC);
} else {
crm_info("Forked process %lld using user %lu (%s) and group %lu "
"for subdaemon %s",
(long long) child->pid, (unsigned long) uid,
pcmk__s(child->uid, "root"), (unsigned long) gid, name);
}

return pcmk_rc_ok;

} else {
Expand Down
2 changes: 2 additions & 0 deletions devel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ CPPCHECK_OUT = $(abs_top_builddir)/cppcheck.out
.PHONY: cppcheck
cppcheck:
cppcheck $(CPPCHECK_ARGS) -I $(top_srcdir)/include \
-I $(top_srcdir)/lib/common \
--include=/usr/include/qb/qblog.h \
--output-file=$(CPPCHECK_OUT) \
--max-configs=30 --inline-suppr -q \
--library=posix --library=gnu --library=gtk \
Expand Down
2 changes: 0 additions & 2 deletions include/crm/common/io_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ void pcmk__close_fds_in_child(bool);
static inline void
pcmk__open_devnull(int flags)
{
// Static analysis clutter
// cppcheck-suppress leakReturnValNotUsed
(void) open("/dev/null", flags);
}

Expand Down
2 changes: 0 additions & 2 deletions lib/cluster/cpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,6 @@ send_cpg_text(const char *data, const pcmk__node_status_t *node,
msg->compressed_size = new_size;

} else {
// cppcheck seems not to understand the abort logic in pcmk__realloc
// cppcheck-suppress memleak
msg = pcmk__realloc(msg, msg->header.size);
memcpy(msg->data, data, msg->size);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/common/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ pcmk__build_arg_context(pcmk__common_args_t *common_args, const char *fmts,
}

// main_group is now owned by context, we don't free it here
// cppcheck-suppress memleak
return context;
}

Expand Down Expand Up @@ -139,7 +138,6 @@ pcmk__add_arg_group(GOptionContext *context, const char *name,
g_option_group_add_entries(group, entries);
g_option_context_add_group(context, group);
// group is now owned by context, we don't free it here
// cppcheck-suppress memleak
}

static gchar *
Expand Down
2 changes: 0 additions & 2 deletions lib/common/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ pcmk__build_path(const char *path_c, mode_t mode)
int rc = pcmk_rc_ok;
char *path = strdup(path_c);

// cppcheck seems not to understand the abort logic in CRM_CHECK
// cppcheck-suppress memleak
CRM_CHECK(path != NULL, return -ENOMEM);
for (len = strlen(path); offset < len; offset++) {
if (path[offset] == '/') {
Expand Down
2 changes: 2 additions & 0 deletions lib/common/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ pcmk__register_format(GOptionGroup *group, const char *name,

pcmk__assert((create != NULL) && !pcmk__str_empty(name));

// cppcheck doesn't understand the above pcmk__assert line
// cppcheck-suppress ctunullpointer
name_copy = strdup(name);
if (name_copy == NULL) {
return ENOMEM;
Expand Down
2 changes: 0 additions & 2 deletions lib/common/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,6 @@ connect_socket_retry(int sock, const struct sockaddr *addr, socklen_t addrlen,
*timer_id = timer;
}

// timer callback should be taking care of cb_data
// cppcheck-suppress memleak
return pcmk_rc_ok;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/common/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ pcmk__parse_ll_range(const char *srcstring, long long *start, long long *end)
pcmk__assert((start != NULL) && (end != NULL));

*start = PCMK__PARSE_INT_DEFAULT;
// cppcheck doesn't understand the above pcmk__assert line
// cppcheck-suppress ctunullpointer
*end = PCMK__PARSE_INT_DEFAULT;

crm_trace("Attempting to decode: [%s]", srcstring);
Expand Down
2 changes: 0 additions & 2 deletions lib/common/xml_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ decompress_file(const char *filename)
goto done;
}

// cppcheck seems not to understand the abort-logic in pcmk__realloc
// cppcheck-suppress memleak
do {
int read_len = 0;

Expand Down
2 changes: 2 additions & 0 deletions lib/pacemaker/pcmk_ticket.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ pcmk__get_ticket_state(cib_t *cib, const char *ticket_id, xmlNode **state)
char *xpath = NULL;

pcmk__assert((cib != NULL) && (state != NULL));
// cppcheck doesn't understand the above pcmk__assert line
// cppcheck-suppress ctunullpointer
*state = NULL;

if (ticket_id != NULL) {
Expand Down