# define clear_regs() ((void)0)
# define get_regs(pid) ((void)0)
#endif
-extern int umoven(struct tcb *, long, int, char *);
+extern int umoven(struct tcb *, long, unsigned int, char *);
#define umove(pid, addr, objp) \
umoven((pid), (addr), sizeof(*(objp)), (char *) (objp))
-extern int umovestr(struct tcb *, long, int, char *);
+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)
extern long getrval2(struct tcb *);
* at address `addr' to our space at `laddr'
*/
int
-umoven(struct tcb *tcp, long addr, int len, char *laddr)
+umoven(struct tcb *tcp, long addr, unsigned int len, char *laddr)
{
int pid = tcp->pid;
- int n, m, nread;
+ unsigned int n, m, nread;
union {
long val;
char x[sizeof(long)];
remote[0].iov_base = (void*)addr;
local[0].iov_len = remote[0].iov_len = len;
r = process_vm_readv(pid, local, 1, remote, 1, 0);
- if (r == len)
+ if ((unsigned int) r == len)
return 0;
if (r >= 0) {
- error_msg("umoven: short read (%d < %d) @0x%lx",
- r, len, addr);
+ error_msg("umoven: short read (%u < %u) @0x%lx",
+ (unsigned int) r, len, addr);
return -1;
}
switch (errno) {
nread = 0;
if (addr & (sizeof(long) - 1)) {
/* addr not a multiple of sizeof(long) */
- n = addr - (addr & -sizeof(long)); /* residue */
- addr &= -sizeof(long); /* residue */
+ n = addr & (sizeof(long) - 1); /* residue */
+ addr &= -sizeof(long); /* aligned address */
errno = 0;
u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
switch (errno) {
case EFAULT: case EIO: case EPERM:
/* address space is inaccessible */
if (nread) {
- perror_msg("umoven: short read (%d < %d) @0x%lx",
+ perror_msg("umoven: short read (%u < %u) @0x%lx",
nread, nread + len, addr - nread);
}
return -1;
* we never write past laddr[len-1]).
*/
int
-umovestr(struct tcb *tcp, long addr, int len, char *laddr)
+umovestr(struct tcb *tcp, long addr, unsigned int len, char *laddr)
{
#if SIZEOF_LONG == 4
const unsigned long x01010101 = 0x01010101ul;
#endif
int pid = tcp->pid;
- int n, m, nread;
+ unsigned int n, m, nread;
union {
unsigned long val;
char x[sizeof(long)];
remote[0].iov_base = (void*)addr;
while (len > 0) {
- int end_in_page;
+ unsigned int chunk_len;
+ unsigned int end_in_page;
int r;
- int chunk_len;
/* Don't read kilobytes: most strings are short */
chunk_len = len;
* (I hope there aren't arches with pages < 4K)
*/
end_in_page = ((addr + chunk_len) & 4095);
- r = chunk_len - end_in_page;
- if (r > 0) /* if chunk_len > end_in_page */
- chunk_len = r; /* chunk_len -= end_in_page */
+ if (chunk_len > end_in_page) /* crosses to the next page */
+ chunk_len -= end_in_page;
local[0].iov_len = remote[0].iov_len = chunk_len;
r = process_vm_readv(pid, local, 1, remote, 1, 0);
if (addr & (sizeof(long) - 1)) {
/* addr not a multiple of sizeof(long) */
- n = addr - (addr & -sizeof(long)); /* residue */
- addr &= -sizeof(long); /* residue */
+ n = addr & (sizeof(long) - 1); /* residue */
+ addr &= -sizeof(long); /* aligned address */
errno = 0;
u.val = ptrace(PTRACE_PEEKDATA, pid, (char *)addr, 0);
switch (errno) {