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

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