Skip to contentSkip to conversation

: bunzip2: Fix warning in get_next_block()

PATCH In review Prarit Bhargava 2 participants 3 messages May 22, 2010 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : bunzip2: Fix warning in get_next_block()

Fix checkstack compile warning in get_next_block():

lib/decompress_bunzip2.c: In function `get_next_block':
lib/decompress_bunzip2.c:511: warning: the frame size of 1920 bytes is larger than 1024 bytes

lib/decompress_bunzip2.c +4 -3
index a4e971d..8a78788 100644
@@ -158,9 +158,10 @@ static int INIT get_next_block(struct bunzip_data *bd)
 	int *base = NULL;
 	int *limit = NULL;
 	int dbufCount, nextSym, dbufSize, groupCount, selector,
-		i, j, k, t, runPos, symCount, symTotal, nSelectors,
-		byteCount[256];
-	unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
+		i, j, k, t, runPos, symCount, symTotal, nSelectors;
+	static int byteCount[256];
+	unsigned char uc, *selectors;
+	static unsigned char symToByte[256], mtfSymbol[256];
 	unsigned int *dbuf, origPtr;
 
 	dbuf = bd->dbuf;
#1 lore raw
Quoted 5 lines · Prarit Bhargava

Fix checkstack compile warning in get_next_block():

lib/decompress_bunzip2.c: In function `get_next_block':
lib/decompress_bunzip2.c:511: warning: the frame size of 1920 bytes is larger than 1024 bytes

lib/decompress_bunzip2.c static int INIT get_next_block(struct bunzip_data *bd) · line 165

Quoted 9 lines
lib/decompress_bunzip2.c +4 -3
 	int dbufCount, nextSym, dbufSize, groupCount, selector,
-		i, j, k, t, runPos, symCount, symTotal, nSelectors,
-		byteCount[256];
-	unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
+		i, j, k, t, runPos, symCount, symTotal, nSelectors;
+	static int byteCount[256];
+	unsigned char uc, *selectors;
+	static unsigned char symToByte[256], mtfSymbol[256];
 	unsigned int *dbuf, origPtr;

Um... Some details might be useful, starting with "why can't that function be called from several processes at once"...

#2 lore raw
Quoted 9 lines · Al Viro
Quoted 5 lines · Prarit Bhargava

Fix checkstack compile warning in get_next_block():

lib/decompress_bunzip2.c: In function `get_next_block':
lib/decompress_bunzip2.c:511: warning: the frame size of 1920 bytes is larger than 1024 bytes

Quoted 13 lines

lib/decompress_bunzip2.c static int INIT get_next_block(struct bunzip_data *bd) · line 165

Quoted 10 lines

int dbufCount, nextSym, dbufSize, groupCount, selector,

lib/decompress_bunzip2.c +4 -3
-		i, j, k, t, runPos, symCount, symTotal, nSelectors,
-		byteCount[256];
-	unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
+		i, j, k, t, runPos, symCount, symTotal, nSelectors;
+	static int byteCount[256];
+	unsigned char uc, *selectors;
+	static unsigned char symToByte[256], mtfSymbol[256];
  	unsigned int *dbuf, origPtr;

Um... Some details might be useful, starting with "why can't that function be called from several processes at once"...

Al, to be honest, I'm not 100% if this is single-threaded or not :/. I was hoping that by throwing the patch out I would get either an ACK or a NAK on it because of the single threaded issue. It seems to me (and I admit I might be totally wrong) that the bunzip2 function is only called during early boot,

#ifdef PREBOOT
STATIC int INIT decompress(unsigned char *buf, int len,
int(*fill)(void*, unsigned int), int(*flush)(void*, unsigned int), unsigned char *outbuf, int *pos, void(*error_fn)(char *x))

{
        return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
}

#endif

... which (again, if the assumptions I'm making are correct) means that only one cpu will be active.

/me hopes someone will correct him if he's wrong and that's why hpa and phillip are cc'd directly

If it isn't single threaded, then you're right -- a PREBOOT malloc is the way to go.

P.