Fix format errors in printf-like functions

This commit is contained in:
Rodrigo Arias 2024-06-21 15:07:41 +02:00
parent d03fe10be8
commit 129020e1c5
28 changed files with 87 additions and 95 deletions

View File

@ -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, ...) verr(const char *prefix, const char *func, const char *errstr, ...)
{ {
va_list ap; va_list ap;
@ -65,7 +65,7 @@ verr(const char *prefix, const char *func, const char *errstr, ...)
va_end(ap); va_end(ap);
} }
void __attribute__((format(printf, 3, 4))) void
vdie(const char *prefix, const char *func, const char *errstr, ...) vdie(const char *prefix, const char *func, const char *errstr, ...)
{ {
va_list ap; va_list ap;

View File

@ -19,8 +19,8 @@ int mkpath(const char *path, mode_t mode, int is_dir);
void progname_set(char *name); void progname_set(char *name);
const char *progname_get(void); const char *progname_get(void);
void enable_debug(void); void enable_debug(void);
void verr(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, ...); void vdie(const char *prefix, const char *func, const char *errstr, ...) __attribute__((format(printf, 3, 4)));
/* clang-format off */ /* clang-format off */

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "bay.h" #include "bay.h"
@ -168,7 +168,7 @@ propagate_chan(struct bay_chan *bchan, enum bay_cb_type type)
struct bay_cb *cur = NULL; struct bay_cb *cur = NULL;
/* New callbacks cannot be added while propagating a bay_chan */ /* New callbacks cannot be added while propagating a bay_chan */
DL_FOREACH(bchan->cb[type], cur) { 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) { if (cur->func(bchan->chan, cur->arg) != 0) {
err("callback failed for %s", bchan->chan->name); err("callback failed for %s", bchan->chan->name);
return -1; return -1;

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "body.h" #include "body.h"
@ -135,7 +135,7 @@ body_execute(struct body_stack *stack, struct body *body)
DL_PREPEND(stack->top, 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); body->name, body->iteration);
return 0; return 0;
@ -258,7 +258,7 @@ body_end(struct body_stack *stack, struct body *body)
DL_DELETE(stack->top, body); DL_DELETE(stack->top, body);
body->stack = NULL; 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); body->name, body->iteration);
return 0; return 0;

View File

@ -7,7 +7,7 @@
#include <string.h> #include <string.h>
#include "common.h" #include "common.h"
void __attribute__((format(printf, 3, 4))) void
chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...)
{ {
memset(chan, 0, sizeof(struct chan)); memset(chan, 0, sizeof(struct chan));

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef CHAN_H #ifndef CHAN_H
@ -70,7 +70,7 @@ chan_read(struct chan *chan, struct value *value)
return 0; 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_set(struct chan *chan, struct value value);
USE_RET int chan_push(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); USE_RET int chan_pop(struct chan *chan, struct value expected);

View File

@ -220,7 +220,7 @@ cpu_update(struct cpu *cpu)
/* Only virtual cpus can be oversubscribed */ /* Only virtual cpus can be oversubscribed */
if (cpu->nth_running > 1 && !cpu->is_virtual) { 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); cpu->name, cpu->nth_running);
return -1; return -1;
} }
@ -248,7 +248,7 @@ cpu_update(struct cpu *cpu)
err("chan_set pid failed"); err("chan_set pid failed");
return -1; return -1;
} }
dbg("cpu%lld sets th_running to %s", dbg("cpu%"PRIi64" sets th_running to %s",
cpu->gindex, value_str(gid_running)); cpu->gindex, value_str(gid_running));
if (chan_set(&cpu->chan[CPU_CHAN_THRUN], gid_running) != 0) { if (chan_set(&cpu->chan[CPU_CHAN_THRUN], gid_running) != 0) {
err("chan_set gid_running failed"); err("chan_set gid_running failed");

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "emu.h" #include "emu.h"
@ -118,9 +118,9 @@ panic(struct emu *emu)
if (emu->ev != NULL) { if (emu->ev != NULL) {
err("event: "); err("event: ");
err(" mcv=%s", emu->ev->mcv); err(" mcv=%s", emu->ev->mcv);
err(" rclock=%lld", emu->ev->rclock); err(" rclock=%"PRIi64, emu->ev->rclock);
err(" sclock=%lld", emu->ev->sclock); err(" sclock=%"PRIi64, emu->ev->sclock);
err(" dclock=%lld", emu->ev->dclock); err(" dclock=%"PRIi64, emu->ev->dclock);
err(" payload_size=%zd", emu->ev->payload_size); err(" payload_size=%zd", emu->ev->payload_size);
err(" is_jumbo=%d", emu->ev->is_jumbo); err(" is_jumbo=%d", emu->ev->is_jumbo);
} }
@ -128,8 +128,8 @@ panic(struct emu *emu)
if (emu->stream != NULL) { if (emu->stream != NULL) {
err("stream: "); err("stream: ");
err(" relpath=%s", emu->stream->relpath); err(" relpath=%s", emu->stream->relpath);
err(" offset=%lld", emu->stream->offset); err(" offset=%"PRIi64, emu->stream->offset);
err(" clock_offset=%lld", emu->stream->clock_offset); err(" clock_offset=%"PRIi64, emu->stream->clock_offset);
} }
err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); err("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
} }
@ -156,7 +156,7 @@ emu_step(struct emu *emu)
return -1; 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); emu_stat_update(&emu->stat, &emu->player);

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "emu_stat.h" #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; double speed = stat->average ? avgspeed : instspeed;
if (last) { 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", info("%5.1f%% done at avg %.0f kev/s \n",
progress * 100.0, avgspeed * 1e-3, tmin, tsec); progress * 100.0, avgspeed * 1e-3);
info("processed %lld input events in %.2f s\n", info("processed %"PRIi64" input events in %.2f s\n",
nprocessed, time_elapsed); nprocessed, time_elapsed);
} else { } else {
int tmin = (int) (time_left / 60.0); int tmin = (int) (time_left / 60.0);

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef LOOM_H #ifndef LOOM_H
@ -14,7 +14,7 @@
struct proc; struct proc;
struct loom { struct loom {
size_t gindex; int64_t gindex;
int is_init; int is_init;
char name[PATH_MAX]; char name[PATH_MAX];

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "model_cpu.h" #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]; const char *ch_name = spec->ch_names[i];
int track_mode = spec->track[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) { name, gindex, ch_name) != 0) {
err("track_init failed"); err("track_init failed");
return -1; return -1;

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "mux.h" #include "mux.h"
@ -25,7 +25,7 @@ default_select(struct mux *mux,
int64_t index = key.i; int64_t index = key.i;
if (index < 0 || index >= mux->ninputs) { if (index < 0 || index >= mux->ninputs) {
err("index out of bounds %lld", index); err("index out of bounds %"PRIi64, index);
return -1; 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]; struct mux_input *input = &mux->inputs[index];
if (input->chan != NULL) { if (input->chan != NULL) {
err("input %d already has a channel", index); err("input %"PRIi64" already has a channel", index);
return -1; return -1;
} }

View File

@ -32,8 +32,8 @@ static int
create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex) create_cpu(struct bay *bay, struct breakdown_cpu *bcpu, int64_t gindex)
{ {
enum chan_type t = CHAN_SINGLE; enum chan_type t = CHAN_SINGLE;
chan_init(&bcpu->tr, t, "nanos6.cpu%lld.breakdown.tr", gindex); chan_init(&bcpu->tr, t, "nanos6.cpu%"PRIi64".breakdown.tr", gindex);
chan_init(&bcpu->tri, t, "nanos6.cpu%lld.breakdown.tri", gindex); chan_init(&bcpu->tri, t, "nanos6.cpu%"PRIi64".breakdown.tri", gindex);
/* Register all channels in the bay */ /* Register all channels in the bay */
if (bay_register(bay, &bcpu->tr) != 0) { 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; int64_t i = in_body;
char *inputs[] = { "subsystem", "task_type" }; 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); *input = mux_get_input(mux, i);
return 0; return 0;

View File

@ -396,7 +396,7 @@ finish_pvt(struct emu *emu, const char *name)
return -1; return -1;
} }
struct pcf *pcf = pvt_get_pcf(pvt); 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); struct pcf_type *pcftype = pcf_find_type(pcf, typeid);
if (pcftype == NULL) { if (pcftype == NULL) {
err("cannot find %s pcf type %d", name, typeid); err("cannot find %s pcf type %d", name, typeid);

View File

@ -229,7 +229,7 @@ pre_affinity_set(struct emu *emu)
} }
if (emu->ev->payload_size != 4) { 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; return -1;
} }
@ -265,7 +265,7 @@ static int
pre_affinity_remote(struct emu *emu) pre_affinity_remote(struct emu *emu)
{ {
if (emu->ev->payload_size != 8) { 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; return -1;
} }
@ -437,7 +437,7 @@ pre_flush(struct emu *emu)
double flush_ms = (double) flush_ns * 1e-6; double flush_ms = (double) flush_ns * 1e-6;
/* Avoid last flush warnings */ /* Avoid last flush warnings */
if (flush_ms > 10.0 && emu->thread->is_running) 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, flush_ms,
emu->ev->dclock, emu->ev->dclock,
emu->thread->tid); emu->thread->tid);

View File

@ -87,7 +87,7 @@ print_model(struct model_spec *spec)
printf("<dl>\n"); printf("<dl>\n");
for (long j = 0; j < spec->evspec->nevents; j++) { for (long j = 0; j < spec->evspec->nevents; j++) {
if (print_event(spec, j) != 0) { if (print_event(spec, j) != 0) {
err("cannot print event %d", j); err("cannot print event %ld", j);
return -1; return -1;
} }
} }

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
/* This program is a really bad idea. It attempts to sort streams by using a /* 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; return r->head;
} }
err("cannot find a event previous to clock %lu", clock); err("cannot find a event previous to clock %"PRIu64, clock);
err("nback=%zd, last_clock=%lu", nback, last_clock); err("nback=%zd, last_clock=%"PRIu64, nback, last_clock);
return -1; return -1;
} }
@ -183,7 +183,7 @@ write_events(struct ovni_ev **table, long n, uint8_t *buf)
memcpy(buf, ev, size); memcpy(buf, ev, size);
buf += size; buf += size;
dbg("injected event %c%c%c at %lld", dbg("injected event %c%c%c at %"PRIu64,
ev->header.model, ev->header.model,
ev->header.category, ev->header.category,
ev->header.value, 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; 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.model,
ev->header.category, ev->header.category,
ev->header.value, 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); qsort(table, n, sizeof(struct ovni_ev *), cmp_ev);
write_events(table, n, buf); 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.model,
ev->header.category, ev->header.category,
ev->header.value, ev->header.value,
@ -270,19 +270,19 @@ static int
execute_sort_plan(struct sortplan *sp) execute_sort_plan(struct sortplan *sp)
{ {
uint64_t clock0 = sp->bad0->header.clock; 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); uint64_t min_clock = find_min_clock((void *) sp->bad0, (void *) sp->next);
if (min_clock < clock0) { if (min_clock < clock0) {
clock0 = min_clock; 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 */ /* Cannot sort in one pass; just fail for now */
int64_t i0 = find_destination(sp->r, clock0); int64_t i0 = find_destination(sp->r, clock0);
if (i0 < 0) { 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"); err("consider increasing the look back size with -n");
return -1; return -1;
} }
@ -410,7 +410,7 @@ stream_check(struct stream *stream)
uint64_t cur_clock = ovni_ev_get_clock(ev); uint64_t cur_clock = ovni_ev_get_clock(ev);
if (cur_clock < last_clock) { 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); last_clock, cur_clock, stream->relpath);
backjump = 1; backjump = 1;
} }

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "player.h" #include "player.h"
@ -164,7 +164,7 @@ update_clocks(struct player *player, struct stream *stream)
} }
if (sclock < player->lastclock) { 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); player->lastclock, sclock, stream->relpath);
if (player->unsorted == 0) if (player->unsorted == 0)
return -1; return -1;

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "sort.h" #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 */ /* Init and register outputs */
for (int64_t i = 0; i < n; i++) { for (int64_t i = 0; i < n; i++) {
struct chan *out = &sort->outputs[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 /* The sort module may write multiple times to the same
* channel if we update more than one input. */ * 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); chan_prop_set(out, CHAN_ALLOW_DUP, 1);
if (bay_register(bay, out) != 0) { if (bay_register(bay, out) != 0) {
err("bay_register out%lld failed", i); err("bay_register out%"PRIi64" failed", i);
return -1; 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]; struct sort_input *input = &sort->inputs[index];
if (input->chan != NULL) { if (input->chan != NULL) {
err("input %d already has a channel", index); err("input %"PRIi64" already has a channel", index);
return -1; return -1;
} }

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "stream.h" #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); warn("stream '%s' has zero events", stream->relpath);
stream->active = 0; stream->active = 0;
} else { } else {
err("impossible, offset %lld bigger than size %lld", err("impossible, offset %"PRIi64" bigger than size %"PRIi64,
stream->offset, stream->size); stream->offset, stream->size);
return -1; return -1;
} }
@ -196,7 +196,7 @@ stream_step(struct stream *stream)
/* It cannot pass the size, otherwise we are reading garbage */ /* It cannot pass the size, otherwise we are reading garbage */
if (stream->offset > stream->size) { if (stream->offset > stream->size) {
err("stream offset %lld exceeds size %lld", err("stream offset %"PRIi64" exceeds size %"PRIi64,
stream->offset, stream->size); stream->offset, stream->size);
return -1; return -1;
} }
@ -223,7 +223,7 @@ stream_step(struct stream *stream)
/* Ensure the clock grows monotonically if unsorted flag not set */ /* Ensure the clock grows monotonically if unsorted flag not set */
if (stream->unsorted == 0) { if (stream->unsorted == 0) {
if (clock < stream->lastclock) { 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, stream->lastclock,
clock, clock,
stream->relpath, stream->relpath,

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "system.h" #include "system.h"
@ -340,10 +340,10 @@ print_system(struct system *sys)
{ {
err("content of system: "); err("content of system: ");
for (struct loom *l = sys->looms; l; l = l->next) { 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); err("+ %zd processes: ", l->nprocs);
for (struct proc *p = l->procs; p; p = p->hh.next) { 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); p->id, p->gindex, p->pid);
err("| + %d threads: ", p->nthreads); err("| + %d threads: ", p->nthreads);
for (struct thread *t = p->threads; t; t = t->hh.next) { 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); err("+ %zd phy cpus: ", l->ncpus);
for (struct cpu *cpu = l->cpus; cpu; cpu = cpu->hh.next) { 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->name,
cpu->gindex, cpu->gindex,
cpu->phyid); cpu->phyid);
} }
err("+ 1 virtual cpu: ", l->ncpus); err("+ 1 virtual cpu: ");
struct cpu *cpu = &l->vcpu; struct cpu *cpu = &l->vcpu;
err("| %s gindex=%lld phyid=%d", err("| %s gindex=%"PRIi64" phyid=%d",
cpu->name, cpu->name,
cpu->gindex, cpu->gindex,
cpu->phyid); cpu->phyid);

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "thread.h" #include "thread.h"
@ -18,7 +18,6 @@
#include "value.h" #include "value.h"
struct proc; struct proc;
static const char chan_fmt[] = "thread%lu.%s";
static const char *chan_name[TH_CHAN_MAX] = { static const char *chan_name[TH_CHAN_MAX] = {
[TH_CHAN_CPU] = "cpu_gindex", [TH_CHAN_CPU] = "cpu_gindex",
[TH_CHAN_TID] = "tid_active", [TH_CHAN_TID] = "tid_active",
@ -159,7 +158,7 @@ thread_init_end(struct thread *th)
for (int i = 0; i < TH_CHAN_MAX; i++) { for (int i = 0; i < TH_CHAN_MAX; i++) {
chan_init(&th->chan[i], CHAN_SINGLE, 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 /* 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; enum thread_state state = (enum thread_state) value.i;
if (mux->ninputs != 1) { 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; return -1;
} }
@ -363,7 +362,7 @@ thread_select_running(struct mux *mux,
enum thread_state state = (enum thread_state) value.i; enum thread_state state = (enum thread_state) value.i;
if (mux->ninputs != 1) { 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; return -1;
} }
@ -392,7 +391,7 @@ thread_set_cpu(struct thread *th, struct cpu *cpu)
return -1; 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; th->cpu = cpu;
/* Update cpu channel */ /* Update cpu channel */
@ -413,7 +412,7 @@ thread_unset_cpu(struct thread *th)
return -1; return -1;
} }
dbg("thread%lld unsets cpu", th->gindex); dbg("thread%"PRIi64" unsets cpu", th->gindex);
th->cpu = NULL; th->cpu = NULL;
struct chan *c = &th->chan[TH_CHAN_CPU]; struct chan *c = &th->chan[TH_CHAN_CPU];
@ -433,7 +432,7 @@ thread_migrate_cpu(struct thread *th, struct cpu *cpu)
return -1; 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; th->cpu = cpu;
struct chan *c = &th->chan[TH_CHAN_CPU]; struct chan *c = &th->chan[TH_CHAN_CPU];

View File

@ -17,7 +17,7 @@ static const char **track_suffix[TRACK_TYPE_MAX] = {
[TRACK_TYPE_TH] = th_suffix, [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, ...) track_init(struct track *track, struct bay *bay, enum track_type type, int mode, const char *fmt, ...)
{ {
va_list ap; va_list ap;

View File

@ -32,7 +32,7 @@ struct track {
struct mux mux; 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_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 int track_set_input(struct track *track, int64_t index, struct chan *inp);
USE_RET struct chan *track_get_output(struct track *track); USE_RET struct chan *track_get_output(struct track *track);

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "emu/mux.h" #include "emu/mux.h"
@ -157,11 +157,8 @@ main(void)
chan_init(&output, CHAN_SINGLE, "output"); chan_init(&output, CHAN_SINGLE, "output");
chan_init(&select, CHAN_SINGLE, "select"); chan_init(&select, CHAN_SINGLE, "select");
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++)
char buf[MAX_CHAN_NAME]; chan_init(&inputs[i], CHAN_SINGLE, "input.%d", i);
sprintf(buf, "input.%d", i);
chan_init(&inputs[i], CHAN_SINGLE, buf);
}
/* Register all channels in the bay */ /* Register all channels in the bay */
OK(bay_register(&bay, &select)); OK(bay_register(&bay, &select));

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "emu/path.h" #include "emu/path.h"
@ -16,7 +16,7 @@ test_underflow_trailing(void)
if (memcmp(in, out, sizeof(in)) != 0) { if (memcmp(in, out, sizeof(in)) != 0) {
for (size_t i = 0; i < sizeof(in); i++) { 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) in[i],
(unsigned char) out[i]); (unsigned char) out[i]);
} }

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdint.h> #include <stdint.h>
@ -28,10 +28,7 @@ test_emit(const char *path)
OK(prv_open(&prv, NROWS, path)); OK(prv_open(&prv, NROWS, path));
for (int i = 0; i < NROWS; i++) { for (int i = 0; i < NROWS; i++) {
char buf[MAX_CHAN_NAME]; chan_init(&chan[i], CHAN_SINGLE, "testchan.%d", i);
sprintf(buf, "testchan.%d", i);
chan_init(&chan[i], CHAN_SINGLE, buf);
OK(bay_register(&bay, &chan[i])); OK(bay_register(&bay, &chan[i]));
} }

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdint.h> #include <stdint.h>
@ -56,12 +56,12 @@ test_case(int64_t n, int64_t run)
while (old == new) while (old == new)
new = randint(); 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); run, n, iold, old, new);
dbg("Contents before sort: "); dbg("Contents before sort: ");
for (int64_t i = 0; i < n; i++) { 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]); i, arr[i], copy[i]);
} }
@ -72,7 +72,7 @@ test_case(int64_t n, int64_t run)
dbg("Contents after sort: "); dbg("Contents after sort: ");
for (int64_t i = 0; i < n; i++) { 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]); 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 n = nmin; n <= nmax; n += nstep) {
for (int64_t run = 0; run < nrun; run++) for (int64_t run = 0; run < nrun; run++)
test_case(n, run); test_case(n, run);
err("n = %lld OK", n); err("n = %"PRIi64" OK", n);
} }
} }