From: Dmitry V. Levin Date: Mon, 20 Jul 2015 12:09:44 +0000 (+0000) Subject: file.c: use umove_or_printaddr X-Git-Tag: v4.11~370 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6d80ffe023b70fde54376b3c87d43da1df4461a;p=strace file.c: use umove_or_printaddr * file.c (printstat32, printstatsol): Remove. (printstat, printstat64, printoldstat): Use umove_or_printaddr. --- diff --git a/file.c b/file.c index 8e1952fc..30929944 100644 --- a/file.c +++ b/file.c @@ -174,19 +174,6 @@ struct stat32 { # undef HAVE_STRUCT_STAT_ST_FSTYPE # undef HAVE_STRUCT_STAT_ST_GEN # include "printstat.h" - -static void -printstat32(struct tcb *tcp, long addr) -{ - struct stat32 statbuf; - - if (umove(tcp, addr, &statbuf) < 0) { - tprints("{...}"); - return; - } - - do_printstat32(tcp, &statbuf); -} #endif /* STAT32_PERSONALITY */ #if defined(SPARC) || defined(SPARC64) @@ -223,20 +210,6 @@ struct solstat { # undef HAVE_STRUCT_STAT_ST_FSTYPE # undef HAVE_STRUCT_STAT_ST_GEN # include "printstat.h" - -static void -printstatsol(struct tcb *tcp, long addr) -{ - struct solstat statbuf; - - if (umove(tcp, addr, &statbuf) < 0) { - tprints("{...}"); - return; - } - - do_printstat_sol(tcp, &statbuf); -} - #endif /* SPARC || SPARC64 */ static void @@ -244,35 +217,28 @@ printstat(struct tcb *tcp, long addr) { struct stat statbuf; - if (!addr) { - tprints("NULL"); - return; - } - if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#lx", addr); - return; - } - #ifdef STAT32_PERSONALITY if (current_personality == STAT32_PERSONALITY) { - printstat32(tcp, addr); + struct stat32 statbuf; + + if (!umove_or_printaddr(tcp, addr, &statbuf)) + do_printstat32(tcp, &statbuf); return; } #endif #if defined(SPARC) || defined(SPARC64) if (current_personality == 1) { - printstatsol(tcp, addr); - return; - } -#endif /* SPARC || SPARC64 */ + struct solstat statbuf; - if (umove(tcp, addr, &statbuf) < 0) { - tprints("{...}"); + if (!umove_or_printaddr(tcp, addr, &statbuf)) + do_printstat_sol(tcp, &statbuf); return; } +#endif /* SPARC || SPARC64 */ - do_printstat(tcp, &statbuf); + if (!umove_or_printaddr(tcp, addr, &statbuf)) + do_printstat(tcp, &statbuf); } SYS_FUNC(stat) @@ -359,15 +325,6 @@ printstat64(struct tcb *tcp, long addr) (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); # endif - if (!addr) { - tprints("NULL"); - return; - } - if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#lx", addr); - return; - } - # ifdef STAT32_PERSONALITY if (current_personality != STAT32_PERSONALITY) { printstat(tcp, addr); @@ -375,12 +332,8 @@ printstat64(struct tcb *tcp, long addr) } # endif /* STAT32_PERSONALITY */ - if (umove(tcp, addr, &statbuf) < 0) { - tprints("{...}"); - return; - } - - do_printstat64(tcp, &statbuf); + if (!umove_or_printaddr(tcp, addr, &statbuf)) + do_printstat64(tcp, &statbuf); } SYS_FUNC(stat64) @@ -467,29 +420,20 @@ printoldstat(struct tcb *tcp, long addr) struct __old_kernel_stat statbuf; struct stat newstatbuf; - if (!addr) { - tprints("NULL"); - return; - } - if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#lx", addr); - return; - } - # if defined(SPARC) || defined(SPARC64) if (current_personality == 1) { - printstatsol(tcp, addr); + struct solstat statbuf; + + if (!umove_or_printaddr(tcp, addr, &statbuf)) + do_printstat_sol(tcp, &statbuf); return; } # endif - if (umove(tcp, addr, &statbuf) < 0) { - tprints("{...}"); - return; + if (!umove_or_printaddr(tcp, addr, &statbuf)) { + convertoldstat(&statbuf, &newstatbuf); + do_printstat(tcp, &newstatbuf); } - - convertoldstat(&statbuf, &newstatbuf); - do_printstat(tcp, &newstatbuf); } SYS_FUNC(oldstat)