Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
32af3ff
Devel: Use more threads when running cppcheck.
clumens Apr 7, 2026
6ae123f
Refactor: libpacemaker: Check that instance is not NULL.
clumens Apr 7, 2026
d290537
Refactor: daemons: Don't assign to a variable we're just going to ove…
clumens Apr 7, 2026
1522dbc
Refactor: libcrmcluster: Make static analysis happy with proc2text.
clumens Apr 7, 2026
9fbc3c9
Refactor: daemons: Unindent code in free_xml_with_position.
clumens Apr 8, 2026
e1c70c6
Refactor: daemons,libs,tools: Add checks to help static analysis.
clumens Apr 8, 2026
4eea0e0
Refactor: daemons: Rearrange the loop in load_env_vars.
clumens Apr 8, 2026
0a29fe0
Devel: Use more threads when running scan-build.
clumens Apr 8, 2026
ff370eb
Refactor: libcrmcommon: Ignore the return value of g_list_append.
clumens Apr 13, 2026
3a80fbd
Refactor: libpacemaker: Avoid a dead assignment in promotion_score_ap…
clumens Apr 13, 2026
c85e8a4
Refactor: libcrmcommon: Explicitly check filename against NULL.
clumens Apr 13, 2026
9cb24fe
Low: libservices: Deal with fgets errors in services__get_lsb_metadata.
clumens Apr 13, 2026
9bb5c5d
Low: daemons,libcib: Fix memory leaks in IPC code.
clumens Apr 14, 2026
b5e0be3
Low: libpacemaker: If process_rsc_history exits early, free the list.
clumens Apr 15, 2026
70a8d07
Low: libpe: Free elements of rsc->priv->ticket_constraints...
clumens Apr 15, 2026
9c329f2
Refactor: libpacemaker: Simplify the rsc_ticket_t type.
clumens Apr 16, 2026
57d7c37
Low: libcrmcommon: Properly return errno from pcmk__bare_output_new.
clumens Apr 16, 2026
0a1cfb7
Med: libpacemaker: Fix a segfault in order_resource_actions_after.
clumens Apr 16, 2026
7ce46ea
Low: libpe: If pe__clone_default exits early, free the lists.
clumens Apr 16, 2026
a470fc3
Low: tools: Fix memory leaks when printing crm_verify warnings/errors.
clumens Apr 16, 2026
1905443
Low: tools: Free the list at the end of cli_resource_print_operations.
clumens Apr 16, 2026
2be2eb8
Low: libpacemaker: Fix a memory leak in inject_action.
clumens Apr 16, 2026
ec588b0
Test: valgrind: Make the bash reader_loop suppression less restrictive.
clumens Apr 16, 2026
9ff45e1
Test: valgrind: Add another suppression for a glib iconv leak.
clumens Apr 16, 2026
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
15 changes: 14 additions & 1 deletion cts/valgrind-pcmk.suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
Bash reader_loop leaks
Memcheck:Leak
fun:malloc
fun:xmalloc
...
fun:reader_loop
fun:main
Expand Down Expand Up @@ -349,3 +348,17 @@
fun:call_init
fun:_dl_init
}

{
glib - iconv
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
...
fun:g_convert_with_iconv
fun:g_convert
...
fun:g_option_context_parse
fun:g_option_context_parse_strv
fun:main
}
10 changes: 6 additions & 4 deletions daemons/based/based_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ dispatch_common(qb_ipcs_connection_t *c, void *data, bool privileged)
"cib_transaction flag set outside of any transaction",
client->name);
pcmk__log_xml_info(msg, "no-transaction");
return 0;
goto cleanup;
}

if (pcmk__is_set(call_options, cib_sync_call)) {
Expand All @@ -178,7 +178,7 @@ dispatch_common(qb_ipcs_connection_t *c, void *data, bool privileged)
xmlNode *reply = NULL;

if (!pcmk__is_set(flags, crm_ipc_client_response)) {
return 0;
goto cleanup;
}

reply = pcmk__xe_create(NULL, __func__);
Expand All @@ -188,7 +188,7 @@ dispatch_common(qb_ipcs_connection_t *c, void *data, bool privileged)

client->request_id = 0;
pcmk__xml_free(reply);
return 0;
goto cleanup;
}

if (pcmk__str_eq(op, PCMK__VALUE_CIB_NOTIFY, pcmk__str_none)) {
Expand All @@ -200,10 +200,12 @@ dispatch_common(qb_ipcs_connection_t *c, void *data, bool privileged)
}

pcmk__ipc_send_ack(client, id, flags, NULL, status);
return 0;
goto cleanup;
}

based_process_request(msg, privileged, client);

cleanup:
pcmk__xml_free(msg);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions daemons/controld/controld_te_actions.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -703,7 +703,7 @@ controld_register_graph_functions(void)
void
notify_crmd(pcmk__graph_t *graph)
{
const char *type = "unknown";
const char *type = NULL;
Comment thread
clumens marked this conversation as resolved.
enum crmd_fsa_input event = I_NULL;

pcmk__debug("Processing transition completion in state %s",
Expand Down
14 changes: 11 additions & 3 deletions daemons/execd/remoted_pidone.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,18 @@ load_env_vars(void)
return;
}

while (getline(&line, &buf_size, fp) != -1) {
load_env_var_line(line);
do {
Comment thread
clumens marked this conversation as resolved.
ssize_t rc = 0;

errno = 0;
}
rc = getline(&line, &buf_size, fp);

if (rc == -1) {
break;
}

load_env_var_line(line);
} while (true);

// getline() returns -1 on EOF (expected) or error
if (errno != 0) {
Expand Down
2 changes: 1 addition & 1 deletion daemons/fenced/pacemaker-fenced.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ main(int argc, char **argv)
}

rc = pcmk__output_new(&out, args->output_ty, args->output_dest, argv);
if (rc != pcmk_rc_ok) {
if ((rc != pcmk_rc_ok) || (out == NULL)) {
Comment thread
clumens marked this conversation as resolved.
exit_code = CRM_EX_ERROR;
g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
"Error creating output format %s: %s",
Expand Down
2 changes: 2 additions & 0 deletions devel/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ clang:
OUT=$$(cd $(top_builddir) \
&& scan-build $(CLANG_checkers:%=-enable-checker %) \
$(MAKE) $(AM_MAKEFLAGS) CFLAGS="-std=c99 $(CFLAGS)" \
-j $(shell nproc --ignore=1) \
clean all 2>&1); \
REPORT=$$(echo "$$OUT" \
| sed -n -e "s/.*'scan-view \(.*\)'.*/\1/p"); \
Expand Down Expand Up @@ -124,6 +125,7 @@ cppcheck:
--include=/usr/include/qb/qblog.h \
--output-file=$(CPPCHECK_OUT) \
--max-configs=30 --inline-suppr -q \
-j $(shell nproc --ignore=1) \
--library=posix --library=gnu --library=gtk \
$(GLIB_INCL_DEF_CFLAGS) -D__GNUC__ \
$(foreach dir,$(CPPCHECK_DIRS),$(top_srcdir)/$(dir))
Expand Down
3 changes: 3 additions & 0 deletions lib/cib/cib_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ cib_native_signon(cib_t *cib, const char *name, enum cib_conn_type type)
*/
if (pcmk__xe_is(reply, PCMK__XE_ACK) && ack_is_failure(reply)) {
rc = -EPROTO;
pcmk__xml_free(reply);
goto done;
}

Expand All @@ -369,6 +370,8 @@ cib_native_signon(cib_t *cib, const char *name, enum cib_conn_type type)
rc = -EPROTO;
}
}

pcmk__xml_free(reply);
}

done:
Expand Down
15 changes: 7 additions & 8 deletions lib/cluster/membership.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -1085,17 +1085,16 @@ update_peer_uname(pcmk__node_status_t *node, const char *uname)
static inline const char *
proc2text(enum crm_proc_flag proc)
{
const char *text = "unknown";

switch (proc) {
case crm_proc_none:
text = "none";
break;
return "none";

case crm_proc_cpg:
text = "corosync-cpg";
break;
return "corosync-cpg";

default:
return "unknown";
}
return text;
}

/*!
Expand Down
14 changes: 12 additions & 2 deletions lib/common/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,23 @@ pcmk__bare_output_new(pcmk__output_t **out, const char *fmt_name,
return ENOMEM;
}

if (pcmk__str_eq(filename, "-", pcmk__str_null_matches)) {
/* Static analysis can't figure out that passing pcmk__str_null_matches
* to pcmk__str_eq means filename can't be NULL in the else block, so
* we'll just take care of that here.
*/
if (filename == NULL) {
filename = "-";
}

if (pcmk__str_eq(filename, "-", pcmk__str_none)) {
Comment thread
clumens marked this conversation as resolved.
(*out)->dest = stdout;
} else {
(*out)->dest = fopen(filename, "w");
if ((*out)->dest == NULL) {
int rc = errno;

g_clear_pointer(out, pcmk__output_free);
return errno;
return rc;
}
}

Expand Down
8 changes: 6 additions & 2 deletions lib/common/schemas.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -407,7 +407,10 @@ load_transforms_from_dir(const char *dir)
g_hash_table_insert(transforms, version_s, list);

} else {
list = g_list_append(list, namelist[i]);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
g_list_append(list, namelist[i]);
Comment thread
clumens marked this conversation as resolved.
#pragma GCC diagnostic pop
free(version_s);
}

Expand Down Expand Up @@ -1067,6 +1070,7 @@ apply_upgrade(const xmlNode *input_xml, int schema_index, gboolean to_logs)
}

// Final result document from upgrade pipeline needs private data
pcmk__assert(new_xml != NULL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is reasonable to have. The path to get here is a bit convoluted. If schema->transforms is NULL, then we never enter the for-loop body. That should never happen thanks to the if test before the apply_upgrade() call. But we look up the schema again in apply_upgrade() based on its index.

It might make more sense to pass current_schema to apply_upgrade(), instead of passing current_schema->schema_index as we do now. Doesn't have to be this PR.

pcmk__xml_new_private_data((xmlNode *) new_xml->doc);

// Ensure result validates with its new schema
Expand Down
50 changes: 28 additions & 22 deletions lib/common/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@ free_xml_with_position(xmlNode *node, int position)
{
xmlDoc *doc = NULL;
xml_node_private_t *nodepriv = NULL;
xml_doc_private_t *docpriv = NULL;
GString *xpath = NULL;

if (node == NULL) {
return pcmk_rc_ok;
Expand Down Expand Up @@ -765,37 +767,41 @@ free_xml_with_position(xmlNode *node, int position)
return EACCES;
}

if (pcmk__xml_doc_all_flags_set(node->doc, pcmk__xf_tracking)
&& !pcmk__is_set(nodepriv->flags, pcmk__xf_created)) {
if (!pcmk__xml_doc_all_flags_set(node->doc, pcmk__xf_tracking)
|| pcmk__is_set(nodepriv->flags, pcmk__xf_created)) {
pcmk__xml_free_node(node);
return pcmk_rc_ok;
}

xml_doc_private_t *docpriv = doc->_private;
GString *xpath = pcmk__element_xpath(node);
pcmk__assert(doc != NULL);

if (xpath != NULL) {
pcmk__deleted_xml_t *deleted_obj = NULL;
docpriv = doc->_private;
Comment thread
clumens marked this conversation as resolved.
xpath = pcmk__element_xpath(node);

pcmk__trace("Deleting %s %p from %p", xpath->str, node, doc);
if (xpath != NULL) {
pcmk__deleted_xml_t *deleted_obj = NULL;

deleted_obj = pcmk__assert_alloc(1, sizeof(pcmk__deleted_xml_t));
deleted_obj->path = g_string_free(xpath, FALSE);
deleted_obj->position = -1;
pcmk__trace("Deleting %s %p from %p", xpath->str, node, doc);

// Record the position only for XML comments for now
if (node->type == XML_COMMENT_NODE) {
if (position >= 0) {
deleted_obj->position = position;
deleted_obj = pcmk__assert_alloc(1, sizeof(pcmk__deleted_xml_t));
deleted_obj->path = g_string_free(xpath, FALSE);
deleted_obj->position = -1;

} else {
deleted_obj->position = pcmk__xml_position(node,
pcmk__xf_skip);
}
}
// Record the position only for XML comments for now
if (node->type == XML_COMMENT_NODE) {
if (position >= 0) {
deleted_obj->position = position;

docpriv->deleted_objs = g_list_append(docpriv->deleted_objs,
deleted_obj);
pcmk__xml_doc_set_flags(node->doc, pcmk__xf_dirty);
} else {
deleted_obj->position = pcmk__xml_position(node, pcmk__xf_skip);
}
}

docpriv->deleted_objs = g_list_append(docpriv->deleted_objs,
deleted_obj);
pcmk__xml_doc_set_flags(node->doc, pcmk__xf_dirty);
}

pcmk__xml_free_node(node);
return pcmk_rc_ok;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/pacemaker/pcmk_injections.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2025 the Pacemaker project contributors
* Copyright 2009-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -634,6 +634,7 @@ inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
pcmk__assert(rc == pcmk_ok);

done:
free(resource);
free(task);
free(node);
free(key);
Expand Down
3 changes: 2 additions & 1 deletion lib/pacemaker/pcmk_sched_actions.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -1824,6 +1824,7 @@ process_rsc_history(const xmlNode *rsc_entry, pcmk_resource_t *rsc,

sorted_op_list = rsc_history_as_list(rsc_entry, &start_index, &stop_index);
if (start_index < stop_index) {
g_list_free(sorted_op_list);
return; // Resource is stopped
}

Expand Down
4 changes: 3 additions & 1 deletion lib/pacemaker/pcmk_sched_clone.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -566,6 +566,8 @@ probe_anonymous_clone(pcmk_resource_t *clone, pcmk_node_t *node)
pcmk_resource_t *instance = (pcmk_resource_t *) iter->data;
const pcmk_node_t *instance_node = NULL;

pcmk__assert(instance != NULL);
Comment thread
clumens marked this conversation as resolved.

instance_node = instance->priv->fns->location(instance, NULL,
pcmk__rsc_node_assigned);
if (pcmk__same_node(instance_node, node)) {
Expand Down
7 changes: 3 additions & 4 deletions lib/pacemaker/pcmk_sched_ordering.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -1271,10 +1271,9 @@ order_resource_actions_after(pcmk_action_t *first_action,

} else {
pcmk__clear_action_flags(then_action_iter, pcmk__action_runnable);
// coverity[null_field] order->rsc1 can't be NULL here
pcmk__warn("%s of %s is unrunnable because there is no %s of %s "
pcmk__warn("%s of %s is unrunnable because there is no %s "
"to order it after", then_action_iter->task, rsc->id,
order->task1, order->rsc1->id);
order->task1);
}
}

Expand Down
7 changes: 4 additions & 3 deletions lib/pacemaker/pcmk_sched_promotable.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -590,7 +590,7 @@ promotion_score_applies(const pcmk_resource_t *rsc, const pcmk_node_t *node)
char *id = clone_strip(rsc->id);
const pcmk_resource_t *parent = pe__const_top_resource(rsc, false);
pcmk_resource_t *active = NULL;
const char *reason = "allowed";
const char *reason = NULL;
Comment thread
clumens marked this conversation as resolved.

// Some checks apply only to anonymous clone instances
if (!pcmk__is_set(rsc->flags, pcmk__rsc_unique)) {
Expand Down Expand Up @@ -641,7 +641,8 @@ promotion_score_applies(const pcmk_resource_t *rsc, const pcmk_node_t *node)
check_allowed:
if (is_allowed(rsc, node)) {
pcmk__rsc_trace(rsc, "Counting %s promotion score (for %s) on %s: %s",
rsc->id, id, pcmk__node_name(node), reason);
rsc->id, id, pcmk__node_name(node),
pcmk__s(reason, "allowed"));
free(id);
return true;
}
Expand Down
Loading