Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation warnings on ioctl-echo-loop and Docker image #26

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt update && \
git \
protobuf-compiler \
rsync \
rust-all \
rust-all=1.58.1+dfsg1~ubuntu1-0ubuntu2 \
&& \
rm -rf /var/lib/apt/lists/*

Expand Down
4 changes: 2 additions & 2 deletions linux/rollup/ioctl-echo-loop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RVCXX = $(CROSS_COMPILE)g++
RVCOPY = $(CROSS_COMPILE)objcopy
RVDUMP = $(CROSS_COMPILE)objdump
STRIP = $(CROSS_COMPILE)strip
RISCV_CFLAGS :=-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)
CFLAGS :=-Wall -pedantic -O2 -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
Expand All @@ -42,7 +42,7 @@ extra.ext2: ioctl-echo-loop
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"

ioctl-echo-loop.toolchain:
$(RVCC) -O2 -o ioctl-echo-loop ioctl-echo-loop.c
$(RVCC) $(CFLAGS) -o ioctl-echo-loop ioctl-echo-loop.c
$(STRIP) ioctl-echo-loop

extra.ext2.toolchain:
Expand Down
42 changes: 25 additions & 17 deletions linux/rollup/ioctl-echo-loop/ioctl-echo-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

#include <linux/cartesi/rollup.h>

Expand Down Expand Up @@ -102,7 +104,8 @@ static int finish_request(int fd, struct rollup_finish *finish, bool accept) {
finish->accept_previous_request = accept;
res = ioctl(fd, IOCTL_ROLLUP_FINISH, (unsigned long) finish);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_FINISH returned error %d\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_FINISH returned error %s [%d]\n", strerror(code), code);
}
return res;
}
Expand Down Expand Up @@ -143,7 +146,8 @@ static int write_vouchers(int fd, unsigned count, struct rollup_bytes *bytes, ui
for (unsigned i = 0; i < count; i++) {
int res = ioctl(fd, IOCTL_ROLLUP_WRITE_VOUCHER, (unsigned long) &v);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_WRITE_VOUCHER returned error %d\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_WRITE_VOUCHER returned error %s [%d]\n", strerror(code), code);
return res;
}
if (verbose)
Expand All @@ -161,7 +165,8 @@ static int write_reports(int fd, unsigned count, struct rollup_bytes *bytes, uns
for (unsigned i = 0; i < count; i++) {
int res = ioctl(fd, IOCTL_ROLLUP_WRITE_REPORT, (unsigned long) &r);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_WRITE_REPORT returned error %d\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_WRITE_REPORT returned error %s [%d]\n", strerror(code), code);
return res;
}
}
Expand All @@ -176,7 +181,8 @@ static int write_exception(int fd, struct rollup_bytes *bytes, unsigned verbose)
show_exception(&e);
int res = ioctl(fd, IOCTL_ROLLUP_THROW_EXCEPTION, (unsigned long) &e);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_THROW_EXCEPTION returned error %d\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_THROW_EXCEPTION returned error %s [%d]\n", strerror(code), code);
return res;
}
return 0;
Expand All @@ -194,7 +200,8 @@ static int handle_advance_state_request(int fd, struct parsed_args *args, struct
req.payload.length = finish->next_request_payload_length;
res = ioctl(fd, IOCTL_ROLLUP_READ_ADVANCE_STATE, (unsigned long) &req);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_READ_ADVANCE_STATE returned error (%d)\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_READ_ADVANCE_STATE returned error %s [%d]\n", strerror(code), code);
return res;
}
*metadata = req.metadata;
Expand Down Expand Up @@ -227,7 +234,8 @@ static int handle_inspect_state_request(int fd, struct parsed_args *args, struct
show_inspect(&req);
res = ioctl(fd, IOCTL_ROLLUP_READ_INSPECT_STATE, (unsigned long) &req);
if (res != 0) {
fprintf(stderr, "IOCTL_ROLLUP_READ_INSPECT_STATE returned error (%d)\n", res);
int code = errno;
fprintf(stderr, "IOCTL_ROLLUP_READ_INSPECT_STATE returned error %s [%d]\n", strerror(code), code);
return res;
}
if (write_reports(fd, args->report_count, &req.payload, args->verbose) != 0) {
Expand Down Expand Up @@ -338,44 +346,44 @@ static void show_advance(struct rollup_advance_state *advance) {
printf("advance:\n"
"\tmsg_sender: ");
print_address(advance->metadata.msg_sender);
printf("\tblock_number: %lu\n"
"\ttimestamp: %lu\n"
"\tepoch_index: %lu\n"
"\tinput_index: %lu\n",
printf("\tblock_number: %llu\n"
"\ttimestamp: %llu\n"
"\tepoch_index: %llu\n"
"\tinput_index: %llu\n",
advance->metadata.block_number, advance->metadata.timestamp, advance->metadata.epoch_index,
advance->metadata.input_index);
}

static void show_inspect(struct rollup_inspect_state *inspect) {
printf("inspect:\n"
"\tlength: %lu\n",
"\tlength: %llu\n",
inspect->payload.length);
}

static void show_voucher(struct rollup_voucher *voucher) {
printf("voucher:\n"
"\tindex: %lu\n"
"\tlength: %lu\n"
"\tindex: %llu\n"
"\tlength: %llu\n"
"\tdestination: ",
voucher->index, voucher->payload.length);
print_address(voucher->destination);
}

static void show_notice(struct rollup_notice *notice) {
printf("notice:\n"
"\tindex: %lu\n"
"\tlength: %lu\n",
"\tindex: %llu\n"
"\tlength: %llu\n",
notice->index, notice->payload.length);
}

static void show_report(struct rollup_report *report) {
printf("report:\n"
"\tlength: %lu\n",
"\tlength: %llu\n",
report->payload.length);
}

static void show_exception(struct rollup_exception *exception) {
printf("exception:\n"
"\tlength: %lu\n",
"\tlength: %llu\n",
exception->payload.length);
}