From 1f748a84e00944a721b16fa5c402b5b2c29084ee Mon Sep 17 00:00:00 2001 From: Torsten Martinsen Date: Tue, 31 Mar 2026 20:44:58 +0200 Subject: [PATCH] Fix -Werror=calloc-transposed-args with gcc 14. --- fs_device.c | 4 ++-- gcode.c | 2 +- ioports.c | 2 +- stepper2.c | 2 +- stream_json.c | 2 +- vfs.c | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs_device.c b/fs_device.c index 2ae45b1..82322e2 100644 --- a/fs_device.c +++ b/fs_device.c @@ -43,7 +43,7 @@ bool device_fs_add_stream (io_stream_properties_t *stream) if(!stream->flags.claimable || !stream->flags.modbus_ready) return false; - fs_device_t *add = calloc(sizeof(fs_device_t), 1); + fs_device_t *add = calloc(1, sizeof(fs_device_t)); if(add) { switch(stream->type) { @@ -119,7 +119,7 @@ static vfs_file_t *fs_open (const char *filename, const char *mode) device->io_stream.state.passthru = On; // flag open - if((file = calloc(sizeof(vfs_file_t) + sizeof(io_stream_t *), 1))) { + if((file = calloc(1, sizeof(vfs_file_t) + sizeof(io_stream_t *)))) { io_stream = &device->io_stream; #ifdef __GNUC__ #pragma GCC diagnostic push diff --git a/gcode.c b/gcode.c index 39f4119..08ef861 100644 --- a/gcode.c +++ b/gcode.c @@ -663,7 +663,7 @@ FLASHMEM static status_code_t macro_add (macro_id_t id, vfs_file_t *file) { m98_macro_t *sub = macro_find(id); - if(sub == NULL && (sub = calloc(sizeof(m98_macro_t), 1))) { + if(sub == NULL && (sub = calloc(1, sizeof(m98_macro_t)))) { sub->id = id; sub->file = file; if(m98_macros) { diff --git a/ioports.c b/ioports.c index 234a1e9..138f35a 100644 --- a/ioports.c +++ b/ioports.c @@ -827,7 +827,7 @@ FLASHMEM static io_ports_list_t *insert_ports (void) { io_ports_list_t *io_ports; - if((io_ports = calloc(sizeof(io_ports_list_t), 1))) { + if((io_ports = calloc(1, sizeof(io_ports_list_t)))) { if(ports == NULL) ports = io_ports; diff --git a/stepper2.c b/stepper2.c index 0d6246b..4f6e327 100644 --- a/stepper2.c +++ b/stepper2.c @@ -258,7 +258,7 @@ st2_motor_t *st2_motor_init (uint_fast8_t axis_idx, bool is_spindle) { st2_motor_t *motor = NULL, *new = motors; - if(hal.stepper.output_step && (motor = calloc(sizeof(st2_motor_t), 1))) { + if(hal.stepper.output_step && (motor = calloc(1, sizeof(st2_motor_t)))) { if(hal.timer.claim && (motor->step_inject_timer = hal.timer.claim((timer_cap_t){ .periodic = Off }, 1000))) { timer_cfg_t step_inject_cfg = { diff --git a/stream_json.c b/stream_json.c index 10923fa..3949892 100644 --- a/stream_json.c +++ b/stream_json.c @@ -36,7 +36,7 @@ json_out_t *json_start (vfs_file_t *file, uint32_t max_levels) { json_out_t *handle = NULL; - if(file && (handle = calloc(sizeof(json_out_t) + sizeof(uint32_t) * max_levels, 1))) { + if(file && (handle = calloc(1, sizeof(json_out_t) + sizeof(uint32_t) * max_levels))) { handle->file = file; handle->max_level = max_levels; vfs_write("{", 1, 1, handle->file); diff --git a/vfs.c b/vfs.c index 259cfc2..8e37451 100644 --- a/vfs.c +++ b/vfs.c @@ -108,7 +108,7 @@ static vfs_dir_t *fs_opendir (const char *path) static vfs_dir_t *dir = NULL; if(dir == NULL) - dir = calloc(sizeof(vfs_dir_t) + 3, 1); + dir = calloc(1, sizeof(vfs_dir_t) + 3); if(dir) { vfs_mount_t **mount = (vfs_mount_t **)&dir->handle; @@ -587,7 +587,7 @@ bool vfs_mount (const char *path, const vfs_t *fs, vfs_st_mode_t mode) if(!strcmp(path, "/")) { root.vfs = fs; root.mode = mode; - } else if((mount = (vfs_mount_t *)calloc(sizeof(vfs_mount_t), 1))) { + } else if((mount = (vfs_mount_t *)calloc(1, sizeof(vfs_mount_t)))) { struct tm tm;