From: "Yury Norov (NVIDIA)" <yury.norov@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Linus Walleij <linus.walleij@linaro.org>,
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>,
"Yury Norov (NVIDIA)" <yury.norov@gmail.com>,
linux-kernel@vger.kernel.org
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 05/21] zlib: rename BITS() to LOWBITS()
Date: Sat, 25 Oct 2025 12:28:41 -0400 [thread overview]
Message-ID: <20251025162858.305236-6-yury.norov@gmail.com> (raw)
In-Reply-To: <20251025162858.305236-1-yury.norov@gmail.com>
In preparation from adding generic BITS() macro, rename the local one.
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
lib/zlib_inflate/inflate.c | 48 +++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index d1efad69f02b..3102137b51c2 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -229,7 +229,7 @@ static int zlib_inflateSyncPacket(z_streamp strm)
} while (0)
/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
+#define LOWBITS(n) \
((unsigned)hold & ((1U << (n)) - 1))
/* Remove n bits from the bit accumulator */
@@ -270,16 +270,16 @@ static int zlib_inflateSyncPacket(z_streamp strm)
is:
NEEDBITS(n);
- ... do something with BITS(n) ...
+ ... do something with LOWBITS(n) ...
DROPBITS(n);
where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
+ input left to load n bits into the accumulator, or it continues. LOWBITS(n)
gives the low n bits in the accumulator. When done, DROPBITS(n) drops
the low n bits off the accumulator. INITBITS() clears the accumulator
and sets the number of available bits to zero. BYTEBITS() discards just
enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
+ and a NEEDBITS(8), then LOWBITS(8) would return the next byte in the stream.
NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
if there is no input available. The decoding of variable length codes uses
@@ -295,7 +295,7 @@ static int zlib_inflateSyncPacket(z_streamp strm)
case STATEw:
while (want < need) {
NEEDBITS(n);
- keep[want++] = BITS(n);
+ keep[want++] = LOWBITS(n);
DROPBITS(n);
}
state = STATEx;
@@ -369,18 +369,18 @@ int zlib_inflate(z_streamp strm, int flush)
}
NEEDBITS(16);
if (
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
+ ((LOWBITS(8) << 8) + (hold >> 8)) % 31) {
strm->msg = (char *)"incorrect header check";
state->mode = BAD;
break;
}
- if (BITS(4) != Z_DEFLATED) {
+ if (LOWBITS(4) != Z_DEFLATED) {
strm->msg = (char *)"unknown compression method";
state->mode = BAD;
break;
}
DROPBITS(4);
- len = BITS(4) + 8;
+ len = LOWBITS(4) + 8;
if (len > state->wbits) {
strm->msg = (char *)"invalid window size";
state->mode = BAD;
@@ -416,9 +416,9 @@ int zlib_inflate(z_streamp strm, int flush)
break;
}
NEEDBITS(3);
- state->last = BITS(1);
+ state->last = LOWBITS(1);
DROPBITS(1);
- switch (BITS(2)) {
+ switch (LOWBITS(2)) {
case 0: /* stored block */
state->mode = STORED;
break;
@@ -465,11 +465,11 @@ int zlib_inflate(z_streamp strm, int flush)
break;
case TABLE:
NEEDBITS(14);
- state->nlen = BITS(5) + 257;
+ state->nlen = LOWBITS(5) + 257;
DROPBITS(5);
- state->ndist = BITS(5) + 1;
+ state->ndist = LOWBITS(5) + 1;
DROPBITS(5);
- state->ncode = BITS(4) + 4;
+ state->ncode = LOWBITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
@@ -484,7 +484,7 @@ int zlib_inflate(z_streamp strm, int flush)
case LENLENS:
while (state->have < state->ncode) {
NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
+ state->lens[order[state->have++]] = (unsigned short)LOWBITS(3);
DROPBITS(3);
}
while (state->have < 19)
@@ -505,7 +505,7 @@ int zlib_inflate(z_streamp strm, int flush)
case CODELENS:
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
+ this = state->lencode[LOWBITS(state->lenbits)];
if ((unsigned)(this.bits) <= bits) break;
PULLBYTE();
}
@@ -524,21 +524,21 @@ int zlib_inflate(z_streamp strm, int flush)
break;
}
len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
+ copy = 3 + LOWBITS(2);
DROPBITS(2);
}
else if (this.val == 17) {
NEEDBITS(this.bits + 3);
DROPBITS(this.bits);
len = 0;
- copy = 3 + BITS(3);
+ copy = 3 + LOWBITS(3);
DROPBITS(3);
}
else {
NEEDBITS(this.bits + 7);
DROPBITS(this.bits);
len = 0;
- copy = 11 + BITS(7);
+ copy = 11 + LOWBITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
@@ -584,7 +584,7 @@ int zlib_inflate(z_streamp strm, int flush)
break;
}
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
+ this = state->lencode[LOWBITS(state->lenbits)];
if ((unsigned)(this.bits) <= bits) break;
PULLBYTE();
}
@@ -592,7 +592,7 @@ int zlib_inflate(z_streamp strm, int flush)
last = this;
for (;;) {
this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
+ (LOWBITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + this.bits) <= bits) break;
PULLBYTE();
}
@@ -619,14 +619,14 @@ int zlib_inflate(z_streamp strm, int flush)
case LENEXT:
if (state->extra) {
NEEDBITS(state->extra);
- state->length += BITS(state->extra);
+ state->length += LOWBITS(state->extra);
DROPBITS(state->extra);
}
state->mode = DIST;
fallthrough;
case DIST:
for (;;) {
- this = state->distcode[BITS(state->distbits)];
+ this = state->distcode[LOWBITS(state->distbits)];
if ((unsigned)(this.bits) <= bits) break;
PULLBYTE();
}
@@ -634,7 +634,7 @@ int zlib_inflate(z_streamp strm, int flush)
last = this;
for (;;) {
this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
+ (LOWBITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + this.bits) <= bits) break;
PULLBYTE();
}
@@ -653,7 +653,7 @@ int zlib_inflate(z_streamp strm, int flush)
case DISTEXT:
if (state->extra) {
NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
+ state->offset += LOWBITS(state->extra);
DROPBITS(state->extra);
}
#ifdef INFLATE_STRICT
--
2.43.0
next prev parent reply other threads:[~2025-10-25 16:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-25 16:28 [PATCH 00/21] lib: add alternatives for GENMASK() Yury Norov (NVIDIA)
2025-10-25 16:28 ` [PATCH 01/21] arc: disasm: rename BITS() for FIELD() Yury Norov (NVIDIA)
2025-10-25 16:28 ` [PATCH 02/21] iwlwifi: drop unused BITS() Yury Norov (NVIDIA)
2025-10-25 16:28 ` [PATCH 03/21] select: rename BITS() to FDS_BITS() Yury Norov (NVIDIA)
2025-10-25 16:28 ` [PATCH 04/21] ALSA: rename BITS to R_BITS Yury Norov (NVIDIA)
2025-10-27 9:09 ` Takashi Iwai
2025-10-25 16:28 ` Yury Norov (NVIDIA) [this message]
2025-10-25 16:28 ` [PATCH 06/21] mfd: prepare to generalize BITS() macro Yury Norov (NVIDIA)
2025-11-06 16:48 ` Lee Jones
2025-10-25 16:28 ` [PATCH 07/21] bits: Add " Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 08/21] mfd: drop local " Yury Norov (NVIDIA)
2025-10-27 22:21 ` Linus Walleij
2025-10-25 16:32 ` [PATCH 09/21] bits: generalize BITMAP_{FIRST,LAST}_WORD_MASK Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 10/21] i2c: nomadik: don't use GENMASK() Yury Norov (NVIDIA)
2025-10-27 22:22 ` Linus Walleij
2025-10-25 16:32 ` [PATCH 11/21] drivers: don't use GENMASK() in FIELD_PREP_WM16() Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 12/21] bitmap: don't use GENMASK() Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 13/21] trace: " Yury Norov (NVIDIA)
2025-10-25 19:29 ` Steven Rostedt
2025-10-25 19:36 ` Steven Rostedt
2025-10-25 16:32 ` [PATCH 14/21] lib: 842: don't use GENMASK_ULL() Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 15/21] bpf: don't use GENMASK() Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 16/21] kcsan: " Yury Norov (NVIDIA)
2025-10-25 16:32 ` [PATCH 17/21] mm: " Yury Norov (NVIDIA)
2025-10-25 16:33 ` [PATCH 18/21] fprobe: " Yury Norov (NVIDIA)
2025-10-25 16:33 ` [PATCH 19/21] fs: " Yury Norov (NVIDIA)
2025-10-25 16:33 ` [PATCH 20/21] fortify-string: " Yury Norov (NVIDIA)
2025-10-25 16:33 ` [PATCH 21/21] Docs: add Functions parameters order section Yury Norov (NVIDIA)
2025-10-27 9:02 ` Jani Nikula
2025-10-27 16:08 ` Jeff Johnson
2025-10-27 18:22 ` Andi Shyti
2025-10-27 18:43 ` Randy Dunlap
2025-10-25 16:37 ` [PATCH 00/21] lib: add alternatives for GENMASK() Yury Norov
2025-10-25 16:39 Yury Norov (NVIDIA)
2025-10-25 16:40 ` [PATCH 05/21] zlib: rename BITS() to LOWBITS() Yury Norov (NVIDIA)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251025162858.305236-6-yury.norov@gmail.com \
--to=yury.norov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=nicolas.frattaroli@collabora.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®