diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-09-30 20:08:11 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-10-09 12:30:24 +0200 |
commit | 8721881ab8fe694aca308016cec493014a5eb816 (patch) | |
tree | 6198843fe615a4c333dd7b4acfef9ed31b2c5d06 /src/defs.h | |
parent | 33296fb29e4895c3842b4950dbb36a811b94c6d4 (diff) | |
download | strace-8721881ab8fe694aca308016cec493014a5eb816.tar.gz |
util: add umoven_uint64_or_printaddr{,64}
There is a couple of places (in generic code) where an integer
of a specified size is to be retrieved; refactor it into a separate
function.
* src/defs.h (umoven_to_uint64_or_printaddr64): New declaration.
(umoven_to_uint64_or_printaddr): New function, a wrapper
for umoven_to_uint64_or_printaddr64.
* src/util.c (umoven_to_uint64_or_printaddr64): New function.
* src/nlattr.c (decode_nla_xval, decode_nla_flags): Rewrite using
umoven_to_uint64_or_printaddr.
Diffstat (limited to 'src/defs.h')
-rw-r--r-- | src/defs.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/defs.h b/src/defs.h index c639a3d86..6f7b6c3a1 100644 --- a/src/defs.h +++ b/src/defs.h @@ -710,6 +710,24 @@ umoven_or_printaddr(struct tcb *tcp, const kernel_ulong_t addr, umoven_or_printaddr((pid), (addr), sizeof(*(objp)), (void *) (objp)) /** + * Retrieves up to 8 bytes (that are treated as a single unsigned integer value) + * and puts it into variable pointed by laddr; + * + * @return 0 on success, -1 (and print addr) on error or if len is more + * than size of uint64_t. + */ +extern int +umoven_to_uint64_or_printaddr64(struct tcb *, uint64_t addr, + unsigned int len, uint64_t *laddr); + +static inline int +umoven_to_uint64_or_printaddr(struct tcb *tcp, const kernel_ulong_t addr, + unsigned int len, uint64_t *laddr) +{ + return umoven_to_uint64_or_printaddr64(tcp, addr, len, laddr); +} + +/** * @return 0 on success, -1 on error (and print addr). */ extern int |