From 129020e1c50c6ab42cef803f5ebd8501d02741f1 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 21 Jun 2024 15:07:41 +0200 Subject: [PATCH] Fix format errors in printf-like functions --- src/common.c | 4 ++-- src/common.h | 4 ++-- src/emu/bay.c | 4 ++-- src/emu/body.c | 6 +++--- src/emu/chan.c | 2 +- src/emu/chan.h | 4 ++-- src/emu/cpu.c | 4 ++-- src/emu/emu.c | 14 +++++++------- src/emu/emu_stat.c | 8 +++----- src/emu/loom.h | 4 ++-- src/emu/model_cpu.c | 5 +++-- src/emu/mux.c | 6 +++--- src/emu/nanos6/breakdown.c | 6 +++--- src/emu/nosv/setup.c | 2 +- src/emu/ovni/event.c | 6 +++--- src/emu/ovnievents.c | 2 +- src/emu/ovnisort.c | 20 ++++++++++---------- src/emu/player.c | 4 ++-- src/emu/sort.c | 8 ++++---- src/emu/stream.c | 8 ++++---- src/emu/system.c | 12 ++++++------ src/emu/thread.c | 15 +++++++-------- src/emu/track.c | 2 +- src/emu/track.h | 2 +- test/unit/mux.c | 9 +++------ test/unit/path.c | 4 ++-- test/unit/prv.c | 7 ++----- test/unit/sort_replace.c | 10 +++++----- 28 files changed, 87 insertions(+), 95 deletions(-) diff --git a/src/common.c b/src/common.c index d27a55c..5f11724 100644 --- a/src/common.c +++ b/src/common.c @@ -56,7 +56,7 @@ vaerr(const char *prefix, const char *func, const char *errstr, va_list ap) } } -void __attribute__((format(printf, 3, 4))) +void verr(const char *prefix, const char *func, const char *errstr, ...) { va_list ap; @@ -65,7 +65,7 @@ verr(const char *prefix, const char *func, const char *errstr, ...) va_end(ap); } -void __attribute__((format(printf, 3, 4))) +void vdie(const char *prefix, const char *func, const char *errstr, ...) { va_list ap; diff --git a/src/common.h b/src/common.h index d20d2ef..4bad0c8 100644 --- a/src/common.h +++ b/src/common.h @@ -19,8 +19,8 @@ int mkpath(const char *path, mode_t mode, int is_dir); void progname_set(char *name); const char *progname_get(void); void enable_debug(void); -void verr(const char *prefix, const char *func, const char *errstr, ...); -void vdie(const char *prefix, const char *func, const char *errstr, ...); +void verr(const char *prefix, const char *func, const char *errstr, ...) __attribute__((format(printf, 3, 4))); +void vdie(const char *prefix, const char *func, const char *errstr, ...) __attribute__((format(printf, 3, 4))); /* clang-format off */ diff --git a/src/emu/bay.c b/src/emu/bay.c index 45405f7..b8cdb61 100644 --- a/src/emu/bay.c +++ b/src/emu/bay.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "bay.h" @@ -168,7 +168,7 @@ propagate_chan(struct bay_chan *bchan, enum bay_cb_type type) struct bay_cb *cur = NULL; /* New callbacks cannot be added while propagating a bay_chan */ DL_FOREACH(bchan->cb[type], cur) { - dbg("calling cb %p", cur->func); + dbg("calling cb %"PRIxPTR, (uintptr_t) cur->func); if (cur->func(bchan->chan, cur->arg) != 0) { err("callback failed for %s", bchan->chan->name); return -1; diff --git a/src/emu/body.c b/src/emu/body.c index ae3681e..ce771aa 100644 --- a/src/emu/body.c +++ b/src/emu/body.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "body.h" @@ -135,7 +135,7 @@ body_execute(struct body_stack *stack, struct body *body) DL_PREPEND(stack->top, body); - dbg("%s state is now Running, iteration %lld", + dbg("%s state is now Running, iteration %ld", body->name, body->iteration); return 0; @@ -258,7 +258,7 @@ body_end(struct body_stack *stack, struct body *body) DL_DELETE(stack->top, body); body->stack = NULL; - dbg("%s state is now Dead, completed iteration %lld", + dbg("%s state is now Dead, completed iteration %ld", body->name, body->iteration); return 0; diff --git a/src/emu/chan.c b/src/emu/chan.c index c9de48a..4832bef 100644 --- a/src/emu/chan.c +++ b/src/emu/chan.c @@ -7,7 +7,7 @@ #include #include "common.h" -void __attribute__((format(printf, 3, 4))) +void chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) { memset(chan, 0, sizeof(struct chan)); diff --git a/src/emu/chan.h b/src/emu/chan.h index 908387f..11eb29b 100644 --- a/src/emu/chan.h +++ b/src/emu/chan.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #ifndef CHAN_H @@ -70,7 +70,7 @@ chan_read(struct chan *chan, struct value *value) return 0; } - void chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...); + void chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) __attribute__((format(printf, 3, 4))); USE_RET int chan_set(struct chan *chan, struct value value); USE_RET int chan_push(struct chan *chan, struct value value); USE_RET int chan_pop(struct chan *chan, struct value expected); diff --git a/src/emu/cpu.c b/src/emu/cpu.c index 666470e..ae75781 100644 --- a/src/emu/cpu.c +++ b/src/emu/cpu.c @@ -220,7 +220,7 @@ cpu_update(struct cpu *cpu) /* Only virtual cpus can be oversubscribed */ if (cpu->nth_running > 1 && !cpu->is_virtual) { - err("physical cpu %s has %d threads running at the same time", + err("physical cpu %s has %zd threads running at the same time", cpu->name, cpu->nth_running); return -1; } @@ -248,7 +248,7 @@ cpu_update(struct cpu *cpu) err("chan_set pid failed"); return -1; } - dbg("cpu%lld sets th_running to %s", + dbg("cpu%"PRIi64" sets th_running to %s", cpu->gindex, value_str(gid_running)); if (chan_set(&cpu->chan[CPU_CHAN_THRUN], gid_running) != 0) { err("chan_set gid_running failed"); diff --git a/src/emu/emu.c b/src/emu/emu.c index c4485b5..113cf4a 100644 --- a/src/emu/emu.c +++ b/src/emu/emu.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "emu.h" @@ -118,9 +118,9 @@ panic(struct emu *emu) if (emu->ev != NULL) { err("event: "); err(" mcv=%s", emu->ev->mcv); - err(" rclock=%lld", emu->ev->rclock); - err(" sclock=%lld", emu->ev->sclock); - err(" dclock=%lld", emu->ev->dclock); + err(" rclock=%"PRIi64, emu->ev->rclock); + err(" sclock=%"PRIi64, emu->ev->sclock); + err(" dclock=%"PRIi64, emu->ev->dclock); err(" payload_size=%zd", emu->ev->payload_size); err(" is_jumbo=%d", emu->ev->is_jumbo); } @@ -128,8 +128,8 @@ panic(struct emu *emu) if (emu->stream != NULL) { err("stream: "); err(" relpath=%s", emu->stream->relpath); - err(" offset=%lld", emu->stream->offset); - err(" clock_offset=%lld", emu->stream->clock_offset); + err(" offset=%"PRIi64, emu->stream->offset); + err(" clock_offset=%"PRIi64, emu->stream->clock_offset); } err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); } @@ -156,7 +156,7 @@ emu_step(struct emu *emu) return -1; } - dbg("----- mvc=%s dclock=%lld -----", emu->ev->mcv, emu->ev->dclock); + dbg("----- mcv=%s dclock=%"PRIi64" -----", emu->ev->mcv, emu->ev->dclock); emu_stat_update(&emu->stat, &emu->player); diff --git a/src/emu/emu_stat.c b/src/emu/emu_stat.c index 6726dbe..487b85b 100644 --- a/src/emu/emu_stat.c +++ b/src/emu/emu_stat.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "emu_stat.h" @@ -54,11 +54,9 @@ emu_stat_report(struct emu_stat *stat, struct player *player, int last) double speed = stat->average ? avgspeed : instspeed; if (last) { - int tmin = (int) (time_elapsed / 60.0); - int tsec = (int) ((time_elapsed / 60.0 - tmin) * 60.0); info("%5.1f%% done at avg %.0f kev/s \n", - progress * 100.0, avgspeed * 1e-3, tmin, tsec); - info("processed %lld input events in %.2f s\n", + progress * 100.0, avgspeed * 1e-3); + info("processed %"PRIi64" input events in %.2f s\n", nprocessed, time_elapsed); } else { int tmin = (int) (time_left / 60.0); diff --git a/src/emu/loom.h b/src/emu/loom.h index 4a382d9..d175cf1 100644 --- a/src/emu/loom.h +++ b/src/emu/loom.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #ifndef LOOM_H @@ -14,7 +14,7 @@ struct proc; struct loom { - size_t gindex; + int64_t gindex; int is_init; char name[PATH_MAX]; diff --git a/src/emu/model_cpu.c b/src/emu/model_cpu.c index 49b3a18..cf8bcfd 100644 --- a/src/emu/model_cpu.c +++ b/src/emu/model_cpu.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "model_cpu.h" @@ -40,7 +40,8 @@ init_chan(struct model_cpu *cpu, const struct model_chan_spec *spec, int64_t gin const char *ch_name = spec->ch_names[i]; int track_mode = spec->track[i]; - if (track_init(track, cpu->bay, TRACK_TYPE_TH, track_mode, "%s.cpu%lld.%s", + if (track_init(track, cpu->bay, TRACK_TYPE_TH, track_mode, + "%s.cpu%"PRIi64".%s", name, gindex, ch_name) != 0) { err("track_init failed"); return -1; diff --git a/src/emu/mux.c b/src/emu/mux.c index c2e9194..81f329e 100644 --- a/src/emu/mux.c +++ b/src/emu/mux.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "mux.h" @@ -25,7 +25,7 @@ default_select(struct mux *mux, int64_t index = key.i; if (index < 0 || index >= mux->ninputs) { - err("index out of bounds %lld", index); + err("index out of bounds %"PRIi64, index); return -1; } @@ -214,7 +214,7 @@ mux_set_input(struct mux *mux, int64_t index, struct chan *chan) struct mux_input *input = &mux->inputs[index]; if (input->chan != NULL) { - err("input %d already has a channel", index); + err("input %"PRIi64" already has a channel", index); return -1; } diff --git a/src/emu/nanos6/breakdown.c b/src/emu/nanos6/breakdown.c index b401744..2138f04 100644 --- a/src/emu/nanos6/breakdown.c +++ b/src/emu/nanos6/breakdown.c @@ -32,8 +32,8 @@ static int create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex) { enum chan_type t = CHAN_SINGLE; - chan_init(&bcpu->tr, t, "nanos6.cpu%lld.breakdown.tr", gindex); - chan_init(&bcpu->tri, t, "nanos6.cpu%lld.breakdown.tri", gindex); + chan_init(&bcpu->tr, t, "nanos6.cpu%"PRIi64".breakdown.tr", gindex); + chan_init(&bcpu->tri, t, "nanos6.cpu%"PRIi64".breakdown.tri", gindex); /* Register all channels in the bay */ if (bay_register(bay, &bcpu->tr) != 0) { @@ -131,7 +131,7 @@ select_tr(struct mux *mux, struct value value, struct mux_input **input) int64_t i = in_body; char *inputs[] = { "subsystem", "task_type" }; - dbg("selecting input %lld (%s)", i, inputs[i]); + dbg("selecting input %"PRIi64" (%s)", i, inputs[i]); *input = mux_get_input(mux, i); return 0; diff --git a/src/emu/nosv/setup.c b/src/emu/nosv/setup.c index eb24731..84bf0d5 100644 --- a/src/emu/nosv/setup.c +++ b/src/emu/nosv/setup.c @@ -396,7 +396,7 @@ finish_pvt(struct emu *emu, const char *name) return -1; } struct pcf *pcf = pvt_get_pcf(pvt); - long typeid = pvt_type[CH_TYPE]; + int typeid = pvt_type[CH_TYPE]; struct pcf_type *pcftype = pcf_find_type(pcf, typeid); if (pcftype == NULL) { err("cannot find %s pcf type %d", name, typeid); diff --git a/src/emu/ovni/event.c b/src/emu/ovni/event.c index 5d14c0d..2aa9916 100644 --- a/src/emu/ovni/event.c +++ b/src/emu/ovni/event.c @@ -229,7 +229,7 @@ pre_affinity_set(struct emu *emu) } if (emu->ev->payload_size != 4) { - err("unexpected payload size %d", emu->ev->payload_size); + err("unexpected payload size %zd", emu->ev->payload_size); return -1; } @@ -265,7 +265,7 @@ static int pre_affinity_remote(struct emu *emu) { if (emu->ev->payload_size != 8) { - err("unexpected payload size %d", emu->ev->payload_size); + err("unexpected payload size %zd", emu->ev->payload_size); return -1; } @@ -437,7 +437,7 @@ pre_flush(struct emu *emu) double flush_ms = (double) flush_ns * 1e-6; /* Avoid last flush warnings */ if (flush_ms > 10.0 && emu->thread->is_running) - warn("large flush of %.1f ms at dclock=%lld ns in tid=%d", + warn("large flush of %.1f ms at dclock=%"PRIi64" ns in tid=%d", flush_ms, emu->ev->dclock, emu->thread->tid); diff --git a/src/emu/ovnievents.c b/src/emu/ovnievents.c index 64ea902..08e080d 100644 --- a/src/emu/ovnievents.c +++ b/src/emu/ovnievents.c @@ -87,7 +87,7 @@ print_model(struct model_spec *spec) printf("
\n"); for (long j = 0; j < spec->evspec->nevents; j++) { if (print_event(spec, j) != 0) { - err("cannot print event %d", j); + err("cannot print event %ld", j); return -1; } } diff --git a/src/emu/ovnisort.c b/src/emu/ovnisort.c index 6288301..a82d004 100644 --- a/src/emu/ovnisort.c +++ b/src/emu/ovnisort.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ /* This program is a really bad idea. It attempts to sort streams by using a @@ -106,8 +106,8 @@ find_destination(struct ring *r, uint64_t clock) return r->head; } - err("cannot find a event previous to clock %lu", clock); - err("nback=%zd, last_clock=%lu", nback, last_clock); + err("cannot find a event previous to clock %"PRIu64, clock); + err("nback=%zd, last_clock=%"PRIu64, nback, last_clock); return -1; } @@ -183,7 +183,7 @@ write_events(struct ovni_ev **table, long n, uint8_t *buf) memcpy(buf, ev, size); buf += size; - dbg("injected event %c%c%c at %lld", + dbg("injected event %c%c%c at %"PRIu64, ev->header.model, ev->header.category, ev->header.value, @@ -216,7 +216,7 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize) { struct ovni_ev *ev = (struct ovni_ev *) src; - dbg("first event before sorting %c%c%c at %lld", + dbg("first event before sorting %c%c%c at %"PRIu64, ev->header.model, ev->header.category, ev->header.value, @@ -238,7 +238,7 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize) qsort(table, n, sizeof(struct ovni_ev *), cmp_ev); write_events(table, n, buf); - dbg("first event after sorting %c%c%c at %lld", + dbg("first event after sorting %c%c%c at %"PRIu64, ev->header.model, ev->header.category, ev->header.value, @@ -270,19 +270,19 @@ static int execute_sort_plan(struct sortplan *sp) { uint64_t clock0 = sp->bad0->header.clock; - dbg("attempt to sort: start clock %lld", sp->bad0->header.clock); + dbg("attempt to sort: start clock %"PRIi64, sp->bad0->header.clock); uint64_t min_clock = find_min_clock((void *) sp->bad0, (void *) sp->next); if (min_clock < clock0) { clock0 = min_clock; - dbg("region not sorted, using min clock=%lld", clock0); + dbg("region not sorted, using min clock=%"PRIi64, clock0); } /* Cannot sort in one pass; just fail for now */ int64_t i0 = find_destination(sp->r, clock0); if (i0 < 0) { - err("cannot find destination for region starting at clock %lld", clock0); + err("cannot find destination for region starting at clock %"PRIi64, clock0); err("consider increasing the look back size with -n"); return -1; } @@ -410,7 +410,7 @@ stream_check(struct stream *stream) uint64_t cur_clock = ovni_ev_get_clock(ev); if (cur_clock < last_clock) { - err("backwards jump in time %lld -> %lld for stream %s", + err("backwards jump in time %"PRIi64" -> %"PRIi64" for stream %s", last_clock, cur_clock, stream->relpath); backjump = 1; } diff --git a/src/emu/player.c b/src/emu/player.c index 6c51a2a..4d0aadc 100644 --- a/src/emu/player.c +++ b/src/emu/player.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "player.h" @@ -164,7 +164,7 @@ update_clocks(struct player *player, struct stream *stream) } if (sclock < player->lastclock) { - err("backwards jump in time %lld -> %lld in stream '%s'", + err("backwards jump in time %"PRIi64" -> %"PRIi64" in stream '%s'", player->lastclock, sclock, stream->relpath); if (player->unsorted == 0) return -1; diff --git a/src/emu/sort.c b/src/emu/sort.c index a2f38ba..3dc0e5a 100644 --- a/src/emu/sort.c +++ b/src/emu/sort.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "sort.h" @@ -165,7 +165,7 @@ sort_init(struct sort *sort, struct bay *bay, int64_t n, const char *name) /* Init and register outputs */ for (int64_t i = 0; i < n; i++) { struct chan *out = &sort->outputs[i]; - chan_init(out, CHAN_SINGLE, "%s.out%lld", name, i); + chan_init(out, CHAN_SINGLE, "%s.out%"PRIi64, name, i); /* The sort module may write multiple times to the same * channel if we update more than one input. */ @@ -176,7 +176,7 @@ sort_init(struct sort *sort, struct bay *bay, int64_t n, const char *name) chan_prop_set(out, CHAN_ALLOW_DUP, 1); if (bay_register(bay, out) != 0) { - err("bay_register out%lld failed", i); + err("bay_register out%"PRIi64" failed", i); return -1; } } @@ -190,7 +190,7 @@ sort_set_input(struct sort *sort, int64_t index, struct chan *chan) struct sort_input *input = &sort->inputs[index]; if (input->chan != NULL) { - err("input %d already has a channel", index); + err("input %"PRIi64" already has a channel", index); return -1; } diff --git a/src/emu/stream.c b/src/emu/stream.c index 49553e0..1e267dd 100644 --- a/src/emu/stream.c +++ b/src/emu/stream.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "stream.h" @@ -118,7 +118,7 @@ stream_load(struct stream *stream, const char *tracedir, const char *relpath) warn("stream '%s' has zero events", stream->relpath); stream->active = 0; } else { - err("impossible, offset %lld bigger than size %lld", + err("impossible, offset %"PRIi64" bigger than size %"PRIi64, stream->offset, stream->size); return -1; } @@ -196,7 +196,7 @@ stream_step(struct stream *stream) /* It cannot pass the size, otherwise we are reading garbage */ if (stream->offset > stream->size) { - err("stream offset %lld exceeds size %lld", + err("stream offset %"PRIi64" exceeds size %"PRIi64, stream->offset, stream->size); return -1; } @@ -223,7 +223,7 @@ stream_step(struct stream *stream) /* Ensure the clock grows monotonically if unsorted flag not set */ if (stream->unsorted == 0) { if (clock < stream->lastclock) { - err("clock goes backwards %lld -> %lld in stream '%s' at offset %lld", + err("clock goes backwards %"PRIi64" -> %"PRIi64" in stream '%s' at offset %"PRIi64, stream->lastclock, clock, stream->relpath, diff --git a/src/emu/system.c b/src/emu/system.c index 0fd64e3..e196f85 100644 --- a/src/emu/system.c +++ b/src/emu/system.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "system.h" @@ -340,10 +340,10 @@ print_system(struct system *sys) { err("content of system: "); for (struct loom *l = sys->looms; l; l = l->next) { - err("%s gindex=%d", l->id, l->gindex); + err("%s gindex=%"PRIi64, l->id, l->gindex); err("+ %zd processes: ", l->nprocs); for (struct proc *p = l->procs; p; p = p->hh.next) { - err("| %s gindex=%d pid=%d", + err("| %s gindex=%"PRIi64" pid=%d", p->id, p->gindex, p->pid); err("| + %d threads: ", p->nthreads); for (struct thread *t = p->threads; t; t = t->hh.next) { @@ -353,15 +353,15 @@ print_system(struct system *sys) } err("+ %zd phy cpus: ", l->ncpus); for (struct cpu *cpu = l->cpus; cpu; cpu = cpu->hh.next) { - err("| %s gindex=%lld phyid=%d", + err("| %s gindex=%"PRIi64" phyid=%d", cpu->name, cpu->gindex, cpu->phyid); } - err("+ 1 virtual cpu: ", l->ncpus); + err("+ 1 virtual cpu: "); struct cpu *cpu = &l->vcpu; - err("| %s gindex=%lld phyid=%d", + err("| %s gindex=%"PRIi64" phyid=%d", cpu->name, cpu->gindex, cpu->phyid); diff --git a/src/emu/thread.c b/src/emu/thread.c index 4725dad..2f3f714 100644 --- a/src/emu/thread.c +++ b/src/emu/thread.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "thread.h" @@ -18,7 +18,6 @@ #include "value.h" struct proc; -static const char chan_fmt[] = "thread%lu.%s"; static const char *chan_name[TH_CHAN_MAX] = { [TH_CHAN_CPU] = "cpu_gindex", [TH_CHAN_TID] = "tid_active", @@ -159,7 +158,7 @@ thread_init_end(struct thread *th) for (int i = 0; i < TH_CHAN_MAX; i++) { chan_init(&th->chan[i], CHAN_SINGLE, - chan_fmt, th->gindex, chan_name[i]); + "thread%"PRIi64".%s", th->gindex, chan_name[i]); } /* The transition Running -> Cooling causes a duplicate (the thread is @@ -327,7 +326,7 @@ thread_select_active(struct mux *mux, enum thread_state state = (enum thread_state) value.i; if (mux->ninputs != 1) { - err("mux doesn't have one input but %d", mux->ninputs); + err("mux doesn't have one input but %"PRIi64, mux->ninputs); return -1; } @@ -363,7 +362,7 @@ thread_select_running(struct mux *mux, enum thread_state state = (enum thread_state) value.i; if (mux->ninputs != 1) { - err("mux doesn't have one input but %d", mux->ninputs); + err("mux doesn't have one input but %"PRIi64, mux->ninputs); return -1; } @@ -392,7 +391,7 @@ thread_set_cpu(struct thread *th, struct cpu *cpu) return -1; } - dbg("thread%lld sets cpu%lld", th->gindex, cpu->gindex); + dbg("thread%"PRIi64" sets cpu%"PRIi64, th->gindex, cpu->gindex); th->cpu = cpu; /* Update cpu channel */ @@ -413,7 +412,7 @@ thread_unset_cpu(struct thread *th) return -1; } - dbg("thread%lld unsets cpu", th->gindex); + dbg("thread%"PRIi64" unsets cpu", th->gindex); th->cpu = NULL; struct chan *c = &th->chan[TH_CHAN_CPU]; @@ -433,7 +432,7 @@ thread_migrate_cpu(struct thread *th, struct cpu *cpu) return -1; } - dbg("thread%lld migrates to cpu%lld", th->gindex, cpu->gindex); + dbg("thread%"PRIi64" migrates to cpu%"PRIi64, th->gindex, cpu->gindex); th->cpu = cpu; struct chan *c = &th->chan[TH_CHAN_CPU]; diff --git a/src/emu/track.c b/src/emu/track.c index 0516be2..9bc6835 100644 --- a/src/emu/track.c +++ b/src/emu/track.c @@ -17,7 +17,7 @@ static const char **track_suffix[TRACK_TYPE_MAX] = { [TRACK_TYPE_TH] = th_suffix, }; -int __attribute__((format(printf, 5, 6))) +int track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...) { va_list ap; diff --git a/src/emu/track.h b/src/emu/track.h index d0b17d0..9ba7669 100644 --- a/src/emu/track.h +++ b/src/emu/track.h @@ -32,7 +32,7 @@ struct track { struct mux mux; }; -USE_RET int track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...); +USE_RET int track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...) __attribute__((format(printf, 5, 6))); USE_RET int track_set_select(struct track *track, struct chan *sel, mux_select_func_t fsel, int64_t ninputs); USE_RET int track_set_input(struct track *track, int64_t index, struct chan *inp); USE_RET struct chan *track_get_output(struct track *track); diff --git a/test/unit/mux.c b/test/unit/mux.c index e16a423..f99502e 100644 --- a/test/unit/mux.c +++ b/test/unit/mux.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "emu/mux.h" @@ -157,11 +157,8 @@ main(void) chan_init(&output, CHAN_SINGLE, "output"); chan_init(&select, CHAN_SINGLE, "select"); - for (int i = 0; i < N; i++) { - char buf[MAX_CHAN_NAME]; - sprintf(buf, "input.%d", i); - chan_init(&inputs[i], CHAN_SINGLE, buf); - } + for (int i = 0; i < N; i++) + chan_init(&inputs[i], CHAN_SINGLE, "input.%d", i); /* Register all channels in the bay */ OK(bay_register(&bay, &select)); diff --git a/test/unit/path.c b/test/unit/path.c index ce29a15..3cbfa4e 100644 --- a/test/unit/path.c +++ b/test/unit/path.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include "emu/path.h" @@ -16,7 +16,7 @@ test_underflow_trailing(void) if (memcmp(in, out, sizeof(in)) != 0) { for (size_t i = 0; i < sizeof(in); i++) { - err("i=%3d, in[i]=%02x out[i]=%02x", i, + err("i=%3zd, in[i]=%02x out[i]=%02x", i, (unsigned char) in[i], (unsigned char) out[i]); } diff --git a/test/unit/prv.c b/test/unit/prv.c index 68a7391..5c10faf 100644 --- a/test/unit/prv.c +++ b/test/unit/prv.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include @@ -28,10 +28,7 @@ test_emit(const char *path) OK(prv_open(&prv, NROWS, path)); for (int i = 0; i < NROWS; i++) { - char buf[MAX_CHAN_NAME]; - sprintf(buf, "testchan.%d", i); - chan_init(&chan[i], CHAN_SINGLE, buf); - + chan_init(&chan[i], CHAN_SINGLE, "testchan.%d", i); OK(bay_register(&bay, &chan[i])); } diff --git a/test/unit/sort_replace.c b/test/unit/sort_replace.c index 2ce4f5f..6872b33 100644 --- a/test/unit/sort_replace.c +++ b/test/unit/sort_replace.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) +/* Copyright (c) 2023-2024 Barcelona Supercomputing Center (BSC) * SPDX-License-Identifier: GPL-3.0-or-later */ #include @@ -56,12 +56,12 @@ test_case(int64_t n, int64_t run) while (old == new) new = randint(); - dbg("-- CASE run=%lld n=%lld iold=%lld old=%lld new=%lld\n", + dbg("-- CASE run=%"PRIi64" n=%"PRIi64" iold=%"PRIi64" old=%"PRIi64" new=%"PRIi64"\n", run, n, iold, old, new); dbg("Contents before sort: "); for (int64_t i = 0; i < n; i++) { - dbg("i=%lld, arr[i]=%lld, copy[i]=%lld\n", + dbg("i=%"PRIi64", arr[i]=%"PRIi64", copy[i]=%"PRIi64"\n", i, arr[i], copy[i]); } @@ -72,7 +72,7 @@ test_case(int64_t n, int64_t run) dbg("Contents after sort: "); for (int64_t i = 0; i < n; i++) { - dbg("i=%lld, arr[i]=%lld, copy[i]=%lld\n", + dbg("i=%"PRIi64", arr[i]=%"PRIi64", copy[i]=%"PRIi64"\n", i, arr[i], copy[i]); } @@ -94,7 +94,7 @@ test_sort_replace(void) for (int64_t n = nmin; n <= nmax; n += nstep) { for (int64_t run = 0; run < nrun; run++) test_case(n, run); - err("n = %lld OK", n); + err("n = %"PRIi64" OK", n); } }