diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-08-29 20:06:18 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-09-02 17:55:13 +0200 |
commit | a9a1ffe9bc078b5c416436caf8d85306661a679b (patch) | |
tree | a5becbbdbb5925cc8ef7e6f6bd9cab73b93535ab | |
parent | 18126ed325b85b815c9d14845fd1e1ba48b6390f (diff) | |
download | strace-esyr/next-ng2-salvage.tar.gz |
ioprio: implement print_ioprio independent of sprint_ioprioesyr/next-ng2-salvage
-rw-r--r-- | src/ioprio.c | 32 | ||||
-rw-r--r-- | tests/ioprio.c | 11 |
2 files changed, 24 insertions, 19 deletions
diff --git a/src/ioprio.c b/src/ioprio.c index bacabe606..16c9e6dbe 100644 --- a/src/ioprio.c +++ b/src/ioprio.c @@ -43,10 +43,23 @@ print_ioprio(unsigned int ioprio) if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) return; - const char *str = sprint_ioprio(ioprio); + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprint_comment_begin(); - (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE - ? tprints_comment : tprints)(str); + unsigned int class = IOPRIO_PRIO_CLASS(ioprio); + unsigned int data = IOPRIO_PRIO_DATA(ioprio); + + tprints_arg_begin("IOPRIO_PRIO_VALUE"); + printxval_ex(ioprio_class, class, + xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE + ? NULL : "IOPRIO_CLASS_???", + XLAT_STYLE_ABBREV); + tprint_arg_next(); + PRINT_VAL_U(data); + tprint_arg_end(); + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprint_comment_end(); } static void @@ -81,9 +94,7 @@ SYS_FUNC(ioprio_get) } else { if (syserror(tcp)) return 0; - if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) - tcp->auxstr = NULL; - else + if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_RAW) tcp->auxstr = sprint_ioprio(tcp->u_rval); return RVAL_STR; } @@ -100,14 +111,7 @@ SYS_FUNC(ioprio_set) tprint_arg_next(); /* ioprio */ - if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) - PRINT_VAL_D((int) tcp->u_arg[2]); - - if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) - return RVAL_DECODED; - - (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE - ? tprints_comment : tprints)(sprint_ioprio(tcp->u_arg[2])); + print_ioprio(tcp->u_arg[2]); return RVAL_DECODED; } diff --git a/tests/ioprio.c b/tests/ioprio.c index 5d998a225..0ce84e99a 100644 --- a/tests/ioprio.c +++ b/tests/ioprio.c @@ -44,7 +44,8 @@ main(void) # if !XLAT_RAW static const char * const bogus_ioprio_str = - "IOPRIO_PRIO_VALUE(0x7d677 /* IOPRIO_CLASS_??? */, 7917)"; + "IOPRIO_PRIO_VALUE(0x7d677" NVERB(" /* IOPRIO_CLASS_??? */") + ", 7917)"; # endif long rc; @@ -96,9 +97,9 @@ main(void) # endif printf(", %d%s", pgid, pidns_pid2str(PT_PGID)); # if XLAT_RAW - printf(", 8191)"); + printf(", 0x1fff)"); # elif XLAT_VERBOSE - printf(", 8191 /* IOPRIO_PRIO_VALUE(0 /* IOPRIO_CLASS_NONE */, 8191) */)"); + printf(", 0x1fff /* IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 8191) */)"); # else /* XLAT_ABBREV */ printf(", IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 8191))"); # endif @@ -108,11 +109,11 @@ main(void) errstr = sprintrc(rc); pidns_print_leader(); # if XLAT_RAW - printf("ioprio_set(%#x, %d, %d) = %s\n", + printf("ioprio_set(%#x, %d, %#x) = %s\n", (int) bogus_which, (int) bogus_who, (int) bogus_ioprio, errstr); # elif XLAT_VERBOSE - printf("ioprio_set(%#x /* IOPRIO_WHO_??? */, %d, %d /* %s */) = %s\n", + printf("ioprio_set(%#x /* IOPRIO_WHO_??? */, %d, %#x /* %s */) = %s\n", (int) bogus_which, (int) bogus_who, (int) bogus_ioprio, bogus_ioprio_str, errstr); # else /* XLAT_ABBREV */ |