From: Denys Vlasenko Date: Sat, 21 Mar 2015 18:50:53 +0000 (+0100) Subject: Change last parameter of umoven() from char* to void* X-Git-Tag: v4.11~556 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e69ed98cdd3c8ee0bba783927bc95b895c60160;p=strace Change last parameter of umoven() from char* to void* Saves tons of casts. Signed-off-by: Denys Vlasenko --- diff --git a/capability.c b/capability.c index bbd5544a..26d9c66a 100644 --- a/capability.c +++ b/capability.c @@ -103,7 +103,7 @@ print_cap_data(struct tcb *tcp, unsigned long addr, const cap_user_header_t h) else len = 1; - if (umoven(tcp, addr, len * sizeof(data[0]), (char *) data) < 0) { + if (umoven(tcp, addr, len * sizeof(data[0]), data) < 0) { tprintf("%#lx", addr); return; } diff --git a/defs.h b/defs.h index 14e46535..4f6bbd96 100644 --- a/defs.h +++ b/defs.h @@ -419,9 +419,9 @@ extern void clear_regs(void); extern void get_regs(pid_t pid); extern int get_scno(struct tcb *tcp); -extern int umoven(struct tcb *, long, unsigned int, char *); +extern int umoven(struct tcb *, long, unsigned int, void *); #define umove(pid, addr, objp) \ - umoven((pid), (addr), sizeof(*(objp)), (char *) (objp)) + umoven((pid), (addr), sizeof(*(objp)), (void *) (objp)) extern int umovestr(struct tcb *, long, unsigned int, char *); extern int upeek(int pid, long, long *); #if defined(SPARC) || defined(SPARC64) || defined(IA64) || defined(SH) diff --git a/desc.c b/desc.c index 24de51de..485c802b 100644 --- a/desc.c +++ b/desc.c @@ -353,7 +353,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) tprintf(", %#lx", arg); continue; } - if (umoven(tcp, arg, fdsize, (char *) fds) < 0) { + if (umoven(tcp, arg, fdsize, fds) < 0) { tprints(", [?]"); continue; } @@ -397,7 +397,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness) int first = 1; arg = args[i+1]; - if (!arg || umoven(tcp, arg, fdsize, (char *) fds) < 0) + if (!arg || umoven(tcp, arg, fdsize, fds) < 0) continue; for (j = 0;; j++) { j = next_set_bit(fds, j, nfds); @@ -445,7 +445,7 @@ sys_oldselect(struct tcb *tcp) { long args[5]; - if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) { + if (umoven(tcp, tcp->u_arg[0], sizeof args, args) < 0) { tprints("[...]"); return 0; } diff --git a/io.c b/io.c index 3626c776..06185096 100644 --- a/io.c +++ b/io.c @@ -112,7 +112,7 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, int deco tprints("..."); break; } - if (umoven(tcp, cur, sizeof_iov, (char *) &iov) < 0) { + if (umoven(tcp, cur, sizeof_iov, &iov) < 0) { tprints("?"); failed = 1; break; diff --git a/kexec.c b/kexec.c index e277668d..6bec51c9 100644 --- a/kexec.c +++ b/kexec.c @@ -58,8 +58,7 @@ print_kexec_segments(struct tcb *tcp, unsigned long addr, unsigned long len) for (i = 0; i < len; ++i) { if (i) tprints(", "); - if (umoven(tcp, addr + i * sizeof_seg, sizeof_seg, - (char *) &seg) < 0) { + if (umoven(tcp, addr + i * sizeof_seg, sizeof_seg, &seg) < 0) { tprints("?"); failed = 1; break; diff --git a/mem.c b/mem.c index 5e1822fb..41d90ec8 100644 --- a/mem.c +++ b/mem.c @@ -106,7 +106,7 @@ sys_old_mmap(struct tcb *tcp) */ int i; unsigned narrow_arg[6]; - if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) + if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1) return 0; for (i = 0; i < 6; i++) u_arg[i] = (unsigned long) narrow_arg[i]; @@ -114,12 +114,12 @@ sys_old_mmap(struct tcb *tcp) /* We are here only in personality 1 (i386) */ int i; unsigned narrow_arg[6]; - if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) + if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1) return 0; for (i = 0; i < 6; ++i) u_arg[i] = (unsigned long) narrow_arg[i]; #else - if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1) + if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), u_arg) == -1) return 0; #endif return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); @@ -134,7 +134,7 @@ sys_old_mmap_pgoff(struct tcb *tcp) int i; unsigned narrow_arg[6]; unsigned long long offset; - if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) + if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1) return 0; for (i = 0; i < 5; i++) u_arg[i] = (unsigned long) narrow_arg[i]; @@ -362,7 +362,7 @@ get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err) tprints("..."); break; } - if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { + if (umoven(tcp, cur, sizeof(n), &n) < 0) { tprints("?"); failed = 1; break; diff --git a/net.c b/net.c index cb29faad..276fc607 100644 --- a/net.c +++ b/net.c @@ -1071,7 +1071,7 @@ do_pipe(struct tcb *tcp, int flags_arg) #if !defined(SPARC) && !defined(SPARC64) && !defined(SH) && !defined(IA64) int fds[2]; - if (umoven(tcp, tcp->u_arg[0], sizeof fds, (char *) fds) < 0) + if (umoven(tcp, tcp->u_arg[0], sizeof fds, fds) < 0) tprints("[...]"); else tprintf("[%u, %u]", fds[0], fds[1]); @@ -1116,7 +1116,7 @@ sys_socketpair(struct tcb *tcp) tprintf(", %#lx", tcp->u_arg[3]); return 0; } - if (umoven(tcp, tcp->u_arg[3], sizeof fds, (char *) fds) < 0) + if (umoven(tcp, tcp->u_arg[3], sizeof fds, fds) < 0) tprints(", [...]"); else tprintf(", [%u, %u]", fds[0], fds[1]); diff --git a/pathtrace.c b/pathtrace.c index 28fc7c9a..0db7fe31 100644 --- a/pathtrace.c +++ b/pathtrace.c @@ -270,7 +270,7 @@ pathtrace_match(struct tcb *tcp) args = tcp->u_arg; if (s->sys_func == sys_oldselect) { if (umoven(tcp, tcp->u_arg[0], sizeof oldargs, - (char*) oldargs) < 0) + oldargs) < 0) { fprintf(stderr, "umoven() failed\n"); return 0; @@ -294,7 +294,7 @@ pathtrace_match(struct tcb *tcp) for (i = 1; i <= 3; ++i) { if (args[i] == 0) continue; - if (umoven(tcp, args[i], fdsize, (char *) fds) < 0) { + if (umoven(tcp, args[i], fdsize, fds) < 0) { fprintf(stderr, "umoven() failed\n"); continue; } @@ -328,7 +328,7 @@ pathtrace_match(struct tcb *tcp) return 0; for (cur = start; cur < end; cur += sizeof(fds)) - if ((umoven(tcp, cur, sizeof fds, (char *) &fds) == 0) + if ((umoven(tcp, cur, sizeof fds, &fds) == 0) && fdmatch(tcp, fds.fd)) return 1; diff --git a/scsi.c b/scsi.c index 867b74c0..73c97eac 100644 --- a/scsi.c +++ b/scsi.c @@ -53,7 +53,7 @@ print_sg_io_buffer(struct tcb *tcp, unsigned long addr, const unsigned int len) goto out; allocated = (len > max_strlen) ? max_strlen : len; if ((buf = malloc(allocated)) == NULL || - umoven(tcp, addr, allocated, (char *) buf) < 0) { + umoven(tcp, addr, allocated, buf) < 0) { tprintf("%#lx", addr); goto out; } diff --git a/sigreturn.c b/sigreturn.c index 365ef1ab..7a0dc062 100644 --- a/sigreturn.c +++ b/sigreturn.c @@ -138,7 +138,7 @@ sys_sigreturn(struct tcb *tcp) /* Fetch remaining words of signal mask, located immediately before. */ addr -= sizeof(mask) - sizeof(long); - if (umoven(tcp, addr, sizeof(mask) - sizeof(long), (char *) &mask[1]) < 0) + if (umoven(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]) < 0) return 0; tprints("{mask="); tprintsigmask_addr("", mask); diff --git a/sock.c b/sock.c index b6fc95c5..dc8febc1 100644 --- a/sock.c +++ b/sock.c @@ -256,7 +256,7 @@ sock_ioctl(struct tcb *tcp, const unsigned int code, long arg) struct ifreq ifra[nifra]; if (umoven(tcp, (unsigned long) ifc.ifc_buf, - sizeof(ifra), (char *) ifra) < 0) { + sizeof(ifra), ifra) < 0) { tprintf("%lx}", (unsigned long) ifc.ifc_buf); return 1; } diff --git a/stream.c b/stream.c index 2aa6366c..3ebbfb73 100644 --- a/stream.c +++ b/stream.c @@ -263,7 +263,7 @@ decode_poll(struct tcb *tcp, long pts) tprints("..."); break; } - if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) { + if (umoven(tcp, cur, sizeof fds, &fds) < 0) { tprints("?"); failed = 1; break; @@ -313,7 +313,7 @@ decode_poll(struct tcb *tcp, long pts) outptr = outstr; for (cur = start; cur < end; cur += sizeof(fds)) { - if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) { + if (umoven(tcp, cur, sizeof fds, &fds) < 0) { if (outptr < end_outstr - 2) *outptr++ = '?'; failed = 1; diff --git a/syscall.c b/syscall.c index 33b22ecc..e981a68c 100644 --- a/syscall.c +++ b/syscall.c @@ -1559,7 +1559,7 @@ get_syscall_args(struct tcb *tcp) for (i = 0; i < nargs; ++i) { if (umoven(tcp, (unsigned long) ia64_rse_skip_regs(out0, i), - sizeof(long), (char *) &tcp->u_arg[i]) < 0) + sizeof(long), &tcp->u_arg[i]) < 0) return -1; } } else { @@ -1601,7 +1601,7 @@ get_syscall_args(struct tcb *tcp) if (nargs > 4) { umoven(tcp, mips_REG_SP + 4 * 4, (nargs - 4) * sizeof(tcp->u_arg[0]), - (char *)(tcp->u_arg + 4)); + &tcp->u_arg[4]); } #elif defined(POWERPC) (void)i; diff --git a/sysctl.c b/sysctl.c index 70cc5d9a..a550edae 100644 --- a/sysctl.c +++ b/sysctl.c @@ -27,7 +27,7 @@ sys_sysctl(struct tcb *tcp) size = sizeof(int) * (unsigned long) info.nlen; name = (size / sizeof(int) != (unsigned long) info.nlen) ? NULL : malloc(size); if (name == NULL || - umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) { + umoven(tcp, (unsigned long) info.name, size, name) < 0) { free(name); if (entering(tcp)) tprintf("{%p, %d, %p, %p, %p, %lu}", diff --git a/uid.c b/uid.c index 1f8c3657..96b3d38f 100644 --- a/uid.c +++ b/uid.c @@ -183,7 +183,7 @@ sys_setgroups(struct tcb *tcp) tprints("..."); break; } - if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { + if (umoven(tcp, cur, sizeof(gid), &gid) < 0) { tprints("?"); failed = 1; break; @@ -242,7 +242,7 @@ sys_getgroups(struct tcb *tcp) tprints("..."); break; } - if (umoven(tcp, cur, sizeof(gid), (char *) &gid) < 0) { + if (umoven(tcp, cur, sizeof(gid), &gid) < 0) { tprints("?"); failed = 1; break; diff --git a/util.c b/util.c index 02c5b9aa..fd9053a5 100644 --- a/util.c +++ b/util.c @@ -835,7 +835,7 @@ dumpiov(struct tcb *tcp, int len, long addr) fprintf(stderr, "Out of memory\n"); return; } - if (umoven(tcp, addr, size, (char *) iov) >= 0) { + if (umoven(tcp, addr, size, iov) >= 0) { for (i = 0; i < len; i++) { /* include the buffer number to make it easy to * match up the trace with the source */ @@ -881,7 +881,7 @@ dumpstr(struct tcb *tcp, long addr, int len) strsize = len + 16; } - if (umoven(tcp, addr, len, (char *) str) < 0) + if (umoven(tcp, addr, len, str) < 0) return; /* Space-pad to 16 bytes */ @@ -966,11 +966,12 @@ static bool process_vm_readv_not_supported = 1; #define PAGMASK (~(PAGSIZ - 1)) /* * move `len' bytes of data from process `pid' - * at address `addr' to our space at `laddr' + * at address `addr' to our space at `our_addr' */ int -umoven(struct tcb *tcp, long addr, unsigned int len, char *laddr) +umoven(struct tcb *tcp, long addr, unsigned int len, void *our_addr) { + char *laddr = our_addr; int pid = tcp->pid; unsigned int n, m, nread; union { diff --git a/utime.c b/utime.c index 6e396b05..ba253567 100644 --- a/utime.c +++ b/utime.c @@ -19,7 +19,7 @@ sys_utime(struct tcb *tcp) tprints("NULL"); else if (!verbose(tcp)) tprintf("%#lx", tcp->u_arg[1]); - else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0) + else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, &u) < 0) tprints("[?, ?]"); else if (wordsize == sizeof u.utl[0]) { tprintf("[%s,", sprinttime(u.utl[0]));