Skip to content

Commit 626de5e

Browse files
committed
Enable Wextra & fix the fallout
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
1 parent 5d45e17 commit 626de5e

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

Makefile.vars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ LD = $(CROSS_COMPILE)ld
1616
CC = $(CROSS_COMPILE)gcc
1717
NM = $(CROSS_COMPILE)nm
1818
OBJCOPY = $(CROSS_COMPILE)objcopy
19-
CFLAGS ?= -g -Wall -O2 -m64 -std=gnu99
19+
CFLAGS ?= -g -Wall -Wextra -O2 -m64 -std=gnu99
2020
TESTCFLAGS += $(CFLAGS) -O0 -DTEST_ENVIRONMENT=1 -I src -I testobj -pthread

src/afu.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,12 @@ static ocxl_err afu_open(ocxl_afu *afu)
471471
return rc;
472472
}
473473

474-
if (metadata.version >= 0) {
475-
afu->version_major = metadata.afu_version_major;
476-
afu->version_minor = metadata.afu_version_minor;
477-
afu->per_pasid_mmio.length = metadata.pp_mmio_size;
478-
afu->global_mmio.length = metadata.global_mmio_size;
479-
afu->pasid = metadata.pasid;
480-
}
474+
// Metadata version 0, always available
475+
afu->version_major = metadata.afu_version_major;
476+
afu->version_minor = metadata.afu_version_minor;
477+
afu->per_pasid_mmio.length = metadata.pp_mmio_size;
478+
afu->global_mmio.length = metadata.global_mmio_size;
479+
afu->pasid = metadata.pasid;
481480

482481
if (afu->tracing) {
483482
trace_metadata(afu);
@@ -606,7 +605,7 @@ ocxl_err ocxl_afu_open_specific(const char *name, const char *physical_function,
606605
goto end;
607606
}
608607

609-
for (int dev = 0; dev < glob_data.gl_pathc; dev++) {
608+
for (size_t dev = 0; dev < glob_data.gl_pathc; dev++) {
610609
const char *dev_path = glob_data.gl_pathv[dev];
611610
ret = ocxl_afu_open_from_dev(dev_path, afu);
612611

@@ -661,7 +660,7 @@ ocxl_err ocxl_afu_open(const char *name, ocxl_afu_h *afu)
661660
* @retval OCXL_NO_CONTEXT if the AFU was not opened
662661
* @retval OCXL_INTERNAL_ERROR if the AFU was unable to attach (check dmesg)
663662
*/
664-
ocxl_err ocxl_afu_attach(ocxl_afu_h afu, uint64_t flags)
663+
ocxl_err ocxl_afu_attach(ocxl_afu_h afu, __attribute__((unused)) uint64_t flags)
665664
{
666665
ocxl_afu *my_afu = (ocxl_afu *) afu;
667666

src/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static ocxl_event_action read_afu_event(ocxl_afu_h afu, uint16_t event_api_versi
334334

335335
char buf[event_size];
336336

337-
int buf_used;
337+
ssize_t buf_used;
338338
if ((buf_used = read(my_afu->fd, buf, event_size)) < 0) {
339339
if (errno == EAGAIN || errno == EWOULDBLOCK) {
340340
*last = 1;
@@ -344,7 +344,7 @@ static ocxl_event_action read_afu_event(ocxl_afu_h afu, uint16_t event_api_versi
344344
errmsg(afu, OCXL_INTERNAL_ERROR, "read of event header from fd %d failed: %d: %s",
345345
my_afu->fd, errno, strerror(errno));
346346
return OCXL_EVENT_ACTION_FAIL;
347-
} else if (buf_used < sizeof(ocxl_kernel_event_header)) {
347+
} else if (buf_used < (ssize_t)sizeof(ocxl_kernel_event_header)) {
348348
errmsg(afu, OCXL_INTERNAL_ERROR, "short read of event header from fd %d", my_afu->fd);
349349
return OCXL_EVENT_ACTION_FAIL;
350350
}

src/mmio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ocxl_err global_mmio_open(ocxl_afu *afu)
9494
{
9595
char path[PATH_MAX + 1];
9696
int length = snprintf(path, sizeof(path), "%s/global_mmio_area", afu->sysfs_path);
97-
if (length >= sizeof(path)) {
97+
if (length >= (int)sizeof(path)) {
9898
ocxl_err rc = OCXL_NO_DEV;
9999
errmsg(afu, rc, "global MMIO path truncated");
100100
return rc;
@@ -211,7 +211,7 @@ static ocxl_err mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t flags, o
211211
return rc;
212212
}
213213

214-
void *addr = mmap(NULL, afu->per_pasid_mmio.length, prot, MAP_SHARED, afu->fd, 0);
214+
void *addr = mmap(NULL, afu->per_pasid_mmio.length, prot, MAP_SHARED, afu->fd, offset);
215215
if (addr == MAP_FAILED) {
216216
ocxl_err rc = OCXL_NO_MEM;
217217
errmsg(afu, rc, "Could not map per-PASID MMIO: %d: %s", errno, strerror(errno));
@@ -427,7 +427,7 @@ inline static ocxl_err mmio_check(ocxl_mmio_h region, off_t offset, size_t size)
427427
return rc;
428428
}
429429

430-
if (offset >= mmio->length - (size - 1)) {
430+
if (offset >= (off_t)(mmio->length - (size - 1))) {
431431
ocxl_err rc = OCXL_OUT_OF_BOUNDS;
432432
errmsg(mmio->afu, rc, "%s MMIO access of 0x%016lx exceeds limit of 0x%016lx",
433433
mmio->type == OCXL_GLOBAL_MMIO ? "Global" : "Per-PASID",

0 commit comments

Comments
 (0)