375 lines
16 KiB
Diff
375 lines
16 KiB
Diff
|
From c120c1ebbcb68966e229d4c3647fdbb511150f94 Mon Sep 17 00:00:00 2001
|
||
|
From: Reid Wahl <nrwahl@protonmail.com>
|
||
|
Date: Wed, 8 Jan 2025 20:44:25 -0800
|
||
|
Subject: [PATCH 1/2] Low: various: Correct some printf specifiers
|
||
|
|
||
|
As of 18a93372, we can use the 'z' modifier for size_t and ssize_t. So
|
||
|
here we take advantage of that to avoid some (long long) casts.
|
||
|
|
||
|
We also correct some incorrect specifiers (signed vs. unsigned, and
|
||
|
using proper macros from inttypes.h).
|
||
|
|
||
|
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
|
||
|
---
|
||
|
daemons/controld/controld_fsa.c | 12 +++---
|
||
|
daemons/controld/controld_messages.c | 8 ++--
|
||
|
lib/cluster/cpg.c | 24 +++++------
|
||
|
lib/common/ipc_server.c | 25 ++++++-----
|
||
|
lib/common/remote.c | 62 ++++++++++++----------------
|
||
|
lib/services/services_linux.c | 17 ++++----
|
||
|
6 files changed, 67 insertions(+), 81 deletions(-)
|
||
|
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/daemons/controld/controld_fsa.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/daemons/controld/controld_fsa.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/daemons/controld/controld_fsa.c
|
||
|
@@ -1,5 +1,5 @@
|
||
|
/*
|
||
|
- * Copyright 2004-2024 the Pacemaker project contributors
|
||
|
+ * Copyright 2004-2025 the Pacemaker project contributors
|
||
|
*
|
||
|
* The version control history for this file may have further details.
|
||
|
*
|
||
|
@@ -9,6 +9,7 @@
|
||
|
|
||
|
#include <crm_internal.h>
|
||
|
|
||
|
+#include <inttypes.h> // PRIx64
|
||
|
#include <sys/param.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdint.h> // uint64_t
|
||
|
@@ -279,9 +280,10 @@ s_crmd_fsa(enum crmd_fsa_cause cause)
|
||
|
|| (controld_globals.fsa_actions != A_NOTHING)
|
||
|
|| pcmk_is_set(controld_globals.flags, controld_fsa_is_stalled)) {
|
||
|
|
||
|
- crm_debug("Exiting the FSA: queue=%d, fsa_actions=%#llx, stalled=%s",
|
||
|
+ crm_debug("Exiting the FSA: queue=%d, fsa_actions=%" PRIx64
|
||
|
+ ", stalled=%s",
|
||
|
g_list_length(controld_globals.fsa_message_queue),
|
||
|
- (unsigned long long) controld_globals.fsa_actions,
|
||
|
+ controld_globals.fsa_actions,
|
||
|
pcmk__flag_text(controld_globals.flags,
|
||
|
controld_fsa_is_stalled));
|
||
|
} else {
|
||
|
@@ -505,9 +507,9 @@ s_crmd_fsa_actions(fsa_data_t * fsa_data
|
||
|
|
||
|
/* Error checking and reporting */
|
||
|
} else {
|
||
|
- crm_err("Action %s not supported " QB_XS " %#llx",
|
||
|
+ crm_err("Action %s not supported " QB_XS " %" PRIx64,
|
||
|
fsa_action2string(controld_globals.fsa_actions),
|
||
|
- (unsigned long long) controld_globals.fsa_actions);
|
||
|
+ controld_globals.fsa_actions);
|
||
|
register_fsa_error_adv(C_FSA_INTERNAL, I_ERROR, fsa_data, NULL,
|
||
|
__func__);
|
||
|
}
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/daemons/controld/controld_messages.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/daemons/controld/controld_messages.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/daemons/controld/controld_messages.c
|
||
|
@@ -9,8 +9,10 @@
|
||
|
|
||
|
#include <crm_internal.h>
|
||
|
|
||
|
-#include <sys/param.h>
|
||
|
+#include <inttypes.h> // PRIx64
|
||
|
+#include <stdint.h> // uint64_t
|
||
|
#include <string.h>
|
||
|
+#include <sys/param.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
#include <crm/crm.h>
|
||
|
@@ -110,8 +112,7 @@ register_fsa_input_adv(enum crmd_fsa_cau
|
||
|
fsa_data->actions = with_actions;
|
||
|
|
||
|
if (with_actions != A_NOTHING) {
|
||
|
- crm_trace("Adding actions %.16llx to input",
|
||
|
- (unsigned long long) with_actions);
|
||
|
+ crm_trace("Adding actions %.16" PRIx64 " to input", with_actions);
|
||
|
}
|
||
|
|
||
|
if (data != NULL) {
|
||
|
@@ -1382,4 +1383,3 @@ broadcast_remote_state_message(const cha
|
||
|
pcmk__cluster_send_message(NULL, pcmk_ipc_controld, msg);
|
||
|
pcmk__xml_free(msg);
|
||
|
}
|
||
|
-
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/lib/cluster/cpg.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/lib/cluster/cpg.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/lib/cluster/cpg.c
|
||
|
@@ -1,5 +1,5 @@
|
||
|
/*
|
||
|
- * Copyright 2004-2024 the Pacemaker project contributors
|
||
|
+ * Copyright 2004-2025 the Pacemaker project contributors
|
||
|
*
|
||
|
* The version control history for this file may have further details.
|
||
|
*
|
||
|
@@ -237,8 +237,7 @@ crm_cs_flush(gpointer data)
|
||
|
}
|
||
|
|
||
|
sent++;
|
||
|
- crm_trace("CPG message sent, size=%llu",
|
||
|
- (unsigned long long) iov->iov_len);
|
||
|
+ crm_trace("CPG message sent, size=%zu", iov->iov_len);
|
||
|
|
||
|
cs_message_queue = g_list_remove(cs_message_queue, iov);
|
||
|
free(iov->iov_base);
|
||
|
@@ -360,10 +359,9 @@ check_message_sanity(const pcmk__cpg_msg
|
||
|
(((msg->size > 1) && (msg->data[msg->size - 2] == '\0'))
|
||
|
|| (msg->data[msg->size - 1] != '\0'))) {
|
||
|
crm_err("CPG message %d from %s invalid: "
|
||
|
- "Payload does not end at byte %llu "
|
||
|
+ "Payload does not end at byte %" PRIu32 " "
|
||
|
QB_XS " from %s[%u] to %s@%s",
|
||
|
- msg->id, ais_dest(&(msg->sender)),
|
||
|
- (unsigned long long) msg->size,
|
||
|
+ msg->id, ais_dest(&(msg->sender)), msg->size,
|
||
|
msg_type2text(msg->sender.type), msg->sender.pid,
|
||
|
msg_type2text(msg->host.type), ais_dest(&(msg->host)));
|
||
|
return false;
|
||
|
@@ -1009,15 +1007,13 @@ send_cpg_text(const char *data, const pc
|
||
|
iov->iov_len = msg->header.size;
|
||
|
|
||
|
if (msg->compressed_size > 0) {
|
||
|
- crm_trace("Queueing CPG message %u to %s "
|
||
|
- "(%llu bytes, %d bytes compressed payload): %.200s",
|
||
|
- msg->id, target, (unsigned long long) iov->iov_len,
|
||
|
- msg->compressed_size, data);
|
||
|
+ crm_trace("Queueing CPG message %" PRIu32 " to %s "
|
||
|
+ "(%zu bytes, %" PRIu32 " bytes compressed payload): %.200s",
|
||
|
+ msg->id, target, iov->iov_len, msg->compressed_size, data);
|
||
|
} else {
|
||
|
- crm_trace("Queueing CPG message %u to %s "
|
||
|
- "(%llu bytes, %d bytes payload): %.200s",
|
||
|
- msg->id, target, (unsigned long long) iov->iov_len,
|
||
|
- msg->size, data);
|
||
|
+ crm_trace("Queueing CPG message %" PRIu32 " to %s "
|
||
|
+ "(%zu bytes, %" PRIu32 " bytes payload): %.200s",
|
||
|
+ msg->id, target, iov->iov_len, msg->size, data);
|
||
|
}
|
||
|
|
||
|
free(target);
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/lib/common/ipc_server.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/lib/common/ipc_server.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/lib/common/ipc_server.c
|
||
|
@@ -1,5 +1,5 @@
|
||
|
/*
|
||
|
- * Copyright 2004-2024 the Pacemaker project contributors
|
||
|
+ * Copyright 2004-2025 the Pacemaker project contributors
|
||
|
*
|
||
|
* The version control history for this file may have further details.
|
||
|
*
|
||
|
@@ -540,9 +540,8 @@ crm_ipcs_flush_events(pcmk__client_t *c)
|
||
|
|
||
|
queue_len -= sent;
|
||
|
if (sent > 0 || queue_len) {
|
||
|
- crm_trace("Sent %d events (%d remaining) for %p[%d]: %s (%lld)",
|
||
|
- sent, queue_len, c->ipcs, c->pid,
|
||
|
- pcmk_rc_str(rc), (long long) qb_rc);
|
||
|
+ crm_trace("Sent %u events (%u remaining) for %p[%d]: %s (%zd)",
|
||
|
+ sent, queue_len, c->ipcs, c->pid, pcmk_rc_str(rc), qb_rc);
|
||
|
}
|
||
|
|
||
|
if (queue_len) {
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/lib/common/remote.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/lib/common/remote.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/lib/common/remote.c
|
||
|
@@ -137,29 +137,26 @@ send_tls(gnutls_session_t session, struc
|
||
|
return EINVAL;
|
||
|
}
|
||
|
|
||
|
- crm_trace("Sending TLS message of %llu bytes",
|
||
|
- (unsigned long long) unsent_len);
|
||
|
+ crm_trace("Sending TLS message of %zu bytes", unsent_len);
|
||
|
+
|
||
|
while (true) {
|
||
|
gnutls_rc = gnutls_record_send(session, unsent, unsent_len);
|
||
|
|
||
|
if (gnutls_rc == GNUTLS_E_INTERRUPTED || gnutls_rc == GNUTLS_E_AGAIN) {
|
||
|
- crm_trace("Retrying to send %llu bytes remaining",
|
||
|
- (unsigned long long) unsent_len);
|
||
|
+ crm_trace("Retrying to send %zu bytes remaining", unsent_len);
|
||
|
|
||
|
} else if (gnutls_rc < 0) {
|
||
|
// Caller can log as error if necessary
|
||
|
- crm_info("TLS connection terminated: %s " QB_XS " rc=%lld",
|
||
|
- gnutls_strerror((int) gnutls_rc),
|
||
|
- (long long) gnutls_rc);
|
||
|
+ crm_info("TLS connection terminated: %s " QB_XS " rc=%zd",
|
||
|
+ gnutls_strerror((int) gnutls_rc), gnutls_rc);
|
||
|
return ECONNABORTED;
|
||
|
|
||
|
} else if (gnutls_rc < unsent_len) {
|
||
|
- crm_trace("Sent %lld of %llu bytes remaining",
|
||
|
- (long long) gnutls_rc, (unsigned long long) unsent_len);
|
||
|
+ crm_trace("Sent %zd of %zu bytes remaining", gnutls_rc, unsent_len);
|
||
|
unsent_len -= gnutls_rc;
|
||
|
unsent += gnutls_rc;
|
||
|
} else {
|
||
|
- crm_trace("Sent all %lld bytes remaining", (long long) gnutls_rc);
|
||
|
+ crm_trace("Sent all %zd bytes remaining", gnutls_rc);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
@@ -178,16 +175,16 @@ send_plaintext(int sock, struct iovec *i
|
||
|
return EINVAL;
|
||
|
}
|
||
|
|
||
|
- crm_debug("Sending plaintext message of %llu bytes to socket %d",
|
||
|
- (unsigned long long) unsent_len, sock);
|
||
|
+ crm_debug("Sending plaintext message of %zu bytes to socket %d",
|
||
|
+ unsent_len, sock);
|
||
|
while (true) {
|
||
|
write_rc = write(sock, unsent, unsent_len);
|
||
|
if (write_rc < 0) {
|
||
|
int rc = errno;
|
||
|
|
||
|
if ((errno == EINTR) || (errno == EAGAIN)) {
|
||
|
- crm_trace("Retrying to send %llu bytes remaining to socket %d",
|
||
|
- (unsigned long long) unsent_len, sock);
|
||
|
+ crm_trace("Retrying to send %zu bytes remaining to socket %d",
|
||
|
+ unsent_len, sock);
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
@@ -197,15 +194,14 @@ send_plaintext(int sock, struct iovec *i
|
||
|
return rc;
|
||
|
|
||
|
} else if (write_rc < unsent_len) {
|
||
|
- crm_trace("Sent %lld of %llu bytes remaining",
|
||
|
- (long long) write_rc, (unsigned long long) unsent_len);
|
||
|
+ crm_trace("Sent %zd of %zu bytes remaining", write_rc, unsent_len);
|
||
|
unsent += write_rc;
|
||
|
unsent_len -= write_rc;
|
||
|
continue;
|
||
|
|
||
|
} else {
|
||
|
- crm_trace("Sent all %lld bytes remaining: %.100s",
|
||
|
- (long long) write_rc, (char *) (iov->iov_base));
|
||
|
+ crm_trace("Sent all %zd bytes remaining: %.100s",
|
||
|
+ write_rc, (char *) (iov->iov_base));
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
@@ -456,8 +452,7 @@ pcmk__read_available_remote_data(pcmk__r
|
||
|
/* automatically grow the buffer when needed */
|
||
|
if(remote->buffer_size < read_len) {
|
||
|
remote->buffer_size = 2 * read_len;
|
||
|
- crm_trace("Expanding buffer to %llu bytes",
|
||
|
- (unsigned long long) remote->buffer_size);
|
||
|
+ crm_trace("Expanding buffer to %zu bytes", remote->buffer_size);
|
||
|
remote->buffer = pcmk__realloc(remote->buffer, remote->buffer_size + 1);
|
||
|
}
|
||
|
|
||
|
@@ -470,8 +465,8 @@ pcmk__read_available_remote_data(pcmk__r
|
||
|
} else if (read_rc == GNUTLS_E_AGAIN) {
|
||
|
rc = EAGAIN;
|
||
|
} else if (read_rc < 0) {
|
||
|
- crm_debug("TLS receive failed: %s (%lld)",
|
||
|
- gnutls_strerror(read_rc), (long long) read_rc);
|
||
|
+ crm_debug("TLS receive failed: %s (%zd)",
|
||
|
+ gnutls_strerror((int) read_rc), read_rc);
|
||
|
rc = EIO;
|
||
|
}
|
||
|
} else if (remote->tcp_socket) {
|
||
|
@@ -491,35 +486,32 @@ pcmk__read_available_remote_data(pcmk__r
|
||
|
remote->buffer_offset += read_rc;
|
||
|
/* always null terminate buffer, the +1 to alloc always allows for this. */
|
||
|
remote->buffer[remote->buffer_offset] = '\0';
|
||
|
- crm_trace("Received %lld more bytes (%llu total)",
|
||
|
- (long long) read_rc,
|
||
|
- (unsigned long long) remote->buffer_offset);
|
||
|
+ crm_trace("Received %zd more bytes (%zu total)",
|
||
|
+ read_rc, remote->buffer_offset);
|
||
|
|
||
|
} else if ((rc == EINTR) || (rc == EAGAIN)) {
|
||
|
crm_trace("No data available for non-blocking remote read: %s (%d)",
|
||
|
pcmk_rc_str(rc), rc);
|
||
|
|
||
|
} else if (read_rc == 0) {
|
||
|
- crm_debug("End of remote data encountered after %llu bytes",
|
||
|
- (unsigned long long) remote->buffer_offset);
|
||
|
+ crm_debug("End of remote data encountered after %zu bytes",
|
||
|
+ remote->buffer_offset);
|
||
|
return ENOTCONN;
|
||
|
|
||
|
} else {
|
||
|
- crm_debug("Error receiving remote data after %llu bytes: %s (%d)",
|
||
|
- (unsigned long long) remote->buffer_offset,
|
||
|
- pcmk_rc_str(rc), rc);
|
||
|
+ crm_debug("Error receiving remote data after %zu bytes: %s (%d)",
|
||
|
+ remote->buffer_offset, pcmk_rc_str(rc), rc);
|
||
|
return ENOTCONN;
|
||
|
}
|
||
|
|
||
|
header = localized_remote_header(remote);
|
||
|
if(header) {
|
||
|
if(remote->buffer_offset < header->size_total) {
|
||
|
- crm_trace("Read partial remote message (%llu of %u bytes)",
|
||
|
- (unsigned long long) remote->buffer_offset,
|
||
|
- header->size_total);
|
||
|
+ crm_trace("Read partial remote message (%zu of %" PRIu32 " bytes)",
|
||
|
+ remote->buffer_offset, header->size_total);
|
||
|
} else {
|
||
|
- crm_trace("Read full remote message of %llu bytes",
|
||
|
- (unsigned long long) remote->buffer_offset);
|
||
|
+ crm_trace("Read full remote message of %zu bytes",
|
||
|
+ remote->buffer_offset);
|
||
|
return pcmk_rc_ok;
|
||
|
}
|
||
|
}
|
||
|
Index: pacemaker-3.0.0+20250128.fa492f5181/lib/services/services_linux.c
|
||
|
===================================================================
|
||
|
--- pacemaker-3.0.0+20250128.fa492f5181.orig/lib/services/services_linux.c
|
||
|
+++ pacemaker-3.0.0+20250128.fa492f5181/lib/services/services_linux.c
|
||
|
@@ -1,5 +1,5 @@
|
||
|
/*
|
||
|
- * Copyright 2010-2024 the Pacemaker project contributors
|
||
|
+ * Copyright 2010-2025 the Pacemaker project contributors
|
||
|
*
|
||
|
* The version control history for this file may have further details.
|
||
|
*
|
||
|
@@ -305,14 +305,12 @@ svc_read_output(int fd, svc_action_t * o
|
||
|
if (is_stderr && op->stderr_data) {
|
||
|
len = strlen(op->stderr_data);
|
||
|
data = op->stderr_data;
|
||
|
- crm_trace("Reading %s stderr into offset %lld",
|
||
|
- op->id, (long long) len);
|
||
|
+ crm_trace("Reading %s stderr into offset %zu", op->id, len);
|
||
|
|
||
|
} else if (is_stderr == FALSE && op->stdout_data) {
|
||
|
len = strlen(op->stdout_data);
|
||
|
data = op->stdout_data;
|
||
|
- crm_trace("Reading %s stdout into offset %lld",
|
||
|
- op->id, (long long) len);
|
||
|
+ crm_trace("Reading %s stdout into offset %zu", op->id, len);
|
||
|
|
||
|
} else {
|
||
|
crm_trace("Reading %s %s", op->id, out_type(is_stderr));
|
||
|
@@ -324,8 +322,8 @@ svc_read_output(int fd, svc_action_t * o
|
||
|
if (rc > 0) {
|
||
|
if (len < MAX_OUTPUT) {
|
||
|
buf[rc] = 0;
|
||
|
- crm_trace("Received %lld bytes of %s %s: %.80s",
|
||
|
- (long long) rc, op->id, out_type(is_stderr), buf);
|
||
|
+ crm_trace("Received %zd bytes of %s %s: %.80s",
|
||
|
+ rc, op->id, out_type(is_stderr), buf);
|
||
|
data = pcmk__realloc(data, len + rc + 1);
|
||
|
strcpy(data + len, buf);
|
||
|
len += rc;
|
||
|
@@ -340,9 +338,8 @@ svc_read_output(int fd, svc_action_t * o
|
||
|
} while ((rc == buf_read_len) || (rc < 0));
|
||
|
|
||
|
if (discarded > 0) {
|
||
|
- crm_warn("Truncated %s %s to %lld bytes (discarded %lld)",
|
||
|
- op->id, out_type(is_stderr), (long long) len,
|
||
|
- (long long) discarded);
|
||
|
+ crm_warn("Truncated %s %s to %zu bytes (discarded %zu)",
|
||
|
+ op->id, out_type(is_stderr), len, discarded);
|
||
|
}
|
||
|
|
||
|
if (is_stderr) {
|