Blame SOURCES/0029-util-update-dumpstr.patch

b484ca
From 79acbcf2550f3a55108240558efb8b9c36eb8399 Mon Sep 17 00:00:00 2001
b484ca
From: Eugene Syromyatnikov <evgsyr@gmail.com>
b484ca
Date: Tue, 19 Feb 2019 03:10:11 +0100
b484ca
Subject: [PATCH] util: update dumpstr
b484ca
b484ca
Use a buffer of a limited size, use proper type for dump amount, avoid
b484ca
hard-coding of byte counts, calculate output buffer size more accurately
b484ca
and minimise its rewriting, pad offset with zeros in accordance
b484ca
with expected output amount.
b484ca
b484ca
* defs.h (dumpstr): Change the type of len argument from int to
b484ca
kernel_ulong_t.
b484ca
* macros.h (ROUNDUP_DIV): New macro.
b484ca
(ROUNDUP): Rewrite using ROUNDUP_DIV.
b484ca
* util.c (ILOG2_ITER_): New macro.
b484ca
(ilog2_64, ilog2_32): New functions.
b484ca
(ilog2_klong): New macro, wrapper around ilog2_32/ilog2_64, so (potentially
b484ca
more expensive) ilog2_64 is not used for ilog2 calculation
b484ca
of a kernel_ulong_t-typed variable on architectures with 32-bit kernel long.
b484ca
(dumpstr): Update.
b484ca
b484ca
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
b484ca
---
b484ca
 defs.h   |   2 +-
b484ca
 macros.h |   6 +-
b484ca
 util.c   | 205 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
b484ca
 3 files changed, 169 insertions(+), 44 deletions(-)
b484ca
b484ca
diff --git a/macros.h b/macros.h
b484ca
index 7f019480..61abf826 100644
b484ca
--- a/macros.h
b484ca
+++ b/macros.h
b484ca
@@ -28,8 +28,12 @@
b484ca
 #endif
b484ca
 #define CLAMP(val, min, max)	MIN(MAX(min, val), max)
b484ca
 
b484ca
+#ifndef ROUNDUP_DIV
b484ca
+# define ROUNDUP_DIV(val_, div_) (((val_) + (div_) - 1) / (div_))
b484ca
+#endif
b484ca
+
b484ca
 #ifndef ROUNDUP
b484ca
-# define ROUNDUP(val_, div_) ((((val_) + (div_) - 1) / (div_)) * (div_))
b484ca
+# define ROUNDUP(val_, div_) (ROUNDUP_DIV((val_), (div_)) * (div_))
b484ca
 #endif
b484ca
 
b484ca
 #ifndef offsetofend
b484ca
-- 
b484ca
2.13.6
b484ca