From c8750b9dfdca869c95fc300b84e8d80842ebbff6 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Wed, 24 Jul 2024 17:02:57 +0200 Subject: [PATCH] Enable -Wconversion and -Wsign-conversion Prevents implicit conversions to go undetected, as they will have to be explicit now. --- CHANGELOG.md | 4 +++ CMakeLists.txt | 2 +- src/common.c | 4 +-- src/emu/bay.c | 2 +- src/emu/chan.c | 4 +-- src/emu/clkoff.c | 2 +- src/emu/cpu.c | 14 ++++----- src/emu/emu_ev.c | 6 ++-- src/emu/ev_spec.c | 8 +++--- src/emu/model_cpu.c | 4 +-- src/emu/model_evspec.c | 2 +- src/emu/model_pvt.c | 8 +++--- src/emu/model_thread.c | 6 ++-- src/emu/mux.c | 2 +- src/emu/nanos6/breakdown.c | 10 +++---- src/emu/nanos6/event.c | 6 ++-- src/emu/nanos6/setup.c | 2 +- src/emu/nosv/breakdown.c | 10 +++---- src/emu/nosv/event.c | 6 ++-- src/emu/ovni/event.c | 10 +++---- src/emu/ovni/mark.c | 16 +++++------ src/emu/ovnievents.c | 4 +-- src/emu/ovnisort.c | 24 ++++++++-------- src/emu/ovnisync.c | 20 ++++++------- src/emu/path.c | 4 +-- src/emu/pv/prf.c | 4 +-- src/emu/pv/prv.c | 4 +-- src/emu/sort.c | 12 ++++---- src/emu/stream.c | 4 +-- src/emu/system.c | 18 ++++++------ src/emu/task.c | 4 +-- src/emu/thread.c | 6 ++-- src/emu/trace.c | 10 +++---- src/emu/track.c | 4 +-- src/include/heap.h | 8 +++--- src/parson.c | 32 ++++++++++----------- src/rt/ovni.c | 31 ++++++++++---------- test/emu/common/instr.c | 4 +-- test/emu/common/instr.h | 22 +++++++------- test/emu/nanos6/blocking.c | 12 ++++---- test/emu/nanos6/if0-pause-parent.c | 4 +-- test/emu/nanos6/instr_nanos6.h | 6 ++-- test/emu/nanos6/nested-tasks-bad.c | 8 +++--- test/emu/nanos6/nested-tasks.c | 4 +-- test/emu/nanos6/rerun-task-bad.c | 12 ++++---- test/emu/nanos6/switch-same-type.c | 4 +-- test/emu/nanos6/task-types.c | 4 +-- test/emu/nosv/bad-double-execute-parallel.c | 4 +-- test/emu/nosv/bad-double-execute.c | 2 +- test/emu/nosv/bad-nest-from-parallel.c | 4 +-- test/emu/nosv/bad-nest-same-task.c | 2 +- test/emu/nosv/bad-pause-parallel.c | 4 +-- test/emu/nosv/instr_nosv.h | 4 +-- test/emu/nosv/mp-rank.c | 6 ++-- test/emu/nosv/multiple-segment.c | 2 +- test/emu/nosv/nest-to-parallel.c | 2 +- test/emu/nosv/nested-tasks.c | 12 ++++---- test/emu/nosv/parallel-tasks.c | 2 +- test/emu/nosv/pause.c | 2 +- test/emu/nosv/switch-same-type.c | 2 +- test/emu/nosv/task-pause-from-submit.c | 2 +- test/emu/nosv/task-types.c | 8 +++--- test/emu/ovni/clockgate.c | 6 ++-- test/emu/ovni/empty-sort.c | 8 +++--- test/emu/ovni/flush-overhead.c | 2 +- test/emu/ovni/flush-tmpdir.c | 4 +-- test/emu/ovni/flush.c | 4 +-- test/emu/ovni/libovni-mark.c | 2 +- test/emu/ovni/sort-first-and-full-ring.c | 10 +++---- test/emu/ovni/sort-flush.c | 30 +++++++++---------- test/emu/ovni/sort.c | 14 ++++----- test/rt/nanos6/sched-add.c | 6 ++-- test/rt/nodes/heat-mark.c | 6 ++-- test/rt/openmp/taskloop.c | 4 +++ test/unit/sort_replace.c | 14 ++++----- 75 files changed, 288 insertions(+), 277 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3943410..807e9e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Enable -Wconversion and -Wsign-conversion. + ## [1.10.0] - 2024-07-26 ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index e5b447e..b9a0f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") add_compile_options(-Wall -Wextra -Wformat -Wmissing-prototypes -Wstrict-prototypes - #-Wconversion -Wsign-conversion + -Wconversion -Wsign-conversion -Wold-style-definition -pedantic -Werror ) diff --git a/src/common.c b/src/common.c index 5f11724..a0b53df 100644 --- a/src/common.c +++ b/src/common.c @@ -45,7 +45,7 @@ vaerr(const char *prefix, const char *func, const char *errstr, va_list ap) vfprintf(stderr, errstr, ap); - int len = strlen(errstr); + int len = (int) strlen(errstr); if (len > 0) { char last = errstr[len - 1]; @@ -103,7 +103,7 @@ mkpath(const char *path, mode_t mode, int is_dir) char *copypath = strdup(path); /* Remove trailing slash */ - int last = strlen(path) - 1; + int last = (int) strlen(path) - 1; while (last > 0 && copypath[last] == '/') copypath[last--] = '\0'; diff --git a/src/emu/bay.c b/src/emu/bay.c index b8cdb61..8dee760 100644 --- a/src/emu/bay.c +++ b/src/emu/bay.c @@ -106,7 +106,7 @@ bay_add_cb(struct bay *bay, enum bay_cb_type type, cb->func = func; cb->arg = arg; cb->bchan = bchan; - cb->type = type; + cb->type = (int) type; cb->enabled = 0; if (enabled) diff --git a/src/emu/chan.c b/src/emu/chan.c index 4832bef..40cfba9 100644 --- a/src/emu/chan.c +++ b/src/emu/chan.c @@ -15,8 +15,8 @@ chan_init(struct chan *chan, enum chan_type type, const char *fmt, ...) va_list ap; va_start(ap, fmt); - int n = ARRAYLEN(chan->name); - int ret = vsnprintf(chan->name, n, fmt, ap); + int n = (int) ARRAYLEN(chan->name); + int ret = vsnprintf(chan->name, (size_t) n, fmt, ap); if (ret >= n) die("channel name too long"); va_end(ap); diff --git a/src/emu/clkoff.c b/src/emu/clkoff.c index 324caee..1fbb8b8 100644 --- a/src/emu/clkoff.c +++ b/src/emu/clkoff.c @@ -95,7 +95,7 @@ cindex(struct clkoff *table) return -1; } - table->index = calloc(table->nentries, sizeof(struct clkoff_entry *)); + table->index = calloc((size_t) table->nentries, sizeof(struct clkoff_entry *)); if (table->index == NULL) { err("calloc failed"); diff --git a/src/emu/cpu.c b/src/emu/cpu.c index ae75781..02c6d8e 100644 --- a/src/emu/cpu.c +++ b/src/emu/cpu.c @@ -78,8 +78,8 @@ cpu_set_loom(struct cpu *cpu, struct loom *loom) static int set_name(struct cpu *cpu) { - size_t i = loom_get_gindex(cpu->loom); - size_t j = cpu_get_phyid(cpu); + size_t i = (size_t) loom_get_gindex(cpu->loom); + size_t j = (size_t) cpu_get_phyid(cpu); int n; if (cpu->is_virtual) @@ -162,7 +162,7 @@ cpu_connect(struct cpu *cpu, struct bay *bay, struct recorder *rec) if (type < 0) continue; - long row = cpu->gindex; + long row = (long) cpu->gindex; long flags = prv_flags[i]; if (prv_register(prv, row, type, bay, c, flags)) { err("prv_register failed"); @@ -176,7 +176,7 @@ cpu_connect(struct cpu *cpu, struct bay *bay, struct recorder *rec) struct pcf_value * cpu_add_to_pcf_type(struct cpu *cpu, struct pcf_type *type) { - return pcf_add_value(type, cpu->gindex + 1, cpu->name); + return pcf_add_value(type, (int) cpu->gindex + 1, cpu->name); } static struct thread * @@ -215,8 +215,8 @@ cpu_update(struct cpu *cpu) } } - cpu->nth_running = running; - cpu->nth_active = active; + cpu->nth_running = (size_t) running; + cpu->nth_active = (size_t) active; /* Only virtual cpus can be oversubscribed */ if (cpu->nth_running > 1 && !cpu->is_virtual) { @@ -265,7 +265,7 @@ cpu_update(struct cpu *cpu) } /* Update nth_running number in the channel */ - if (chan_set(&cpu->chan[CPU_CHAN_NRUN], value_int64(running)) != 0) { + if (chan_set(&cpu->chan[CPU_CHAN_NRUN], value_int64((int64_t) running)) != 0) { err("chan_set nth_running failed"); return -1; } diff --git a/src/emu/emu_ev.c b/src/emu/emu_ev.c index 1702144..631f21d 100644 --- a/src/emu/emu_ev.c +++ b/src/emu/emu_ev.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_ev.h" @@ -13,11 +13,11 @@ emu_ev(struct emu_ev *ev, const struct ovni_ev *oev, ev->v = oev->header.value; ev->mcv[3] = '\0'; - ev->rclock = oev->header.clock; + ev->rclock = (int64_t) oev->header.clock; ev->sclock = sclock; ev->dclock = dclock; - ev->payload_size = ovni_payload_size(oev); + ev->payload_size = (size_t) ovni_payload_size(oev); if (ev->payload_size > 0) { ev->has_payload = 1; diff --git a/src/emu/ev_spec.c b/src/emu/ev_spec.c index b7d83de..adf49c2 100644 --- a/src/emu/ev_spec.c +++ b/src/emu/ev_spec.c @@ -104,7 +104,7 @@ parse_arg(struct ev_spec *spec, char *arg) } /* Copy name */ - size_t n = snprintf(argspec->name, sizeof(argspec->name), "%s", name); + size_t n = (size_t) snprintf(argspec->name, sizeof(argspec->name), "%s", name); if (n >= sizeof(argspec->name)) { err("argument name too long: %s", name); return -1; @@ -364,7 +364,7 @@ print_arg(struct ev_arg *arg, const char *fmt, struct cursor *c, struct emu_ev * #define CASE(TYPE) \ do { \ TYPE *data = (TYPE *) &payload[arg->offset]; \ - n = snprintf(c->out, c->len, fmt, *data); \ + n = snprintf(c->out, (size_t) c->len, fmt, *data); \ if (n >= c->len) { \ err("no space for argument"); \ return -1; \ @@ -386,8 +386,8 @@ print_arg(struct ev_arg *arg, const char *fmt, struct cursor *c, struct emu_ev * char *data = (char *) &payload[arg->offset]; /* Here we trust the input string to * contain a nil at the end */ - int n = snprintf(c->out, c->len, fmt, data); - if (n >= c->len) { + int n = snprintf(c->out, (size_t) c->len, fmt, data); + if (n >= (int) c->len) { err("no space for string argument"); return -1; } diff --git a/src/emu/model_cpu.c b/src/emu/model_cpu.c index cf8bcfd..77deea2 100644 --- a/src/emu/model_cpu.c +++ b/src/emu/model_cpu.c @@ -27,7 +27,7 @@ get_model_cpu(struct cpu *cpu, int id) static int init_chan(struct model_cpu *cpu, const struct model_chan_spec *spec, int64_t gindex) { - cpu->track = calloc(spec->nch, sizeof(struct track)); + cpu->track = calloc((size_t) spec->nch, sizeof(struct track)); if (cpu->track == NULL) { err("calloc failed:"); return -1; @@ -108,7 +108,7 @@ connect_cpu(struct emu *emu, struct cpu *scpu, int id) struct chan *sel = cpu_get_th_chan(scpu); - int64_t nthreads = emu->system.nthreads; + int64_t nthreads = (int64_t) emu->system.nthreads; if (track_set_select(track, sel, NULL, nthreads) != 0) { err("track_select failed"); return -1; diff --git a/src/emu/model_evspec.c b/src/emu/model_evspec.c index 23fd12a..85e27a5 100644 --- a/src/emu/model_evspec.c +++ b/src/emu/model_evspec.c @@ -21,7 +21,7 @@ model_evspec_init(struct model_evspec *evspec, struct model_spec *spec) } /* Preallocate a contiguous map, as we know the size */ - evspec->alloc = calloc(evspec->nevents, sizeof(struct ev_spec)); + evspec->alloc = calloc((size_t) evspec->nevents, sizeof(struct ev_spec)); if (evspec->alloc == NULL) { err("calloc failed:"); return -1; diff --git a/src/emu/model_pvt.c b/src/emu/model_pvt.c index 860f2d5..fd6f838 100644 --- a/src/emu/model_pvt.c +++ b/src/emu/model_pvt.c @@ -35,7 +35,7 @@ create_values(const struct model_pvt_spec *pvt, return 0; for (const struct pcf_value_label *p = q; p->label != NULL; p++) { - if (pcf_add_value(t, p->value, p->label) == NULL) { + if (pcf_add_value(t, (int) p->value, p->label) == NULL) { err("pcf_add_value failed"); return -1; } @@ -66,7 +66,7 @@ create_type(const struct model_pvt_spec *pvt, return -1; } - struct pcf_type *pcftype = pcf_add_type(pcf, type, label); + struct pcf_type *pcftype = pcf_add_type(pcf, (int) type, label); if (pcftype == NULL) { err("pcf_add_type failed"); return -1; @@ -106,7 +106,7 @@ connect_cpu_prv(struct emu *emu, struct cpu *scpu, struct prv *prv, int id) for (int i = 0; i < spec->nch; i++) { struct chan *out = track_get_output(&cpu->track[i]); long type = spec->pvt->type[i]; - long row = scpu->gindex; + long row = (long) scpu->gindex; long flags = flags_arr ? flags_arr[i] : 0; if (prv_register(prv, row, type, &emu->bay, out, flags)) { err("prv_register failed"); @@ -158,7 +158,7 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv, int id) for (int i = 0; i < spec->nch; i++) { struct chan *out = track_get_output(&th->track[i]); long type = spec->pvt->type[i]; - long row = sth->gindex; + long row = (long) sth->gindex; long flags = flags_arr ? flags_arr[i] : 0; if (prv_register(prv, row, type, &emu->bay, out, flags)) { err("prv_register failed"); diff --git a/src/emu/model_thread.c b/src/emu/model_thread.c index 7266ae3..68133b9 100644 --- a/src/emu/model_thread.c +++ b/src/emu/model_thread.c @@ -22,7 +22,7 @@ init_chan(struct model_thread *th, const struct model_chan_spec *spec, int64_t g const char *fmt = "%s.thread%"PRIi64".%s"; const char *prefix = spec->prefix; - th->ch = calloc(spec->nch, sizeof(struct chan)); + th->ch = calloc((size_t) spec->nch, sizeof(struct chan)); if (th->ch == NULL) { err("calloc failed:"); return -1; @@ -30,7 +30,7 @@ init_chan(struct model_thread *th, const struct model_chan_spec *spec, int64_t g for (int i = 0; i < spec->nch; i++) { struct chan *c = &th->ch[i]; - int type = spec->ch_stack[i]; + enum chan_type type = spec->ch_stack[i] ? CHAN_STACK : CHAN_SINGLE; const char *ch_name = spec->ch_names[i]; chan_init(c, type, fmt, prefix, gindex, ch_name); @@ -45,7 +45,7 @@ init_chan(struct model_thread *th, const struct model_chan_spec *spec, int64_t g } } - th->track = calloc(spec->nch, sizeof(struct track)); + th->track = calloc((size_t) spec->nch, sizeof(struct track)); if (th->track == NULL) { err("calloc failed:"); return -1; diff --git a/src/emu/mux.c b/src/emu/mux.c index 81f329e..bf557d6 100644 --- a/src/emu/mux.c +++ b/src/emu/mux.c @@ -177,7 +177,7 @@ mux_init(struct mux *mux, mux->select = select; mux->output = output; mux->ninputs = ninputs; - mux->inputs = calloc(ninputs, sizeof(struct mux_input)); + mux->inputs = calloc((size_t) ninputs, sizeof(struct mux_input)); mux->def = value_null(); if (mux->inputs == NULL) { diff --git a/src/emu/nanos6/breakdown.c b/src/emu/nanos6/breakdown.c index 2138f04..2723abb 100644 --- a/src/emu/nanos6/breakdown.c +++ b/src/emu/nanos6/breakdown.c @@ -59,12 +59,12 @@ model_nanos6_breakdown_create(struct emu *emu) /* Count phy cpus */ struct system *sys = &emu->system; - int64_t nphycpus = sys->ncpus - sys->nlooms; + int64_t nphycpus = (int64_t) (sys->ncpus - sys->nlooms); bemu->nphycpus = nphycpus; /* Create a new Paraver trace */ struct recorder *rec = &emu->recorder; - bemu->pvt = recorder_add_pvt(rec, "nanos6-breakdown", nphycpus); + bemu->pvt = recorder_add_pvt(rec, "nanos6-breakdown", (long) nphycpus); if (bemu->pvt == NULL) { err("recorder_add_pvt failed"); return -1; @@ -245,7 +245,7 @@ model_nanos6_breakdown_connect(struct emu *emu) flags |= PRV_ZERO; struct chan *out = sort_get_output(&bemu->sort, i); - if (prv_register(prv, i, type, bay, out, flags)) { + if (prv_register(prv, (long) i, type, bay, out, flags)) { err("prv_register failed"); return -1; } @@ -268,7 +268,7 @@ model_nanos6_breakdown_finish(struct emu *emu, struct pcf *pcf = pvt_get_pcf(bemu->pvt); long typeid = PRV_NANOS6_BREAKDOWN; char label[] = "CPU: Nanos6 Runtime/Idle/Task breakdown"; - struct pcf_type *pcftype = pcf_add_type(pcf, typeid, label); + struct pcf_type *pcftype = pcf_add_type(pcf, (int) typeid, label); const struct pcf_value_label *v = NULL; /* Emit subsystem values */ @@ -307,7 +307,7 @@ model_nanos6_breakdown_finish(struct emu *emu, return -1; } - if (prf_add(prf, row, name) != 0) { + if (prf_add(prf, (long) row, name) != 0) { err("prf_add failed for %s", name); return -1; } diff --git a/src/emu/nanos6/event.c b/src/emu/nanos6/event.c index ae1aaf2..4bfed64 100644 --- a/src/emu/nanos6/event.c +++ b/src/emu/nanos6/event.c @@ -299,7 +299,7 @@ update_task_state(struct emu *emu) static int expand_transition_value(struct emu *emu, int was_running, int runs_now, char *tr_p) { - char tr = emu->ev->v; + char tr = (char) emu->ev->v; /* Ensure we don't clobber the value */ if (tr == 'X' || tr == 'E') { @@ -419,7 +419,7 @@ update_task(struct emu *emu) struct task *next = bnext == NULL ? NULL : body_get_task(bnext); /* Update the subsystem channel */ - if (update_task_ss_channel(emu, emu->ev->v) != 0) { + if (update_task_ss_channel(emu, (char) emu->ev->v) != 0) { err("update_task_ss_channel failed"); return -1; } @@ -467,7 +467,7 @@ create_task(struct emu *emu) * task, so we relax the model to allow this for now. */ flags |= TASK_FLAG_RELAX_NESTING; - if (task_create(info, type_id, task_id, flags) != 0) { + if (task_create(info, type_id, task_id, (uint32_t) flags) != 0) { err("task_create failed"); return -1; } diff --git a/src/emu/nanos6/setup.c b/src/emu/nanos6/setup.c index 69d4558..bd906df 100644 --- a/src/emu/nanos6/setup.c +++ b/src/emu/nanos6/setup.c @@ -402,7 +402,7 @@ finish_pvt(struct emu *emu, const char *name) } struct pcf *pcf = pvt_get_pcf(pvt); long typeid = pvt_type[CH_TYPE]; - struct pcf_type *pcftype = pcf_find_type(pcf, typeid); + struct pcf_type *pcftype = pcf_find_type(pcf, (int) typeid); for (struct proc *p = sys->procs; p; p = p->gnext) { struct nanos6_proc *proc = EXT(p, model_id); diff --git a/src/emu/nosv/breakdown.c b/src/emu/nosv/breakdown.c index 735552a..40a3e7c 100644 --- a/src/emu/nosv/breakdown.c +++ b/src/emu/nosv/breakdown.c @@ -82,12 +82,12 @@ model_nosv_breakdown_create(struct emu *emu) /* Count phy cpus */ struct system *sys = &emu->system; - int64_t nphycpus = sys->ncpus - sys->nlooms; + int64_t nphycpus = (int64_t) (sys->ncpus - sys->nlooms); bemu->nphycpus = nphycpus; /* Create a new Paraver trace */ struct recorder *rec = &emu->recorder; - bemu->pvt = recorder_add_pvt(rec, "nosv-breakdown", nphycpus); + bemu->pvt = recorder_add_pvt(rec, "nosv-breakdown", (long) nphycpus); if (bemu->pvt == NULL) { err("recorder_add_pvt failed"); return -1; @@ -270,7 +270,7 @@ model_nosv_breakdown_connect(struct emu *emu) long flags = PRV_SKIPDUP | PRV_ZERO; struct chan *out = sort_get_output(&bemu->sort, i); - if (prv_register(prv, i, type, bay, out, flags)) { + if (prv_register(prv, (long) i, type, bay, out, flags)) { err("prv_register failed"); return -1; } @@ -293,7 +293,7 @@ model_nosv_breakdown_finish(struct emu *emu, struct pcf *pcf = pvt_get_pcf(bemu->pvt); long typeid = PRV_NOSV_BREAKDOWN; char label[] = "CPU: nOS-V Runtime/Idle/Task breakdown"; - struct pcf_type *pcftype = pcf_add_type(pcf, typeid, label); + struct pcf_type *pcftype = pcf_add_type(pcf, (int) typeid, label); const struct pcf_value_label *v = NULL; /* Emit subsystem values */ @@ -332,7 +332,7 @@ model_nosv_breakdown_finish(struct emu *emu, return -1; } - if (prf_add(prf, row, name) != 0) { + if (prf_add(prf, (long) row, name) != 0) { err("prf_add failed for %s", name); return -1; } diff --git a/src/emu/nosv/event.c b/src/emu/nosv/event.c index 52b7d8a..217a510 100644 --- a/src/emu/nosv/event.c +++ b/src/emu/nosv/event.c @@ -324,7 +324,7 @@ update_task_state(struct emu *emu) static int expand_transition_value(struct emu *emu, int was_running, int runs_now, char *tr_p) { - char tr = emu->ev->v; + char tr = (char) emu->ev->v; /* Ensure we don't clobber the value */ if (tr == 'X' || tr == 'E') { @@ -441,7 +441,7 @@ update_task(struct emu *emu) struct body *next = task_get_running(stack); /* Update the subsystem channel */ - if (update_task_ss_channel(emu, emu->ev->v) != 0) { + if (update_task_ss_channel(emu, (char) emu->ev->v) != 0) { err("update_task_ss_channel failed"); return -1; } @@ -509,7 +509,7 @@ pre_task(struct emu *emu) switch (emu->ev->v) { case 'C': case 'c': - ret = create_task(emu, emu->ev->v); + ret = create_task(emu, (char) emu->ev->v); break; case 'x': case 'e': diff --git a/src/emu/ovni/event.c b/src/emu/ovni/event.c index 2aa9916..b56f1e3 100644 --- a/src/emu/ovni/event.c +++ b/src/emu/ovni/event.c @@ -390,18 +390,18 @@ pre_burst(struct emu *emu) for (int i = 0; i < n; i++) deltas[i] = th->burst_time[i + 1] - th->burst_time[i]; - qsort(deltas, n, sizeof(int64_t), compare_int64); + qsort(deltas, (size_t) n, sizeof(int64_t), compare_int64); double avg = 0.0; double maxdelta = 0; for (int i = 0; i < n; i++) { - if (deltas[i] > maxdelta) - maxdelta = deltas[i]; - avg += deltas[i]; + if ((double) deltas[i] > maxdelta) + maxdelta = (double) deltas[i]; + avg += (double) deltas[i]; } avg /= (double) n; - double median = deltas[n / 2]; + double median = (double) deltas[n / 2]; info("%s burst stats: median/avg/max = %3.0f/%3.0f/%3.0f ns", emu->loom->id, median, avg, maxdelta); diff --git a/src/emu/ovni/mark.c b/src/emu/ovni/mark.c index 2081b41..aab9e96 100644 --- a/src/emu/ovni/mark.c +++ b/src/emu/ovni/mark.c @@ -303,7 +303,7 @@ create_thread_chan(struct ovni_mark_emu *m, struct bay *bay, struct thread *th) struct ovni_mark_thread *t = &oth->mark; /* Create as many channels as required */ - t->channels = calloc(m->ntypes, sizeof(struct chan)); + t->channels = calloc((size_t) m->ntypes, sizeof(struct chan)); if (t->channels == NULL) { err("calloc failed:"); return -1; @@ -330,7 +330,7 @@ create_thread_chan(struct ovni_mark_emu *m, struct bay *bay, struct thread *th) } /* Setup tracking */ - t->track = calloc(m->ntypes, sizeof(struct track)); + t->track = calloc((size_t) m->ntypes, sizeof(struct track)); if (t->track == NULL) { err("calloc failed:"); return -1; @@ -358,7 +358,7 @@ init_cpu(struct ovni_mark_emu *m, struct bay *bay, struct cpu *cpu) struct ovni_mark_cpu *c = &ocpu->mark; /* Setup tracking */ - c->track = calloc(m->ntypes, sizeof(struct track)); + c->track = calloc((size_t) m->ntypes, sizeof(struct track)); if (c->track == NULL) { err("calloc failed:"); return -1; @@ -442,7 +442,7 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv) /* Then connect the output of the tracking module to the prv * trace for the current thread */ struct chan *out = track_get_output(track); - long row = sth->gindex; + long row = (long) sth->gindex; long flags = PRV_SKIPDUPNULL; long prvtype = type->prvtype; if (prv_register(prv, row, prvtype, &emu->bay, out, flags)) { @@ -457,14 +457,14 @@ connect_thread_prv(struct emu *emu, struct thread *sth, struct prv *prv) static int create_type(struct pcf *pcf, struct mark_type *type) { - struct pcf_type *pcftype = pcf_add_type(pcf, type->prvtype, type->title); + struct pcf_type *pcftype = pcf_add_type(pcf, (int) type->prvtype, type->title); if (pcftype == NULL) { err("pcf_add_type failed"); return -1; } for (struct mark_label *l = type->labels; l; l = l->hh.next) { - if (pcf_add_value(pcftype, l->value, l->label) == NULL) { + if (pcf_add_value(pcftype, (int) l->value, l->label) == NULL) { err("pcf_add_value failed"); return -1; } @@ -534,7 +534,7 @@ connect_cpu_prv(struct emu *emu, struct cpu *scpu, struct prv *prv) struct track *track = &mcpu->track[i]; struct chan *sel = cpu_get_th_chan(scpu); - int64_t nthreads = emu->system.nthreads; + int64_t nthreads = (int64_t) emu->system.nthreads; if (track_set_select(track, sel, NULL, nthreads) != 0) { err("track_select failed"); return -1; @@ -557,7 +557,7 @@ connect_cpu_prv(struct emu *emu, struct cpu *scpu, struct prv *prv) /* Then connect the output of the tracking module to the prv * trace for the current thread */ struct chan *out = track_get_output(track); - long row = scpu->gindex; + long row = (long) scpu->gindex; long flags = PRV_SKIPDUPNULL; long prvtype = type->prvtype; if (prv_register(prv, row, prvtype, &emu->bay, out, flags)) { diff --git a/src/emu/ovnievents.c b/src/emu/ovnievents.c index 08e080d..c217e1e 100644 --- a/src/emu/ovnievents.c +++ b/src/emu/ovnievents.c @@ -20,7 +20,7 @@ static int html_encode(char *dst, int ndst, const char *src) { int j = 0; - int nsrc = strlen(src); + int nsrc = (int) strlen(src); for (int i = 0; i < nsrc; i++) { /* Simple check */ @@ -36,7 +36,7 @@ html_encode(char *dst, int ndst, const char *src) case '\'': strcpy(&dst[j], "'"); j += 6; break; case '<': strcpy(&dst[j], "<"); j += 4; break; case '>': strcpy(&dst[j], ">"); j += 4; break; - default: dst[j++] = c; break; + default: dst[j++] = (char) c; break; } } diff --git a/src/emu/ovnisort.c b/src/emu/ovnisort.c index a82d004..a439552 100644 --- a/src/emu/ovnisort.c +++ b/src/emu/ovnisort.c @@ -179,7 +179,7 @@ write_events(struct ovni_ev **table, long n, uint8_t *buf) { for (long i = 0; i < n; i++) { struct ovni_ev *ev = table[i]; - size_t size = ovni_ev_size(ev); + size_t size = (size_t) ovni_ev_size(ev); memcpy(buf, ev, size); buf += size; @@ -200,8 +200,8 @@ cmp_ev(const void *a, const void *b) struct ovni_ev *ev1 = *pev1; struct ovni_ev *ev2 = *pev2; - int64_t clock1 = ev1->header.clock; - int64_t clock2 = ev2->header.clock; + int64_t clock1 = (int64_t) ev1->header.clock; + int64_t clock2 = (int64_t) ev2->header.clock; if (clock1 < clock2) return -1; @@ -223,19 +223,19 @@ sort_buf(uint8_t *src, uint8_t *buf, int64_t bufsize) ev->header.clock); /* Create a copy of the array */ - uint8_t *buf2 = malloc(bufsize); + uint8_t *buf2 = malloc((size_t) bufsize); if (buf2 == NULL) die("malloc failed:"); - memcpy(buf2, src, bufsize); + memcpy(buf2, src, (size_t) bufsize); long n = count_events(buf2, buf2 + bufsize); - struct ovni_ev **table = calloc(n, sizeof(struct ovni_ev *)); + struct ovni_ev **table = calloc((size_t) n, sizeof(struct ovni_ev *)); if (table == NULL) die("calloc failed:"); index_events(table, n, buf2); - qsort(table, n, sizeof(struct ovni_ev *), cmp_ev); + qsort(table, (size_t) n, sizeof(struct ovni_ev *), cmp_ev); write_events(table, n, buf); dbg("first event after sorting %c%c%c at %"PRIu64, @@ -260,7 +260,7 @@ write_stream(int fd, void *base, void *dst, const void *src, size_t size) if (written < 0) die("pwrite failed:"); - size -= written; + size -= (size_t) written; src = (void *) (((uint8_t *) src) + written); dst = (void *) (((uint8_t *) dst) + written); } @@ -300,7 +300,7 @@ execute_sort_plan(struct sortplan *sp) if (!buf) die("malloc failed:"); - sort_buf((uint8_t *) first, buf, bufsize); + sort_buf((uint8_t *) first, buf, (int64_t) bufsize); write_stream(sp->fd, sp->base, first, buf, bufsize); @@ -435,8 +435,8 @@ process_trace(struct trace *trace) struct ring ring; int ret = 0; - ring.size = max_look_back; - ring.ev = malloc(ring.size * sizeof(struct ovni_ev *)); + ring.size = (ssize_t) max_look_back; + ring.ev = malloc((size_t) ring.size * sizeof(struct ovni_ev *)); if (ring.ev == NULL) die("malloc failed:"); @@ -511,7 +511,7 @@ parse_args(int argc, char *argv[]) operation_mode = CHECK; break; case 'n': - max_look_back = atol(optarg); + max_look_back = (size_t) atol(optarg); break; default: /* '?' */ usage(); diff --git a/src/emu/ovnisync.c b/src/emu/ovnisync.c index 3a2e9b8..9e12be2 100644 --- a/src/emu/ovnisync.c +++ b/src/emu/ovnisync.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 @@ -182,7 +182,7 @@ fill_offset(struct offset *offset, int nsamples) static void offset_compute_delta(struct offset *ref, struct offset *cur, int nsamples, int verbose) { - double *delta = malloc(sizeof(double) * nsamples); + double *delta = malloc(sizeof(double) * (size_t) nsamples); if (delta == NULL) { perror("malloc"); @@ -199,7 +199,7 @@ offset_compute_delta(struct offset *ref, struct offset *cur, int nsamples, int v } } - qsort(delta, nsamples, sizeof(double), cmp_double); + qsort(delta, (size_t) nsamples, sizeof(double), cmp_double); cur->delta_median = delta[nsamples / 2]; cur->delta_mean = 0; @@ -223,14 +223,14 @@ offset_compute_delta(struct offset *ref, struct offset *cur, int nsamples, int v static size_t offset_size(int nsamples) { - return sizeof(struct offset) + sizeof(double) * nsamples; + return sizeof(struct offset) + sizeof(double) * (size_t) nsamples; } static struct offset * table_get_offset(struct offset_table *table, int i, int nsamples) { char *p = (char *) table->_offset; - p += i * offset_size(nsamples); + p += (size_t) i * offset_size(nsamples); return (struct offset *) p; } @@ -252,14 +252,14 @@ build_offset_table(int nsamples, int rank, int verbose) MPI_Comm_size(MPI_COMM_WORLD, &table->nprocs); - table->_offset = calloc(table->nprocs, offset_size(nsamples)); + table->_offset = calloc((size_t) table->nprocs, offset_size(nsamples)); if (table->_offset == NULL) { perror("malloc"); exit(EXIT_FAILURE); } - table->offset = malloc(sizeof(struct offset *) * table->nprocs); + table->offset = malloc(sizeof(struct offset *) * (size_t) table->nprocs); if (table->offset == NULL) { perror("malloc"); @@ -288,8 +288,8 @@ build_offset_table(int nsamples, int rank, int verbose) void *sendbuf = rank == 0 ? MPI_IN_PLACE : offset; /* Then collect all the offsets into the rank 0 */ - MPI_Gather(sendbuf, offset_size(nsamples), MPI_CHAR, - offset, offset_size(nsamples), MPI_CHAR, + MPI_Gather(sendbuf, (int) offset_size(nsamples), MPI_CHAR, + offset, (int) offset_size(nsamples), MPI_CHAR, 0, MPI_COMM_WORLD); /* Finish the offsets by computing the deltas on rank 0 */ @@ -399,7 +399,7 @@ do_work(struct options *options, int rank) } if (drift_mode) - sleep(options->drift_wait); + sleep((unsigned) options->drift_wait); } if (rank == 0) diff --git a/src/emu/path.c b/src/emu/path.c index 2743f18..1161c2d 100644 --- a/src/emu/path.c +++ b/src/emu/path.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 "path.h" @@ -95,7 +95,7 @@ path_keep(char *path, int n) void path_remove_trailing(char *path) { - int n = strlen(path); + int n = (int) strlen(path); for (int i = n - 1; i >= 0 && path[i] == '/'; i--) { path[i] = '\0'; } diff --git a/src/emu/pv/prf.c b/src/emu/pv/prf.c index 0414457..7032dfb 100644 --- a/src/emu/pv/prf.c +++ b/src/emu/pv/prf.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 "prf.h" @@ -20,7 +20,7 @@ prf_open(struct prf *prf, const char *path, long nrows) } prf->nrows = nrows; - prf->rows = calloc(nrows, sizeof(struct prf_row)); + prf->rows = calloc((size_t) nrows, sizeof(struct prf_row)); if (prf->rows == NULL) { err("calloc failed:"); diff --git a/src/emu/pv/prv.c b/src/emu/pv/prv.c index c227f1e..a5e0b85 100644 --- a/src/emu/pv/prv.c +++ b/src/emu/pv/prv.c @@ -25,7 +25,7 @@ prv_open_file(struct prv *prv, long nrows, FILE *file) prv->file = file; /* Write fake header to allocate the space */ - write_header(file, 0LL, nrows); + write_header(file, 0LL, (int) nrows); return 0; } @@ -48,7 +48,7 @@ prv_close(struct prv *prv) { /* Fix the header with the current duration */ fseek(prv->file, 0, SEEK_SET); - write_header(prv->file, prv->time, prv->nrows); + write_header(prv->file, prv->time, (int) prv->nrows); fclose(prv->file); return 0; } diff --git a/src/emu/sort.c b/src/emu/sort.c index 3dc0e5a..d994cea 100644 --- a/src/emu/sort.c +++ b/src/emu/sort.c @@ -106,8 +106,8 @@ sort_cb_input(struct chan *in_chan, void *ptr) if (likely(sort->copied)) { sort_replace(sort->sorted, sort->n, old, new); } else { - memcpy(sort->sorted, sort->values, sort->n * sizeof(int64_t)); - qsort(sort->sorted, sort->n, sizeof(int64_t), cmp_int64); + memcpy(sort->sorted, sort->values, (size_t) sort->n * sizeof(int64_t)); + qsort(sort->sorted, (size_t) sort->n, sizeof(int64_t), cmp_int64); sort->copied = 1; } @@ -141,22 +141,22 @@ sort_init(struct sort *sort, struct bay *bay, int64_t n, const char *name) memset(sort, 0, sizeof(struct sort)); sort->bay = bay; sort->n = n; - sort->inputs = calloc(n, sizeof(struct sort_input)); + sort->inputs = calloc((size_t) n, sizeof(struct sort_input)); if (sort->inputs == NULL) { err("calloc failed:"); return -1; } - sort->outputs = calloc(n, sizeof(struct chan)); + sort->outputs = calloc((size_t) n, sizeof(struct chan)); if (sort->outputs == NULL) { err("calloc failed:"); return -1; } - sort->values = calloc(n, sizeof(int64_t)); + sort->values = calloc((size_t) n, sizeof(int64_t)); if (sort->values == NULL) { err("calloc failed:"); return -1; } - sort->sorted = calloc(n, sizeof(int64_t)); + sort->sorted = calloc((size_t) n, sizeof(int64_t)); if (sort->sorted == NULL) { err("calloc failed:"); return -1; diff --git a/src/emu/stream.c b/src/emu/stream.c index 1e267dd..ddfe2b6 100644 --- a/src/emu/stream.c +++ b/src/emu/stream.c @@ -59,7 +59,7 @@ load_stream_fd(struct stream *stream, int fd) } int prot = PROT_READ | PROT_WRITE; - stream->buf = mmap(NULL, st.st_size, prot, MAP_PRIVATE, fd, 0); + stream->buf = mmap(NULL, (size_t) st.st_size, prot, MAP_PRIVATE, fd, 0); if (stream->buf == MAP_FAILED) { err("mmap failed:"); @@ -241,7 +241,7 @@ stream_step(struct stream *stream) void stream_progress(struct stream *stream, int64_t *done, int64_t *total) { - *done = stream->offset - sizeof(struct ovni_stream_header); + *done = stream->offset - (int64_t) sizeof(struct ovni_stream_header); *total = stream->usize; } diff --git a/src/emu/system.c b/src/emu/system.c index e196f85..3b30d85 100644 --- a/src/emu/system.c +++ b/src/emu/system.c @@ -226,7 +226,7 @@ create_system(struct system *sys, struct trace *trace) const char *dir = trace->tracedir; /* Allocate the lpt map */ - sys->lpt = calloc(trace->nstreams, sizeof(struct lpt)); + sys->lpt = calloc((size_t) trace->nstreams, sizeof(struct lpt)); if (sys->lpt == NULL) { err("calloc failed:"); return -1; @@ -373,20 +373,20 @@ init_global_indices(struct system *sys) { size_t iloom = 0; for (struct loom *l = sys->looms; l; l = l->next) - loom_set_gindex(l, iloom++); + loom_set_gindex(l, (int64_t) iloom++); sys->nprocs = 0; for (struct proc *p = sys->procs; p; p = p->gnext) - proc_set_gindex(p, sys->nprocs++); + proc_set_gindex(p, (int64_t) sys->nprocs++); sys->nthreads = 0; for (struct thread *t = sys->threads; t; t = t->gnext) - thread_set_gindex(t, sys->nthreads++); + thread_set_gindex(t, (int64_t) sys->nthreads++); sys->ncpus = 0; sys->nphycpus = 0; for (struct cpu *c = sys->cpus; c; c = c->next) { - cpu_set_gindex(c, sys->ncpus++); + cpu_set_gindex(c, (int64_t) sys->ncpus++); if (!c->is_virtual) sys->nphycpus++; } @@ -641,13 +641,13 @@ system_connect(struct system *sys, struct bay *bay, struct recorder *rec) { /* Create Paraver traces */ struct pvt *pvt_cpu = NULL; - if ((pvt_cpu = recorder_add_pvt(rec, "cpu", sys->ncpus)) == NULL) { + if ((pvt_cpu = recorder_add_pvt(rec, "cpu", (long) sys->ncpus)) == NULL) { err("recorder_add_pvt failed"); return -1; } struct pvt *pvt_th = NULL; - if ((pvt_th = recorder_add_pvt(rec, "thread", sys->nthreads)) == NULL) { + if ((pvt_th = recorder_add_pvt(rec, "thread", (long) sys->nthreads)) == NULL) { err("recorder_add_pvt failed"); return -1; } @@ -667,7 +667,7 @@ system_connect(struct system *sys, struct bay *bay, struct recorder *rec) return -1; } - if (prf_add(prf, th->gindex, name) != 0) { + if (prf_add(prf, (long) th->gindex, name) != 0) { err("prf_add failed for thread '%s'", th->id); return -1; } @@ -688,7 +688,7 @@ system_connect(struct system *sys, struct bay *bay, struct recorder *rec) } struct prf *prf = pvt_get_prf(pvt_cpu); - if (prf_add(prf, cpu->gindex, cpu->name) != 0) { + if (prf_add(prf, (long) cpu->gindex, cpu->name) != 0) { err("prf_add failed for cpu '%s'", cpu->name); return -1; } diff --git a/src/emu/task.c b/src/emu/task.c index 53df5db..ae0562f 100644 --- a/src/emu/task.c +++ b/src/emu/task.c @@ -288,7 +288,7 @@ task_create_pcf_types(struct pcf_type *pcftype, struct task_type *types) /* Emit types for all task types */ for (struct task_type *tt = types; tt != NULL; tt = tt->hh.next) { - struct pcf_value *pcfvalue = pcf_find_value(pcftype, tt->gid); + struct pcf_value *pcfvalue = pcf_find_value(pcftype, (int) tt->gid); if (pcfvalue != NULL) { /* Ensure the label is the same, so we know that * no collision occurred */ @@ -301,7 +301,7 @@ task_create_pcf_types(struct pcf_type *pcftype, struct task_type *types) } } - if (pcf_add_value(pcftype, tt->gid, tt->label) == NULL) { + if (pcf_add_value(pcftype, (int) tt->gid, tt->label) == NULL) { err("pcf_add_value failed"); return -1; } diff --git a/src/emu/thread.c b/src/emu/thread.c index 2f3f714..72995e8 100644 --- a/src/emu/thread.c +++ b/src/emu/thread.c @@ -91,7 +91,7 @@ get_tid(const char *id, int *tid) char *endptr; errno = 0; - *tid = strtol(tidstr, &endptr, 10); + *tid = (int) strtol(tidstr, &endptr, 10); if (errno != 0) { err("strtol failed for '%s':", tidstr); return -1; @@ -196,7 +196,7 @@ create_type(struct pcf *pcf, int i) return 0; const char *label = pvt_name[i]; - struct pcf_type *pcftype = pcf_add_type(pcf, type, label); + struct pcf_type *pcftype = pcf_add_type(pcf, (int) type, label); if (pcftype == NULL) { err("pcf_add_type failed"); return -1; @@ -234,7 +234,7 @@ thread_connect(struct thread *th, struct bay *bay, struct recorder *rec) } long type = chan_type[i]; - long row = th->gindex; + long row = (long) th->gindex; long flags = prv_flags[i]; if (prv_register(prv, row, type, bay, c, flags)) { diff --git a/src/emu/trace.c b/src/emu/trace.c index 74071d0..4b8bd49 100644 --- a/src/emu/trace.c +++ b/src/emu/trace.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 */ #define _XOPEN_SOURCE 500 @@ -36,7 +36,7 @@ load_stream(struct trace *trace, const char *path) return -1; } - int offset = strlen(trace->tracedir); + int offset = (int) strlen(trace->tracedir); const char *relpath = path + offset; /* Skip begin slashes */ @@ -58,14 +58,14 @@ has_suffix(const char *str, const char *suffix) if (!str || !suffix) return 0; - int lenstr = strlen(str); - int lensuffix = strlen(suffix); + int lenstr = (int) strlen(str); + int lensuffix = (int) strlen(suffix); if (lensuffix > lenstr) return 0; const char *p = str + lenstr - lensuffix; - if (strncmp(p, suffix, lensuffix) == 0) + if (strncmp(p, suffix, (size_t) lensuffix) == 0) return 1; return 0; diff --git a/src/emu/track.c b/src/emu/track.c index 9bc6835..4f7aa5f 100644 --- a/src/emu/track.c +++ b/src/emu/track.c @@ -23,8 +23,8 @@ track_init(struct track *track, struct bay *bay, enum track_type type, int mode, va_list ap; va_start(ap, fmt); - int n = ARRAYLEN(track->name); - int ret = vsnprintf(track->name, n, fmt, ap); + int n = (int) ARRAYLEN(track->name); + int ret = vsnprintf(track->name, (size_t) n, fmt, ap); if (ret >= n) { err("track name too long"); return -1; diff --git a/src/include/heap.h b/src/include/heap.h index d88932e..cd3e1a1 100644 --- a/src/include/heap.h +++ b/src/include/heap.h @@ -117,11 +117,11 @@ leading_zeros(size_t x) { /* Call and if()'s optimized by the compiler with -O2 */ if (sizeof(size_t) == sizeof(unsigned int)) - return __builtin_clz(x); + return __builtin_clz((unsigned int) x); else if (sizeof(size_t) == sizeof(unsigned long)) - return __builtin_clzl(x); + return __builtin_clzl((unsigned long) x); else if (sizeof(size_t) == sizeof(unsigned long long)) - return __builtin_clzll(x); + return __builtin_clzll((unsigned long long) x); else die("cannot find suitable size for __builtin_clz*"); } @@ -133,7 +133,7 @@ heap_get_move(size_t *node /*out*/) size_t aux_node = *node; // Round to previous po2 - int shift = sizeof(size_t) * 8 - leading_zeros(aux_node) - 1; + int shift = (int) sizeof(size_t) * 8 - leading_zeros(aux_node) - 1; size_t base = 1ULL << shift; aux_node -= base / 2; diff --git a/src/parson.c b/src/parson.c index f29248b..193f09f 100644 --- a/src/parson.c +++ b/src/parson.c @@ -316,7 +316,7 @@ read_file(const char *filename) fclose(fp); return NULL; } - size_to_read = pos; + size_to_read = (size_t) pos; rewind(fp); file_contents = (char *) parson_malloc(sizeof(char) * (size_to_read + 1)); if (!file_contents) { @@ -361,7 +361,7 @@ remove_comments(char *string, const char *start_token, const char *end_token) if (!ptr) { return; } - for (i = 0; i < (ptr - string) + end_token_len; i++) { + for (i = 0; i < (size_t) (ptr - string) + end_token_len; i++) { string[i] = ' '; } string = ptr + end_token_len - 1; @@ -503,7 +503,7 @@ json_object_dotremove_internal(JSON_Object *object, const char *name, int free_v if (dot_pos == NULL) { return json_object_remove_internal(object, name, free_value); } - temp_value = json_object_getn_value(object, name, dot_pos - name); + temp_value = json_object_getn_value(object, name, (size_t) (dot_pos - name)); if (json_value_get_type(temp_value) != JSONObject) { return JSONFailure; } @@ -638,13 +638,13 @@ parse_utf16(const char **unprocessed, char **processed) if (cp < 0x80) { processed_ptr[0] = (char) cp; /* 0xxxxxxx */ } else if (cp < 0x800) { - processed_ptr[0] = ((cp >> 6) & 0x1F) | 0xC0; /* 110xxxxx */ - processed_ptr[1] = ((cp) &0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr[0] = (char) (((cp >> 6) & 0x1F) | 0xC0); /* 110xxxxx */ + processed_ptr[1] = (char) (((cp) &0x3F) | 0x80); /* 10xxxxxx */ processed_ptr += 1; } else if (cp < 0xD800 || cp > 0xDFFF) { - processed_ptr[0] = ((cp >> 12) & 0x0F) | 0xE0; /* 1110xxxx */ - processed_ptr[1] = ((cp >> 6) & 0x3F) | 0x80; /* 10xxxxxx */ - processed_ptr[2] = ((cp) &0x3F) | 0x80; /* 10xxxxxx */ + processed_ptr[0] = (char) (((cp >> 12) & 0x0F) | 0xE0);/* 1110xxxx */ + processed_ptr[1] = (char) (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[2] = (char) (((cp) &0x3F) | 0x80); /* 10xxxxxx */ processed_ptr += 2; } else if (cp >= 0xD800 && cp <= 0xDBFF) { /* lead surrogate (0xD800..0xDBFF) */ lead = cp; @@ -657,10 +657,10 @@ parse_utf16(const char **unprocessed, char **processed) return JSONFailure; } cp = ((((lead - 0xD800) & 0x3FF) << 10) | ((trail - 0xDC00) & 0x3FF)) + 0x010000; - processed_ptr[0] = (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ - processed_ptr[1] = (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ - processed_ptr[2] = (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ - processed_ptr[3] = (((cp) &0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[0] = (char) (((cp >> 18) & 0x07) | 0xF0); /* 11110xxx */ + processed_ptr[1] = (char) (((cp >> 12) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[2] = (char) (((cp >> 6) & 0x3F) | 0x80); /* 10xxxxxx */ + processed_ptr[3] = (char) (((cp) &0x3F) | 0x80); /* 10xxxxxx */ processed_ptr += 3; } else { /* trail surrogate before lead surrogate */ return JSONFailure; @@ -758,7 +758,7 @@ get_quoted_string(const char **string, size_t *output_string_len) if (status != JSONSuccess) { return NULL; } - input_string_len = *string - string_start - 2; /* length without quotes */ + input_string_len = (size_t) (*string - string_start - 2); /* length without quotes */ return process_string(string_start + 1, input_string_len, output_string_len); } @@ -957,7 +957,7 @@ parse_number_value(const char **string) if (errno == ERANGE && (number == -HUGE_VAL || number == HUGE_VAL)) { return NULL; } - if ((errno && errno != ERANGE) || !is_decimal(*string, end - *string)) { + if ((errno && errno != ERANGE) || !is_decimal(*string, (size_t) (end - *string))) { return NULL; } *string = end; @@ -1410,7 +1410,7 @@ json_object_dotget_value(const JSON_Object *object, const char *name) if (!dot_position) { return json_object_get_value(object, name); } - object = json_value_get_object(json_object_getn_value(object, name, dot_position - name)); + object = json_value_get_object(json_object_getn_value(object, name, (size_t) (dot_position - name))); return json_object_dotget_value(object, dot_position + 1); } @@ -2253,7 +2253,7 @@ json_object_dotset_value(JSON_Object *object, const char *name, JSON_Value *valu if (dot_pos == NULL) { return json_object_set_value(object, name, value); } - name_len = dot_pos - name; + name_len = (size_t) (dot_pos - name); temp_value = json_object_getn_value(object, name, name_len); if (temp_value) { /* Don't overwrite existing non-object (unlike json_object_set_value, but it shouldn't be changed at this point) */ diff --git a/src/rt/ovni.c b/src/rt/ovni.c index 2ce748c..92a3b98 100644 --- a/src/rt/ovni.c +++ b/src/rt/ovni.c @@ -435,8 +435,8 @@ write_evbuf(uint8_t *buf, size_t size) if (written < 0) die("failed to write buffer to disk:"); - size -= written; - buf += written; + size -= (size_t) written; + buf += (size_t) written; } while (size > 0); } @@ -638,7 +638,7 @@ clock_monotonic_now(void) if (clock_gettime(rproc.clockid, &tp)) die("clock_gettime() failed:"); - return tp.tv_sec * ns + tp.tv_nsec; + return (uint64_t) tp.tv_sec * ns + (uint64_t) tp.tv_nsec; } uint64_t @@ -666,9 +666,9 @@ ovni_ev_get_clock(const struct ovni_ev *ev) void ovni_ev_set_mcv(struct ovni_ev *ev, const char *mcv) { - ev->header.model = mcv[0]; - ev->header.category = mcv[1]; - ev->header.value = mcv[2]; + ev->header.model = (uint8_t) mcv[0]; + ev->header.category = (uint8_t) mcv[1]; + ev->header.value = (uint8_t) mcv[2]; } static size_t @@ -681,7 +681,7 @@ int ovni_payload_size(const struct ovni_ev *ev) { if (ev->header.flags & OVNI_EV_JUMBO) - return get_jumbo_payload_size(ev); + return (int) get_jumbo_payload_size(ev); int size = ev->header.flags & 0x0f; @@ -704,22 +704,23 @@ ovni_payload_add(struct ovni_ev *ev, const uint8_t *buf, int size) if (size < 2) die("payload size %d too small", size); - size_t payload_size = ovni_payload_size(ev); + size_t payload_size = (size_t) ovni_payload_size(ev); /* Ensure we have room */ - if (payload_size + size > sizeof(ev->payload)) + if (payload_size + (size_t) size > sizeof(ev->payload)) die("no space left for %d bytes", size); - memcpy(&ev->payload.u8[payload_size], buf, size); - payload_size += size; + memcpy(&ev->payload.u8[payload_size], buf, (size_t) size); + payload_size += (size_t) size; - ev->header.flags = (ev->header.flags & 0xf0) | ((payload_size - 1) & 0x0f); + ev->header.flags = (uint8_t) ((ev->header.flags & 0xf0) + | ((payload_size - 1) & 0x0f)); } int ovni_ev_size(const struct ovni_ev *ev) { - return sizeof(ev->header) + ovni_payload_size(ev); + return (int) sizeof(ev->header) + ovni_payload_size(ev); } static void @@ -778,7 +779,7 @@ ovni_ev_add_jumbo(struct ovni_ev *ev, const uint8_t *buf, uint32_t bufsize) die("the event payload must be empty"); ovni_payload_add(ev, (uint8_t *) &bufsize, sizeof(bufsize)); - size_t evsize = ovni_ev_size(ev); + size_t evsize = (size_t) ovni_ev_size(ev); size_t totalsize = evsize + bufsize; @@ -818,7 +819,7 @@ ovni_ev_add(struct ovni_ev *ev) int flushed = 0; uint64_t t0, t1; - int size = ovni_ev_size(ev); + size_t size = (size_t) ovni_ev_size(ev); /* Check if the event fits or flush first otherwise */ if (rthread.evlen + size >= OVNI_MAX_EV_BUF) { diff --git a/test/emu/common/instr.c b/test/emu/common/instr.c index 575c413..46628c7 100644 --- a/test/emu/common/instr.c +++ b/test/emu/common/instr.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 "instr.h" @@ -9,7 +9,7 @@ int64_t last_clock; /* Clock from the last event */ int64_t get_clock(void) { - last_clock = ovni_clock_now(); + last_clock = (int64_t) ovni_clock_now(); if (first_clock_set == 0) { first_clock = last_clock; first_clock_set = 1; diff --git a/test/emu/common/instr.h b/test/emu/common/instr.h index 0e58fc0..9ac5114 100644 --- a/test/emu/common/instr.h +++ b/test/emu/common/instr.h @@ -19,20 +19,20 @@ extern int64_t last_clock; int64_t get_clock(void); int64_t get_delta(void); -#define INSTR_0ARG(name, mcv) \ - static inline void name(void) \ - { \ - struct ovni_ev ev = {0}; \ - ovni_ev_set_clock(&ev, get_clock()); \ - ovni_ev_set_mcv(&ev, mcv); \ - ovni_ev_emit(&ev); \ +#define INSTR_0ARG(name, mcv) \ + static inline void name(void) \ + { \ + struct ovni_ev ev = {0}; \ + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); \ + ovni_ev_set_mcv(&ev, mcv); \ + ovni_ev_emit(&ev); \ } #define INSTR_1ARG(name, mcv, ta, a) \ static inline void name(ta a) \ { \ struct ovni_ev ev = {0}; \ - ovni_ev_set_clock(&ev, get_clock()); \ + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); \ ovni_ev_set_mcv(&ev, mcv); \ ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \ ovni_ev_emit(&ev); \ @@ -42,7 +42,7 @@ int64_t get_delta(void); static inline void name(ta a, tb b) \ { \ struct ovni_ev ev = {0}; \ - ovni_ev_set_clock(&ev, get_clock()); \ + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); \ ovni_ev_set_mcv(&ev, mcv); \ ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \ ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \ @@ -53,7 +53,7 @@ int64_t get_delta(void); static inline void name(ta a, tb b, tc c) \ { \ struct ovni_ev ev = {0}; \ - ovni_ev_set_clock(&ev, get_clock()); \ + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); \ ovni_ev_set_mcv(&ev, mcv); \ ovni_payload_add(&ev, (uint8_t *) &a, sizeof(a)); \ ovni_payload_add(&ev, (uint8_t *) &b, sizeof(b)); \ @@ -72,7 +72,7 @@ instr_thread_end(void) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OHe"); - ovni_ev_set_clock(&ev, get_clock()); + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); ovni_ev_emit(&ev); /* Flush the events to disk before killing the thread */ diff --git a/test/emu/nanos6/blocking.c b/test/emu/nanos6/blocking.c index 2c0271f..016db55 100644 --- a/test/emu/nanos6/blocking.c +++ b/test/emu/nanos6/blocking.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 @@ -19,17 +19,17 @@ main(void) uint32_t typeid = 1; uint32_t taskid = 1; - instr_nanos6_type_create(typeid); + instr_nanos6_type_create((int32_t) typeid); - instr_nanos6_task_create_and_execute(taskid, typeid); + instr_nanos6_task_create_and_execute((int32_t) taskid, typeid); sleep_us(us); instr_nanos6_block_enter(); - instr_nanos6_task_pause(taskid); + instr_nanos6_task_pause((int32_t) taskid); sleep_us(us); - instr_nanos6_task_resume(taskid); + instr_nanos6_task_resume((int32_t) taskid); instr_nanos6_block_exit(); sleep_us(us); - instr_nanos6_task_end(taskid); + instr_nanos6_task_end((int32_t) taskid); instr_nanos6_task_body_exit(); instr_end(); diff --git a/test/emu/nanos6/if0-pause-parent.c b/test/emu/nanos6/if0-pause-parent.c index c30f1e1..2dcc230 100644 --- a/test/emu/nanos6/if0-pause-parent.c +++ b/test/emu/nanos6/if0-pause-parent.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 @@ -18,7 +18,7 @@ main(void) int ntasks = 100; uint32_t typeid = 1; - instr_nanos6_type_create(typeid); + instr_nanos6_type_create((int32_t) typeid); /* Create and run the tasks, one nested into another */ for (int32_t id = 1; id <= ntasks; id++) { diff --git a/test/emu/nanos6/instr_nanos6.h b/test/emu/nanos6/instr_nanos6.h index 90f39ea..b82e964 100644 --- a/test/emu/nanos6/instr_nanos6.h +++ b/test/emu/nanos6/instr_nanos6.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 INSTR_NANOS6_H @@ -20,7 +20,7 @@ instr_nanos6_type_create(int32_t typeid) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "6Yc"); - ovni_ev_set_clock(&ev, get_clock()); + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); char buf[256]; char *p = buf; @@ -32,7 +32,7 @@ instr_nanos6_type_create(int32_t typeid) sprintf(p, "testtype%d", typeid); nbytes += strlen(p) + 1; - ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes); + ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, (uint32_t) nbytes); return task_get_type_gid(p); } diff --git a/test/emu/nanos6/nested-tasks-bad.c b/test/emu/nanos6/nested-tasks-bad.c index 181a9d7..3494028 100644 --- a/test/emu/nanos6/nested-tasks-bad.c +++ b/test/emu/nanos6/nested-tasks-bad.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 @@ -12,13 +12,13 @@ main(void) instr_nanos6_init(); uint32_t typeid = 666; - instr_nanos6_type_create(typeid); + instr_nanos6_type_create((int32_t) typeid); uint32_t taskid = 1; - instr_nanos6_task_create_and_execute(taskid, typeid); + instr_nanos6_task_create_and_execute((int32_t) taskid, typeid); /* Run another nested task with same id (should fail) */ - instr_nanos6_task_execute(taskid); + instr_nanos6_task_execute((int32_t) taskid); instr_end(); diff --git a/test/emu/nanos6/nested-tasks.c b/test/emu/nanos6/nested-tasks.c index f6b291d..c2fcd0b 100644 --- a/test/emu/nanos6/nested-tasks.c +++ b/test/emu/nanos6/nested-tasks.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 @@ -15,7 +15,7 @@ main(void) int ntasks = 100; uint32_t typeid = 1; - instr_nanos6_type_create(typeid); + instr_nanos6_type_create((int32_t) typeid); /* Create and run the tasks, one nested into another */ for (int i = 0; i < ntasks; i++) { diff --git a/test/emu/nanos6/rerun-task-bad.c b/test/emu/nanos6/rerun-task-bad.c index b922a9c..cf481e3 100644 --- a/test/emu/nanos6/rerun-task-bad.c +++ b/test/emu/nanos6/rerun-task-bad.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 @@ -14,15 +14,15 @@ main(void) instr_nanos6_init(); uint32_t typeid = 666; - instr_nanos6_type_create(typeid); + instr_nanos6_type_create((int32_t) typeid); uint32_t taskid = 1; - instr_nanos6_task_create_and_execute(taskid, typeid); - instr_nanos6_task_end(taskid); + instr_nanos6_task_create_and_execute((int32_t) taskid, typeid); + instr_nanos6_task_end((int32_t) taskid); /* Run again the same task (should fail) */ - instr_nanos6_task_execute(taskid); - instr_nanos6_task_end(taskid); + instr_nanos6_task_execute((int32_t) taskid); + instr_nanos6_task_end((int32_t) taskid); instr_end(); diff --git a/test/emu/nanos6/switch-same-type.c b/test/emu/nanos6/switch-same-type.c index 6f1eb1d..9aae91c 100644 --- a/test/emu/nanos6/switch-same-type.c +++ b/test/emu/nanos6/switch-same-type.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 @@ -19,7 +19,7 @@ main(void) instr_nanos6_init(); uint32_t typeid = 100; - uint32_t gid = instr_nanos6_type_create(typeid); + uint32_t gid = instr_nanos6_type_create((int32_t) typeid); /* Create two tasks of the same type */ instr_nanos6_task_create(1, typeid); diff --git a/test/emu/nanos6/task-types.c b/test/emu/nanos6/task-types.c index 87744cc..58b8a23 100644 --- a/test/emu/nanos6/task-types.c +++ b/test/emu/nanos6/task-types.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 @@ -22,7 +22,7 @@ main(void) instr_nanos6_type_create(i + 1); for (int i = 0; i < ntasks; i++) { - instr_nanos6_task_create_and_execute(i + 1, (i % ntypes) + 1); + instr_nanos6_task_create_and_execute(i + 1, (uint32_t) ((i % ntypes) + 1)); sleep_us(500); instr_nanos6_task_end(i + 1); instr_nanos6_task_body_exit(); diff --git a/test/emu/nosv/bad-double-execute-parallel.c b/test/emu/nosv/bad-double-execute-parallel.c index 3d4dc33..6e83d5d 100644 --- a/test/emu/nosv/bad-double-execute-parallel.c +++ b/test/emu/nosv/bad-double-execute-parallel.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 @@ -17,7 +17,7 @@ main(void) uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create_par(1, typeid); instr_nosv_task_create_par(2, typeid); diff --git a/test/emu/nosv/bad-double-execute.c b/test/emu/nosv/bad-double-execute.c index c3a45a8..062ea4a 100644 --- a/test/emu/nosv/bad-double-execute.c +++ b/test/emu/nosv/bad-double-execute.c @@ -17,7 +17,7 @@ main(void) uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); instr_nosv_task_create(2, typeid); diff --git a/test/emu/nosv/bad-nest-from-parallel.c b/test/emu/nosv/bad-nest-from-parallel.c index 876da23..d175974 100644 --- a/test/emu/nosv/bad-nest-from-parallel.c +++ b/test/emu/nosv/bad-nest-from-parallel.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 @@ -19,7 +19,7 @@ main(void) uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create_par(1, typeid); instr_nosv_task_create_par(2, typeid); diff --git a/test/emu/nosv/bad-nest-same-task.c b/test/emu/nosv/bad-nest-same-task.c index 21eb220..0bd9099 100644 --- a/test/emu/nosv/bad-nest-same-task.c +++ b/test/emu/nosv/bad-nest-same-task.c @@ -12,7 +12,7 @@ main(void) instr_nosv_init(); uint32_t typeid = 666; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); instr_nosv_task_execute(1, 0); diff --git a/test/emu/nosv/bad-pause-parallel.c b/test/emu/nosv/bad-pause-parallel.c index ca8795d..b19c2fe 100644 --- a/test/emu/nosv/bad-pause-parallel.c +++ b/test/emu/nosv/bad-pause-parallel.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 @@ -19,7 +19,7 @@ main(void) uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create_par(1, typeid); instr_nosv_submit_enter(); instr_nosv_task_execute(1, 1); diff --git a/test/emu/nosv/instr_nosv.h b/test/emu/nosv/instr_nosv.h index 0b51488..17c222b 100644 --- a/test/emu/nosv/instr_nosv.h +++ b/test/emu/nosv/instr_nosv.h @@ -21,7 +21,7 @@ instr_nosv_type_create(int32_t typeid) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "VYc"); - ovni_ev_set_clock(&ev, get_clock()); + ovni_ev_set_clock(&ev, (uint64_t) get_clock()); char buf[256]; char *p = buf; @@ -33,7 +33,7 @@ instr_nosv_type_create(int32_t typeid) sprintf(p, "testtype%d", typeid); nbytes += strlen(p) + 1; - ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, nbytes); + ovni_ev_jumbo_emit(&ev, (uint8_t *) buf, (uint32_t) nbytes); return task_get_type_gid(p); } diff --git a/test/emu/nosv/mp-rank.c b/test/emu/nosv/mp-rank.c index 1c37f7d..cc2bd0f 100644 --- a/test/emu/nosv/mp-rank.c +++ b/test/emu/nosv/mp-rank.c @@ -5,7 +5,7 @@ #include "instr_nosv.h" static void -task(int32_t id, uint32_t typeid, int us) +task(uint32_t id, uint32_t typeid, int us) { instr_nosv_task_create(id, typeid); instr_nosv_task_execute(id, 0); @@ -23,11 +23,11 @@ main(void) instr_start(rank, nranks); instr_nosv_init(); - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); /* Create some fake nosv tasks */ for (int i = 0; i < 10; i++) - task(i + 1, typeid, 5000); + task((uint32_t) i + 1, typeid, 5000); instr_end(); diff --git a/test/emu/nosv/multiple-segment.c b/test/emu/nosv/multiple-segment.c index 9e7ccd1..3285fcb 100644 --- a/test/emu/nosv/multiple-segment.c +++ b/test/emu/nosv/multiple-segment.c @@ -51,7 +51,7 @@ main(void) instr_thread_execute(lcpu, -1, 0); uint32_t typeid = 1; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); instr_nosv_task_execute(1, 0); sleep_us(10000); diff --git a/test/emu/nosv/nest-to-parallel.c b/test/emu/nosv/nest-to-parallel.c index 761659b..77ab978 100644 --- a/test/emu/nosv/nest-to-parallel.c +++ b/test/emu/nosv/nest-to-parallel.c @@ -18,7 +18,7 @@ main(void) uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); instr_nosv_task_create_par(2, typeid); diff --git a/test/emu/nosv/nested-tasks.c b/test/emu/nosv/nested-tasks.c index aca329d..171d244 100644 --- a/test/emu/nosv/nested-tasks.c +++ b/test/emu/nosv/nested-tasks.c @@ -17,21 +17,21 @@ main(void) int ntasks = 100; uint32_t typeid = 1; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); for (int id = 1; id <= ntasks; id++) - instr_nosv_task_create(id, typeid); + instr_nosv_task_create((uint32_t) id, typeid); for (int id = 1; id <= ntasks; id++) { - instr_nosv_task_execute(id, 0); - instr_nosv_task_pause(id, 0); + instr_nosv_task_execute((uint32_t) id, 0); + instr_nosv_task_pause((uint32_t) id, 0); instr_nosv_submit_enter(); } for (int id = ntasks; id >= 1; id--) { instr_nosv_submit_exit(); - instr_nosv_task_resume(id, 0); - instr_nosv_task_end(id, 0); + instr_nosv_task_resume((uint32_t) id, 0); + instr_nosv_task_end((uint32_t) id, 0); } instr_end(); diff --git a/test/emu/nosv/parallel-tasks.c b/test/emu/nosv/parallel-tasks.c index 97d58af..4a1d0c5 100644 --- a/test/emu/nosv/parallel-tasks.c +++ b/test/emu/nosv/parallel-tasks.c @@ -17,7 +17,7 @@ main(void) uint32_t typeid = 100; uint32_t taskid = 200; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create_par(taskid, typeid); /* Create and run the tasks, one nested into another */ diff --git a/test/emu/nosv/pause.c b/test/emu/nosv/pause.c index 18d192e..4da3796 100644 --- a/test/emu/nosv/pause.c +++ b/test/emu/nosv/pause.c @@ -18,7 +18,7 @@ main(void) int us = 500; uint32_t typeid = 1; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); instr_nosv_task_execute(1, 0); sleep_us(us); diff --git a/test/emu/nosv/switch-same-type.c b/test/emu/nosv/switch-same-type.c index 85f4237..ab629cf 100644 --- a/test/emu/nosv/switch-same-type.c +++ b/test/emu/nosv/switch-same-type.c @@ -19,7 +19,7 @@ main(void) instr_nosv_init(); uint32_t typeid = 100; - uint32_t gid = instr_nosv_type_create(typeid); + uint32_t gid = instr_nosv_type_create((int32_t) typeid); /* Create two tasks of the same type */ instr_nosv_task_create(1, typeid); diff --git a/test/emu/nosv/task-pause-from-submit.c b/test/emu/nosv/task-pause-from-submit.c index da9d642..b3256f6 100644 --- a/test/emu/nosv/task-pause-from-submit.c +++ b/test/emu/nosv/task-pause-from-submit.c @@ -30,7 +30,7 @@ main(void) die("fopen failed:"); uint32_t typeid = 100; - instr_nosv_type_create(typeid); + instr_nosv_type_create((int32_t) typeid); instr_nosv_task_create(1, typeid); diff --git a/test/emu/nosv/task-types.c b/test/emu/nosv/task-types.c index 5c6549c..d9f3d77 100644 --- a/test/emu/nosv/task-types.c +++ b/test/emu/nosv/task-types.c @@ -19,13 +19,13 @@ main(void) int ntypes = 10; for (int i = 0; i < ntypes; i++) - instr_nosv_type_create(i + 1); + instr_nosv_type_create((int32_t) i + 1); for (int i = 0; i < ntasks; i++) { - instr_nosv_task_create(i + 1, (i % ntypes) + 1); - instr_nosv_task_execute(i + 1, 0); + instr_nosv_task_create((uint32_t) i + 1, (uint32_t) ((i % ntypes) + 1)); + instr_nosv_task_execute((uint32_t) i + 1, 0); sleep_us(500); - instr_nosv_task_end(i + 1, 0); + instr_nosv_task_end((uint32_t) i + 1, 0); } instr_end(); diff --git a/test/emu/ovni/clockgate.c b/test/emu/ovni/clockgate.c index 05b5033..66ed98e 100644 --- a/test/emu/ovni/clockgate.c +++ b/test/emu/ovni/clockgate.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 @@ -17,7 +17,7 @@ thread_execute_delayed(int32_t cpu, int32_t creator_tid, uint64_t tag) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OHx"); - ovni_ev_set_clock(&ev, ovni_clock_now() + delta); + ovni_ev_set_clock(&ev, ovni_clock_now() + (uint64_t) delta); ovni_payload_add(&ev, (uint8_t *) &cpu, sizeof(cpu)); ovni_payload_add(&ev, (uint8_t *) &creator_tid, sizeof(creator_tid)); ovni_payload_add(&ev, (uint8_t *) &tag, sizeof(tag)); @@ -50,7 +50,7 @@ start_delayed(int rank, int nranks) dbg("thread %d has cpu %d (ncpus=%d)", get_tid(), curcpu, nranks); - delta = ((int64_t) rank) * 2LL * 3600LL * 1000LL * 1000LL * 1000LL; + delta = ((int64_t) rank) * (int64_t) (2LL * 3600LL * 1000LL * 1000LL * 1000LL); thread_execute_delayed(curcpu, -1, 0); } diff --git a/test/emu/ovni/empty-sort.c b/test/emu/ovni/empty-sort.c index 72c5536..4c220bb 100644 --- a/test/emu/ovni/empty-sort.c +++ b/test/emu/ovni/empty-sort.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 @@ -11,7 +11,7 @@ emit(char *mcv, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, mcv); - ovni_ev_set_clock(&ev, clock); + ovni_ev_set_clock(&ev, (uint64_t) clock); ovni_ev_emit(&ev); } @@ -23,7 +23,7 @@ main(void) /* Leave some room to prevent clashes */ sleep_us(100); /* 100000 us */ - int64_t t0 = ovni_clock_now(); + int64_t t0 = (int64_t) ovni_clock_now(); emit("OU[", t0); @@ -33,7 +33,7 @@ main(void) t += 33; } - emit("OU]", ovni_clock_now()); + emit("OU]", (int64_t) ovni_clock_now()); instr_end(); diff --git a/test/emu/ovni/flush-overhead.c b/test/emu/ovni/flush-overhead.c index 6d07c9c..bc0131f 100644 --- a/test/emu/ovni/flush-overhead.c +++ b/test/emu/ovni/flush-overhead.c @@ -13,7 +13,7 @@ emit(uint8_t *buf, size_t size) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OB."); ovni_ev_set_clock(&ev, ovni_clock_now()); - ovni_ev_jumbo_emit(&ev, buf, size); + ovni_ev_jumbo_emit(&ev, buf, (uint32_t) size); } #define NRUNS 50 diff --git a/test/emu/ovni/flush-tmpdir.c b/test/emu/ovni/flush-tmpdir.c index 6fd404f..383b105 100644 --- a/test/emu/ovni/flush-tmpdir.c +++ b/test/emu/ovni/flush-tmpdir.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 @@ -13,7 +13,7 @@ emit(uint8_t *buf, size_t size) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OB."); ovni_ev_set_clock(&ev, ovni_clock_now()); - ovni_ev_jumbo_emit(&ev, buf, size); + ovni_ev_jumbo_emit(&ev, buf, (uint32_t) size); } /* Test that we can flush the stream when we are working with a different tmpdir diff --git a/test/emu/ovni/flush.c b/test/emu/ovni/flush.c index 4883684..0530082 100644 --- a/test/emu/ovni/flush.c +++ b/test/emu/ovni/flush.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 @@ -13,7 +13,7 @@ emit(uint8_t *buf, size_t size) struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OB."); ovni_ev_set_clock(&ev, ovni_clock_now()); - ovni_ev_jumbo_emit(&ev, buf, size); + ovni_ev_jumbo_emit(&ev, buf, (uint32_t) size); } int diff --git a/test/emu/ovni/libovni-mark.c b/test/emu/ovni/libovni-mark.c index 7f62346..fddc392 100644 --- a/test/emu/ovni/libovni-mark.c +++ b/test/emu/ovni/libovni-mark.c @@ -29,7 +29,7 @@ main(void) instr_start(rank, nranks); /* Deterministic rand() */ - srand(100 + rank); + srand(100U + (unsigned) rank); /* Test set without labels */ diff --git a/test/emu/ovni/sort-first-and-full-ring.c b/test/emu/ovni/sort-first-and-full-ring.c index e2d7140..80ee014 100644 --- a/test/emu/ovni/sort-first-and-full-ring.c +++ b/test/emu/ovni/sort-first-and-full-ring.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 @@ -30,7 +30,7 @@ emit(char *mcv, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, mcv); - ovni_ev_set_clock(&ev, clock); + ovni_ev_set_clock(&ev, (uint64_t) clock); ovni_ev_emit(&ev); } @@ -39,12 +39,12 @@ main(void) { init(); - int64_t t0 = ovni_clock_now(); + int64_t t0 = (int64_t) ovni_clock_now(); /* Leave some room to prevent clashes */ sleep_us(100000); /* 100000000 ns */ - int64_t t1 = ovni_clock_now(); + int64_t t1 = (int64_t) ovni_clock_now(); emit("OU[", t1); @@ -64,7 +64,7 @@ main(void) t += 33; } - emit("OU]", ovni_clock_now()); + emit("OU]", (int64_t) ovni_clock_now()); ovni_flush(); ovni_proc_fini(); diff --git a/test/emu/ovni/sort-flush.c b/test/emu/ovni/sort-flush.c index 7c3bf07..5de23a8 100644 --- a/test/emu/ovni/sort-flush.c +++ b/test/emu/ovni/sort-flush.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 @@ -12,8 +12,8 @@ emit_jumbo(uint8_t *buf, size_t size, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OUj"); - ovni_ev_set_clock(&ev, clock); - ovni_ev_jumbo_emit(&ev, buf, size); + ovni_ev_set_clock(&ev, (uint64_t) clock); + ovni_ev_jumbo_emit(&ev, buf, (uint32_t) size); } static void @@ -21,7 +21,7 @@ emit(char *mcv, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, mcv); - ovni_ev_set_clock(&ev, clock); + ovni_ev_set_clock(&ev, (uint64_t) clock); ovni_ev_emit(&ev); } @@ -37,11 +37,11 @@ fill(long room) /* Skip the jumbo event header and payload size */ size_t header = ev_size + 4; - size_t payload_size = OVNI_MAX_EV_BUF - room - header; + size_t payload_size = (size_t) OVNI_MAX_EV_BUF - (size_t) room - header; uint8_t *payload_buf = calloc(1, payload_size); /* Fill the stream buffer */ - int64_t t = ovni_clock_now(); + int64_t t = (int64_t) ovni_clock_now(); emit_jumbo(payload_buf, payload_size, t); /* Leave some room to prevent clashes */ @@ -70,9 +70,9 @@ test_flush_after_sort(void) */ /* Skip the two flush events and leave room for OU[ */ - fill(3 * sizeof(struct ovni_ev_header)); + fill(3 * (long) sizeof(struct ovni_ev_header)); - int64_t t = ovni_clock_now(); + int64_t t = (int64_t) ovni_clock_now(); /* Emit the opening of the sort region */ emit("OU[", t++); @@ -85,7 +85,7 @@ test_flush_after_sort(void) emit("KCI", t++ - 100); /* Finish the sort region */ - emit("OU]", ovni_clock_now()); + emit("OU]", (int64_t) ovni_clock_now()); } static void @@ -94,7 +94,7 @@ test_unsorted(void) /* Test unsorted events in the sorting region */ sleep_us(100); /* Make room */ - int64_t t = ovni_clock_now(); + int64_t t = (int64_t) ovni_clock_now(); emit("OU[", t); emit("KCI", t + 2 - 100); /* out of order */ emit("KCO", t + 1 - 100); @@ -106,7 +106,7 @@ test_overlap(void) { /* Test overlapping events among regions */ - int64_t t = ovni_clock_now(); + int64_t t = (int64_t) ovni_clock_now(); /* Round time next 1 microsecond to be easier to read */ t += 1000 - (t % 1000); @@ -127,8 +127,8 @@ test_overlap_flush(void) /* Skip the two flush events and leave room for OU[ */ sleep_us(100); - fill(5 * sizeof(struct ovni_ev_header)); - int64_t t = ovni_clock_now(); + fill(5 * (long) sizeof(struct ovni_ev_header)); + int64_t t = (int64_t) ovni_clock_now(); /* Round time next 1 microsecond to be easier to read */ t += 1000 - (t % 1000); @@ -138,11 +138,11 @@ test_overlap_flush(void) emit("KCI", t + 11); emit("OU]", t + 21); /* We need realistic clock due to incoming flush */ - emit("OU[", ovni_clock_now()); + emit("OU[", (int64_t) ovni_clock_now()); /* Flush here */ emit("KCO", t + 12); emit("KCI", t + 13); - emit("OU]", ovni_clock_now()); + emit("OU]", (int64_t) ovni_clock_now()); } int diff --git a/test/emu/ovni/sort.c b/test/emu/ovni/sort.c index 67242d5..53126d5 100644 --- a/test/emu/ovni/sort.c +++ b/test/emu/ovni/sort.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 @@ -12,8 +12,8 @@ emit_jumbo(uint8_t *buf, size_t size, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, "OUj"); - ovni_ev_set_clock(&ev, clock); - ovni_ev_jumbo_emit(&ev, buf, size); + ovni_ev_set_clock(&ev, (uint64_t) clock); + ovni_ev_jumbo_emit(&ev, buf, (uint32_t) size); } static void @@ -21,7 +21,7 @@ emit(char *mcv, int64_t clock) { struct ovni_ev ev = {0}; ovni_ev_set_mcv(&ev, mcv); - ovni_ev_set_clock(&ev, clock); + ovni_ev_set_clock(&ev, (uint64_t) clock); ovni_ev_emit(&ev); } @@ -36,7 +36,7 @@ main(void) /* Leave some room to prevent clashes */ sleep_us(100); /* 100000 us */ - int64_t t0 = ovni_clock_now(); + int64_t t0 = (int64_t) ovni_clock_now(); emit("OU[", t0); @@ -48,7 +48,7 @@ main(void) /* Also test jumbo events */ for (int i = 0; i < BUFSIZE; i++) - buf[i] = i & 0xff; + buf[i] = (uint8_t) (i & 0xff); emit_jumbo(buf, BUFSIZE, t); @@ -56,7 +56,7 @@ main(void) while ((int64_t) ovni_clock_now() < t) sleep_us(10); - emit("OU]", ovni_clock_now()); + emit("OU]", (int64_t) ovni_clock_now()); instr_end(); diff --git a/test/rt/nanos6/sched-add.c b/test/rt/nanos6/sched-add.c index a6b5518..c491485 100644 --- a/test/rt/nanos6/sched-add.c +++ b/test/rt/nanos6/sched-add.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 @@ -31,7 +31,7 @@ do_task(int t) static void do_run(void) { - memset(handle, 0, ntasks * sizeof(void *)); + memset(handle, 0, (size_t) ntasks * sizeof(void *)); atomic_store(&nhandles, 0); for (int t = 0; t < ntasks; t++) @@ -63,7 +63,7 @@ main(void) { ncpus = get_ncpus(); - handle = calloc(ntasks, sizeof(void *)); + handle = calloc((size_t) ntasks, sizeof(void *)); if (handle == NULL) { perror("calloc failed"); diff --git a/test/rt/nodes/heat-mark.c b/test/rt/nodes/heat-mark.c index ef40726..698b9d7 100644 --- a/test/rt/nodes/heat-mark.c +++ b/test/rt/nodes/heat-mark.c @@ -93,7 +93,7 @@ static void reset(double *matrix) { /* Set all elements to zero */ - memset(matrix, 0, rows * cols * sizeof(double)); + memset(matrix, 0, (size_t) rows * (size_t) cols * sizeof(double)); /* Set the left side to 1.0 */ for (long i = 0; i < rows; i++) @@ -128,7 +128,9 @@ main(void) die("cannot read pagesize"); double *matrix; - int err = posix_memalign((void **) &matrix, pagesize, rows * cols * sizeof(double)); + int err = posix_memalign((void **) &matrix, (size_t) pagesize, + (size_t) rows * (size_t) cols * sizeof(double)); + if (err || matrix == NULL) die("posix_memalign failed:"); diff --git a/test/rt/openmp/taskloop.c b/test/rt/openmp/taskloop.c index 8a10d6e..648bf0c 100644 --- a/test/rt/openmp/taskloop.c +++ b/test/rt/openmp/taskloop.c @@ -5,12 +5,16 @@ int main(void) #pragma omp parallel #pragma omp single { +/* Broken clang: https://github.com/llvm/llvm-project/issues/100536 */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wconversion" #pragma omp taskloop for (int i = 0; i < 10000; i++) { #pragma omp task sleep_us(1); } +#pragma clang diagnostic pop } return 0; diff --git a/test/unit/sort_replace.c b/test/unit/sort_replace.c index 6872b33..dc8459b 100644 --- a/test/unit/sort_replace.c +++ b/test/unit/sort_replace.c @@ -30,8 +30,8 @@ cmp_int64(const void *a, const void *b) static void test_case(int64_t n, int64_t run) { - srand(run); - int64_t *arr = calloc(n, sizeof(int64_t)); + srand((unsigned) run); + int64_t *arr = calloc((size_t) n, sizeof(int64_t)); if (arr == NULL) die("calloc failed:"); @@ -39,14 +39,14 @@ test_case(int64_t n, int64_t run) for (int64_t i = 0; i < n; i++) arr[i] = randint(); - qsort(arr, n, sizeof(int64_t), cmp_int64); + qsort(arr, (size_t) n, sizeof(int64_t), cmp_int64); - int64_t *copy = calloc(n, sizeof(int64_t)); + int64_t *copy = calloc((size_t) n, sizeof(int64_t)); if (copy == NULL) die("calloc failed:"); - memcpy(copy, arr, n * sizeof(int64_t)); + memcpy(copy, arr, (size_t) n * sizeof(int64_t)); int64_t iold = rand() % n; int64_t old = arr[iold]; @@ -68,7 +68,7 @@ test_case(int64_t n, int64_t run) sort_replace(arr, n, old, new); copy[iold] = new; - qsort(copy, n, sizeof(int64_t), cmp_int64); + qsort(copy, (size_t) n, sizeof(int64_t), cmp_int64); dbg("Contents after sort: "); for (int64_t i = 0; i < n; i++) { @@ -76,7 +76,7 @@ test_case(int64_t n, int64_t run) i, arr[i], copy[i]); } - if (memcmp(arr, copy, n * sizeof(int64_t)) == 0) + if (memcmp(arr, copy, (size_t) n * sizeof(int64_t)) == 0) return; die("mismatch");