From 9c17bd0a5f3af4f52851e24beebfee2f0d5fc907 Mon Sep 17 00:00:00 2001 From: Lucy Phipps Date: Wed, 8 Jun 2022 18:48:19 +0100 Subject: [PATCH] early return as requested --- arch/arm/crc32_acle.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/crc32_acle.c b/arch/arm/crc32_acle.c index 0133e88f..ce75c343 100644 --- a/arch/arm/crc32_acle.c +++ b/arch/arm/crc32_acle.c @@ -37,6 +37,11 @@ uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, uint64_t len) { len -= sizeof(uint32_t); } + if (len == 0) { + c = ~c; + return c; + } + const uint64_t *buf8 = (const uint64_t *) buf4; while (len >= sizeof(uint64_t)) { @@ -61,6 +66,11 @@ uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, uint64_t len) { buf = (const unsigned char *) buf2; #else /* __aarch64__ */ + if (len == 0) { + c = ~c; + return c; + } + while (len >= sizeof(uint32_t)) { c = __crc32w(c, *buf4++); len -= sizeof(uint32_t); -- 2.47.3