Cleanup fetch part of printstr_ex
* util.c (printstr_ex): Initialize "style" early, unify error handling.
This commit is contained in:
parent
6931903807
commit
ead746af18
27
util.c
27
util.c
@ -836,7 +836,8 @@ printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style)
|
||||
static char *str = NULL;
|
||||
static char *outstr;
|
||||
unsigned int size;
|
||||
unsigned int style;
|
||||
unsigned int style = user_style;
|
||||
int rc;
|
||||
int ellipsis;
|
||||
|
||||
if (!addr) {
|
||||
@ -859,24 +860,18 @@ printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style)
|
||||
* Treat as a NUL-terminated string: fetch one byte more
|
||||
* because string_quote may look one byte ahead.
|
||||
*/
|
||||
if (umovestr(tcp, addr, size, str) < 0) {
|
||||
printaddr(addr);
|
||||
return;
|
||||
}
|
||||
style = QUOTE_0_TERMINATED;
|
||||
style |= QUOTE_0_TERMINATED;
|
||||
rc = umovestr(tcp, addr, size, str);
|
||||
} else {
|
||||
if (size > (unsigned long) len)
|
||||
size = (unsigned long) len;
|
||||
rc = umoven(tcp, addr, size, str);
|
||||
}
|
||||
else {
|
||||
if (size > (unsigned long)len)
|
||||
size = (unsigned long)len;
|
||||
if (umoven(tcp, addr, size, str) < 0) {
|
||||
printaddr(addr);
|
||||
return;
|
||||
}
|
||||
style = 0;
|
||||
if (rc < 0) {
|
||||
printaddr(addr);
|
||||
return;
|
||||
}
|
||||
|
||||
style |= user_style;
|
||||
|
||||
if (style & QUOTE_0_TERMINATED) {
|
||||
if (size) {
|
||||
--size;
|
||||
|
Loading…
Reference in New Issue
Block a user