Skip to content

Commit

Permalink
refactor: discard unused variables using std::ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 17, 2024
1 parent cbc8631 commit 6889836
Show file tree
Hide file tree
Showing 38 changed files with 367 additions and 568 deletions.
5 changes: 2 additions & 3 deletions src/clint-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
namespace cartesi {

/// \brief CLINT device peek callback. See ::pma_peek.
static bool clint_peek(const pma_entry &pma, const machine &m, uint64_t page_offset, const unsigned char **page_data,
unsigned char * /*scratch*/) {
(void) m;
static bool clint_peek(const pma_entry &pma, const machine & /*m*/, uint64_t page_offset,
const unsigned char **page_data, unsigned char * /*scratch*/) {
*page_data = nullptr;
return (page_offset % PMA_PAGE_SIZE) == 0 && page_offset < pma.get_length();
}
Expand Down
8 changes: 2 additions & 6 deletions src/clint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ static bool clint_read_mtimecmp(i_device_state_access *a, uint64_t *val, int log
}

/// \brief CLINT device read callback. See ::pma_read.
static bool clint_read(void *context, i_device_state_access *a, uint64_t offset, uint64_t *val, int log2_size) {
(void) context;

static bool clint_read(void * /*context*/, i_device_state_access *a, uint64_t offset, uint64_t *val, int log2_size) {
switch (offset) {
case clint_msip0_rel_addr:
return clint_read_msip(a, val, log2_size);
Expand All @@ -78,10 +76,8 @@ static bool clint_read(void *context, i_device_state_access *a, uint64_t offset,
}

/// \brief CLINT device read callback. See ::pma_write.
static execute_status clint_write(void *context, i_device_state_access *a, uint64_t offset, uint64_t val,
static execute_status clint_write(void * /*context*/, i_device_state_access *a, uint64_t offset, uint64_t val,
int log2_size) {
(void) context;

switch (offset) {
case clint_msip0_rel_addr:
if (log2_size == 2) {
Expand Down
10 changes: 5 additions & 5 deletions src/clua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ static void fprint_str(FILE *out, const char *str, int max) {
int m = max;
for (i = 0; m > 0 && str[i]; ++i) {
if (isprint(str[i])) {
(void) fputc(str[i], out);
std::ignore = fputc(str[i], out);
m -= 1;
} else {
(void) fprintf(out, "\\0x%02x", static_cast<unsigned char>(str[i]));
std::ignore = fprintf(out, "\\0x%02x", static_cast<unsigned char>(str[i]));
m -= 5;
}
}
if (str[i]) {
(void) fprintf(out, "...");
std::ignore = fprintf(out, "...");
}
}

Expand All @@ -77,9 +77,9 @@ void clua_print(lua_State *L, int idx) {
lua_getglobal(L, "tostring");
lua_pushvalue(L, idx);
lua_call(L, 1, 1);
(void) fprintf(stderr, "%02d: ", idx);
std::ignore = fprintf(stderr, "%02d: ", idx);
fprint_str(stderr, lua_tostring(L, -1), 68);
(void) fputc('\n', stderr);
std::ignore = fputc('\n', stderr);
lua_pop(L, 1);
}

Expand Down
5 changes: 2 additions & 3 deletions src/htif-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
namespace cartesi {

/// \brief HTIF device peek callback. See ::pma_peek.
static bool htif_peek(const pma_entry &pma, const machine &m, uint64_t page_offset, const unsigned char **page_data,
unsigned char * /*scratch*/) {
(void) m;
static bool htif_peek(const pma_entry &pma, const machine & /*m*/, uint64_t page_offset,
const unsigned char **page_data, unsigned char * /*scratch*/) {
*page_data = nullptr;
return (page_offset % PMA_PAGE_SIZE) == 0 && page_offset < pma.get_length();
}
Expand Down
8 changes: 2 additions & 6 deletions src/htif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ static constexpr auto htif_iconsole_rel_addr = static_cast<uint64_t>(htif_csr::i
static constexpr auto htif_iyield_rel_addr = static_cast<uint64_t>(htif_csr::iyield);

/// \brief HTIF device read callback. See ::pma_read.
static bool htif_read(void *context, i_device_state_access *a, uint64_t offset, uint64_t *pval, int log2_size) {
(void) context;

static bool htif_read(void * /*context*/, i_device_state_access *a, uint64_t offset, uint64_t *pval, int log2_size) {
// Our HTIF only supports 64-bit reads
if (log2_size != 3) {
return false;
Expand Down Expand Up @@ -64,7 +62,6 @@ static bool htif_read(void *context, i_device_state_access *a, uint64_t offset,
}

static execute_status htif_halt(i_device_state_access *a, uint64_t cmd, uint64_t data) {
(void) a;
if (cmd == HTIF_HALT_CMD_HALT && ((data & 1) != 0)) {
a->set_iflags_H();
return execute_status::success_and_halt;
Expand All @@ -74,8 +71,7 @@ static execute_status htif_halt(i_device_state_access *a, uint64_t cmd, uint64_t
return execute_status::success;
}

static execute_status htif_yield(i_device_state_access *a, uint64_t cmd, uint64_t data) {
(void) data;
static execute_status htif_yield(i_device_state_access *a, uint64_t cmd, uint64_t /*data*/) {
execute_status status = execute_status::success;
// If yield command is enabled, yield and acknowledge
if (cmd < 64 && (((a->read_htif_iyield() >> cmd) & 1) != 0)) {
Expand Down
Loading

0 comments on commit 6889836

Please sign in to comment.