summaryrefslogtreecommitdiff
path: root/lib/lzo/lzo1x_decompress_safe.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2025-08-07 13:44:44 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2025-08-16 17:24:31 +0800
commitd2236198839ca57610d1f7be7c61fb8c95f2fca6 (patch)
tree3f1ce9dbf2345dc052468d516c1896ad2671fa57 /lib/lzo/lzo1x_decompress_safe.c
parent817fcdbd4ca29834014a5dadbe8e11efeb12800c (diff)
lib/lzo: add unlikely hints to overrun checks
The NEED_* macros do an implicit goto in case the safety bounds checks fail. Add the unlikely hints as this is the error case and not a hot path. The final assembly is slightly shorter and some jumps got reordered according to the hints. text data bss dec hex filename 2294 16 0 2310 906 pre/lzo1x_decompress_safe.o 2277 16 0 2293 8f5 post/lzo1x_decompress_safe.o text data bss dec hex filename 3444 48 0 3492 da4 pre/lzo1x_compress_safe.o 3372 48 0 3420 d5c post/lzo1x_compress_safe.o Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/lzo/lzo1x_decompress_safe.c')
-rw-r--r--lib/lzo/lzo1x_decompress_safe.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/lzo/lzo1x_decompress_safe.c b/lib/lzo/lzo1x_decompress_safe.c
index c94f4928e188..318abb82c63d 100644
--- a/lib/lzo/lzo1x_decompress_safe.c
+++ b/lib/lzo/lzo1x_decompress_safe.c
@@ -22,9 +22,9 @@
#define HAVE_IP(x) ((size_t)(ip_end - ip) >= (size_t)(x))
#define HAVE_OP(x) ((size_t)(op_end - op) >= (size_t)(x))
-#define NEED_IP(x) if (!HAVE_IP(x)) goto input_overrun
-#define NEED_OP(x) if (!HAVE_OP(x)) goto output_overrun
-#define TEST_LB(m_pos) if ((m_pos) < out) goto lookbehind_overrun
+#define NEED_IP(x) if (unlikely(!HAVE_IP(x))) goto input_overrun
+#define NEED_OP(x) if (unlikely(!HAVE_OP(x))) goto output_overrun
+#define TEST_LB(m_pos) if (unlikely((m_pos) < out)) goto lookbehind_overrun
/* This MAX_255_COUNT is the maximum number of times we can add 255 to a base
* count without overflowing an integer. The multiply will overflow when