Skip to content

Commit

Permalink
Use io->Oxff instead of 0xff in all the io plugins ##io
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Mar 2, 2025
1 parent 331d086 commit 5013278
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion libr/io/io_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ R_IPI bool io_memory_resize(RIO *io, RIODesc *fd, ut64 count) {

R_IPI int io_memory_read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
R_RETURN_VAL_IF_FAIL (io && fd && buf, -1);
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
if (!fd->data) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_bochs.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
}

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
ut64 addr = io->off;
if (!desc || !desc->data) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_dsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static int r_io_posix_open(const char *file, int perm, int mode, bool nocache) {
static int dsc_object_read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
R_RETURN_VAL_IF_FAIL (fd && fd->data && buf, -1);
if (io->off == UT64_MAX) {
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
return count;
}
RIODscObject *dsc = fd->data;
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_gdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
if (!io || !fd || !buf || count < 1) {
return -1;
}
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
ut64 addr = io->off;
if (!desc || !desc->data) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_gzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static bool __resize(RIO *io, RIODesc *fd, ut64 count) {
}

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
if (!fd || !fd->data) {
return -1;
}
Expand Down
10 changes: 5 additions & 5 deletions libr/io/p/io_mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
if (dd ->magic != r_str_hash ("mach")) {
return -1;
}
memset (buf, 0xff, len);
memset (buf, io->Oxff, len);
int pid = __get_pid (desc);
task_t task = pid_to_task (desc, pid);
if (task_is_dead (desc, pid)) {
Expand All @@ -260,25 +260,25 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
break;
case KERN_INVALID_ADDRESS:
if (blocksize == 1) {
memset (buf+copied, 0xff, len-copied);
memset (buf+copied, io->Oxff, len-copied);
return size+copied;
}
blocksize = 1;
blen = 1;
buf[copied] = 0xff;
buf[copied] = io->Oxff;
break;
}
if (err == -1 || size < 1) {
return -1;
}
if (size == 0) {
if (blocksize == 1) {
memset (buf + copied, 0xff, len - copied);
memset (buf + copied, io->Oxff, len - copied);
return len;
}
blocksize = 1;
blen = 1;
buf[copied] = 0xff;
buf[copied] = io->Oxff;
}
copied += blen;
}
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_procpid.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int debug_os_read_at(int fdn, void *buf, int sz, ut64 addr) {
}

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int len) {
memset (buf, 0xff, len); // TODO: only memset the non-readed bytes
memset (buf, io->Oxff, len); // TODO: only memset the non-readed bytes
return debug_os_read_at (RIOPROCPID_FD (fd), buf, len, io->off);
}

Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_qnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
}

static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
ut64 addr = io->off;
if (!desc) {
return -1;
Expand Down
8 changes: 4 additions & 4 deletions libr/io/p/io_r2k.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* io_r2k - radare2 - LGPL - Copyright 2016-2024 - SkUaTeR + panda */
/* io_r2k - radare2 - LGPL - Copyright 2016-2025 - pancake, SkUaTeR, panda */

#include <r_io.h>
#include <r_lib.h>
Expand Down Expand Up @@ -49,12 +49,12 @@ static int r2k__read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
return ReadMemory (io, fd, IOCTL_READ_PHYSICAL_ADDR, r2k_struct.pid, io->off, buf, count);
default:
R_LOG_ERROR ("Undefined beid in r2k__read");
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
return count;
}
#else
R_LOG_TODO ("r2k not implemented for this plataform");
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
return count;
#endif
}
Expand Down Expand Up @@ -135,7 +135,7 @@ static RIODesc *r2k__open(RIO *io, const char *pathname, int rw, int mode) {
RIOPlugin r_io_plugin_r2k = {
.meta = {
.name = "r2k",
.desc = "Kernel access API io",
.desc = "Client side to comunicate with the r2k kernel module",
.author = "skuater,panda",
.license = "LGPL-3.0-only",
},
Expand Down
5 changes: 2 additions & 3 deletions libr/io/p/io_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int len) {
return -1;
}
int left = arena->size - io->off;
memset (buf, 0xff, len);
memset (buf, io->Oxff, len);
memcpy (buf, arena->bytes + io->off, R_MIN (left, len));
return len;
}
Expand Down Expand Up @@ -76,9 +76,8 @@ static ut64 __lseek(RIO *io, RIODesc *fd, ut64 offset, int whence) {
case R_IO_SEEK_SET:
if (offset >= size) {
return size;
} else {
return offset;
}
return offset;
case R_IO_SEEK_CUR:
return io->off + offset;
case R_IO_SEEK_END:
Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_self.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
return newlen;
}
}
memset (buf, 0xff, len);
memset (buf, io->Oxff, len);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion libr/io/p/io_sysgdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
left = count - 1024;
count = 1024;
}
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
if (count > 0) {
char *cmd = r_str_newf ("x/%db 0x%"PFMT64x, count, addr);
char *ores = runcmd (cmd);
Expand Down
4 changes: 2 additions & 2 deletions libr/io/p/io_winedbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Wine-dbg>
int wordSize = 4;
ut32 *w = (ut32*)buf;
int i;
memset (buf, 0xff, count);
memset (buf, io->Oxff, count);
int words = count / wordSize; // XXX must pad align to 4
for (i = 0; i < words ; i++) {
ut64 addr = io->off + (i * wordSize);
Expand All @@ -116,7 +116,7 @@ Wine-dbg>

int left = count % wordSize;
if (left > 0) {
ut32 n = 0xff;
ut32 n = UT32_MAX;
ut8 *wn = (ut8*)&n;
ut64 addr = io->off + (i * wordSize);
char *cmd = r_str_newf ("x 0x%"PFMT64x, addr);
Expand Down
2 changes: 1 addition & 1 deletion libr/io/undo.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ R_API void r_io_wundo_new(RIO *io, ut64 off, const ut8 *data, int len) {
R_FREE (uw);
return;
}
memset (uw->o, 0xff, len);
memset (uw->o, io->Oxff, len);
r_io_read_at (io, off, uw->o, len);
r_list_append (io->undo.w_list, uw);
}
Expand Down

0 comments on commit 5013278

Please sign in to comment.