Skip to content

Commit d57c00d

Browse files
committed
Refactor: various: Use correct pcmk__assert_alloc() arg order
This should make absolutely no difference but uses the correct semantics. Signed-off-by: Reid Wahl <[email protected]>
1 parent 406369c commit d57c00d

File tree

11 files changed

+16
-15
lines changed

11 files changed

+16
-15
lines changed

daemons/fenced/fenced_commands.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ build_port_aliases(const char *hostmap, GList ** targets)
925925
case ':':
926926
if (i > last) {
927927
free(name);
928-
name = pcmk__assert_alloc(1, 1 + i - last);
928+
name = pcmk__assert_alloc(1 + i - last, sizeof(char));
929929
memcpy(name, hostmap + last, i - last);
930930
}
931931
last = i + 1;
@@ -939,7 +939,8 @@ build_port_aliases(const char *hostmap, GList ** targets)
939939
case '\t':
940940
if (name) {
941941
int k = 0;
942-
char *value = pcmk__assert_alloc(1, 1 + i - last);
942+
char *value = pcmk__assert_alloc(1 + i - last,
943+
sizeof(char));
943944

944945
memcpy(value, hostmap + last, i - last);
945946

lib/cluster/cpg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pcmk__cpg_message_data(cpg_handle_t handle, uint32_t sender_id, uint32_t pid,
466466
if (msg->is_compressed && (msg->size > 0)) {
467467
int rc = BZ_OK;
468468
unsigned int new_size = msg->size + 1;
469-
char *uncompressed = pcmk__assert_alloc(1, new_size);
469+
char *uncompressed = pcmk__assert_alloc(new_size, sizeof(char));
470470

471471
rc = BZ2_bzBuffToBuffDecompress(uncompressed, &new_size, msg->data,
472472
msg->compressed_size, 1, 0);

lib/common/actions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ decode_transition_magic(const char *magic, char **uuid, int *transition_id, int
403403
res = sscanf(magic, "%d:%d;%ms", &local_op_status, &local_op_rc, &key);
404404
#else
405405
// magic must have >=4 other characters
406-
key = pcmk__assert_alloc(1, strlen(magic) - 3);
406+
key = pcmk__assert_alloc(strlen(magic) - 3, sizeof(char));
407407
res = sscanf(magic, "%d:%d;%s", &local_op_status, &local_op_rc, key);
408408
#endif
409409
if (res == EOF) {

lib/common/fuzzers/iso8601_fuzzer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 the Pacemaker project contributors
2+
* Copyright 2024-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -27,7 +27,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2727
if (size < 10) {
2828
return -1; // Do not add input to testing corpus
2929
}
30-
ns = pcmk__assert_alloc(1, size + 1);
30+
ns = pcmk__assert_alloc(size + 1, sizeof(char));
3131
memcpy(ns, data, size);
3232

3333
period = crm_time_parse_period(ns);

lib/common/fuzzers/scores_fuzzer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 the Pacemaker project contributors
2+
* Copyright 2024-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -21,7 +21,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2121
guint result = 0U;
2222

2323
if (size > 0) {
24-
ns = pcmk__assert_alloc(1, size + 1);
24+
ns = pcmk__assert_alloc(size + 1, sizeof(char));
2525
memcpy(ns, data, size);
2626
ns[size] = '\0';
2727
}

lib/common/fuzzers/strings_fuzzer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2828
if (size < 10) {
2929
return -1; // Do not add input to testing corpus
3030
}
31-
ns = pcmk__assert_alloc(1, size + 1);
31+
ns = pcmk__assert_alloc(size + 1, sizeof(char));
3232
memcpy(ns, data, size);
3333
ns[size] = '\0';
3434

lib/common/output_text.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pcmk__text_prompt(const char *prompt, bool echo, char **dest)
481481
#if HAVE_SSCANF_M
482482
rc = scanf("%ms", dest);
483483
#else
484-
*dest = pcmk__assert_alloc(1, 1024);
484+
*dest = pcmk__assert_alloc(1024, sizeof(char));
485485
rc = scanf("%1023s", *dest);
486486
#endif
487487
fprintf(stderr, "\n");

lib/common/procfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ pcmk__throttle_cib_load(const char *server, float *load)
398398
}
399399

400400
if (fgets(buffer, sizeof(buffer), stream) != NULL) {
401-
char *comm = pcmk__assert_alloc(1, 256);
401+
char *comm = pcmk__assert_alloc(256, sizeof(char));
402402
char state = 0;
403403
int rc = 0, pid = 0, ppid = 0, pgrp = 0, session = 0, tty_nr = 0, tpgid = 0;
404404
unsigned long flags = 0, minflt = 0, cminflt = 0, majflt = 0, cmajflt = 0, utime = 0, stime = 0;

lib/common/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pcmk__remote_message_xml(pcmk__remote_t *remote)
293293
int rc = 0;
294294
unsigned int size_u = 1 + header->payload_uncompressed;
295295
char *uncompressed =
296-
pcmk__assert_alloc(1, header->payload_offset + size_u);
296+
pcmk__assert_alloc(header->payload_offset + size_u, sizeof(char));
297297

298298
crm_trace("Decompressing message data %d bytes into %d bytes",
299299
header->payload_compressed, size_u);

lib/pacemaker/pcmk_injections.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
581581

582582
out->message(out, "inject-spec", spec);
583583

584-
key = pcmk__assert_alloc(1, strlen(spec) + 1);
585-
node = pcmk__assert_alloc(1, strlen(spec) + 1);
584+
key = pcmk__assert_alloc(strlen(spec) + 1, sizeof(char));
585+
node = pcmk__assert_alloc(strlen(spec) + 1, sizeof(char));
586586
rc = sscanf(spec, "%[^@]@%[^=]=%d", key, node, &outcome);
587587
if (rc != 3) {
588588
out->err(out, "Invalid operation spec: %s. Only found %d fields",

0 commit comments

Comments
 (0)