]> granicus.if.org Git - strace/commit
util: update dumpstr
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 19 Feb 2019 02:10:11 +0000 (03:10 +0100)
committerEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 20 Feb 2019 15:10:37 +0000 (16:10 +0100)
commit79acbcf2550f3a55108240558efb8b9c36eb8399
treefa5692ce350f19681cae57b729823c0973186066
parent328ff889b1c0fac23685ddbc7a3d6991b9899fc8
util: update dumpstr

Use a buffer of a limited size, use proper type for dump amount, avoid
hard-coding of byte counts, calculate output buffer size more accurately
and minimise its rewriting, pad offset with zeros in accordance
with expected output amount.

* defs.h (dumpstr): Change the type of len argument from int to
kernel_ulong_t.
* macros.h (ROUNDUP_DIV): New macro.
(ROUNDUP): Rewrite using ROUNDUP_DIV.
* util.c (ILOG2_ITER_): New macro.
(ilog2_64, ilog2_32): New functions.
(ilog2_klong): New macro, wrapper around ilog2_32/ilog2_64, so (potentially
more expensive) ilog2_64 is not used for ilog2 calculation
of a kernel_ulong_t-typed variable on architectures with 32-bit kernel long.
(dumpstr): Update.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
defs.h
macros.h
util.c