affinity.c: use printaddr and umove_or_printaddr
* affinity.c (print_affinitylist): Use printaddr and umove_or_printaddr. (sys_sched_getaffinity): Remove redundant u_rval check.
This commit is contained in:
parent
07eaf50848
commit
a52375f748
58
affinity.c
58
affinity.c
@ -1,35 +1,40 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_affinitylist(struct tcb *tcp, long list, unsigned int len)
|
print_affinitylist(struct tcb *tcp, const unsigned long addr, const unsigned int len)
|
||||||
{
|
{
|
||||||
int first = 1;
|
unsigned long w;
|
||||||
unsigned long w, min_len;
|
const unsigned int size = len * sizeof(w);
|
||||||
|
const unsigned long end = addr + size;
|
||||||
|
unsigned long cur, abbrev_end;
|
||||||
|
|
||||||
if (abbrev(tcp) && len / sizeof(w) > max_strlen)
|
if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
|
||||||
min_len = len - max_strlen * sizeof(w);
|
!addr || !len || size / sizeof(w) != len || end < addr) {
|
||||||
else
|
printaddr(addr);
|
||||||
min_len = 0;
|
return;
|
||||||
for (; len >= sizeof(w) && len > min_len;
|
}
|
||||||
len -= sizeof(w), list += sizeof(w)) {
|
|
||||||
if (umove(tcp, list, &w) < 0)
|
if (abbrev(tcp)) {
|
||||||
break;
|
abbrev_end = addr + max_strlen * sizeof(w);
|
||||||
if (first)
|
if (abbrev_end < addr)
|
||||||
tprints("{");
|
abbrev_end = end;
|
||||||
else
|
} else {
|
||||||
|
abbrev_end = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
tprints("[");
|
||||||
|
for (cur = addr; cur < end; cur += sizeof(w)) {
|
||||||
|
if (cur > addr)
|
||||||
tprints(", ");
|
tprints(", ");
|
||||||
first = 0;
|
if (cur >= abbrev_end) {
|
||||||
|
tprints("...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (umove_or_printaddr(tcp, cur, &w))
|
||||||
|
break;
|
||||||
tprintf("%lx", w);
|
tprintf("%lx", w);
|
||||||
}
|
}
|
||||||
if (len) {
|
tprints("]");
|
||||||
if (first)
|
|
||||||
tprintf("%#lx", list);
|
|
||||||
else
|
|
||||||
tprintf(", %s}", (len >= sizeof(w) && len > min_len ?
|
|
||||||
"???" : "..."));
|
|
||||||
} else {
|
|
||||||
tprints(first ? "{}" : "}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SYS_FUNC(sched_setaffinity)
|
SYS_FUNC(sched_setaffinity)
|
||||||
@ -46,10 +51,7 @@ SYS_FUNC(sched_getaffinity)
|
|||||||
if (entering(tcp)) {
|
if (entering(tcp)) {
|
||||||
tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
|
tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
|
||||||
} else {
|
} else {
|
||||||
if (tcp->u_rval == -1)
|
print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
|
||||||
tprintf("%#lx", tcp->u_arg[2]);
|
|
||||||
else
|
|
||||||
print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user