[ipxe-devel] [PATCH] Clean up the nrv2b algorithm

Joshua C. joshuacov at googlemail.com
Sun May 6 11:57:14 UTC 2012


When compiling ipxe.lkrn on fedora16 I'm getting warnings (turned
errors) from the nrv2b.c. This algorithm hasn't been touched since
2002 and contains some old code that never gets compiled or executed.
I just cleaned it up. If others are having similar issues maybe this
small patch can be merged upstream.

--Joshua
-------------------------------------

>From 8c741b4dc1fb351c6a128bb1e5743bb734cc78b3 Mon Sep 17 00:00:00 2001
From: Joshua Cov. <joshuacov at googlemail.com>
Date: Sun, 6 May 2012 14:45:28 +0200
Subject: [PATCH] clean up the nrv2b algorithm

The nrv2b algorithm hasn't been touched since 2002. It's pretty old
and contains some illogical/unused code that triggers warnings/errors
when being compiled with gcc-4.6.3. Clean it up.

---
 src/util/nrv2b.c |   36 ------------------------------------
 1 file changed, 36 deletions(-)

diff --git a/src/util/nrv2b.c b/src/util/nrv2b.c
index cbb94c0..5c6518e 100644
--- a/src/util/nrv2b.c
+++ b/src/util/nrv2b.c
@@ -209,7 +209,6 @@ struct ucl_compress

 #define SWD_HSIZE	16384
 #define SWD_MAX_CHAIN	2048
-#define SWD_BEST_OFF    1

 #define HEAD3(b,p) \
     (((0x9f5f*(((((uint32_t)b[p]<<5)^b[p+1])<<5)^b[p+2]))>>5) & (SWD_HSIZE-1))
@@ -235,16 +234,10 @@ struct ucl_swd
 	unsigned int m_off;
 	unsigned int look;
 	int b_char;
-#if defined(SWD_BEST_OFF)
-	unsigned int best_off[ SWD_BEST_OFF ];
-#endif
 	
 /* semi public */
 	struct ucl_compress *c;
 	unsigned int m_pos;
-#if defined(SWD_BEST_OFF)
-	unsigned int best_pos[ SWD_BEST_OFF ];
-#endif
 	
 /* private */
 	const uint8_t *dict;
@@ -590,13 +583,6 @@ void swd_search(struct ucl_swd *s, unsigned int
node, unsigned int cnt)
 #endif
 			assert(memcmp(bp,&b[node],i) == 0);
 			
-#if defined(SWD_BEST_OFF)
-			if (i < SWD_BEST_OFF)
-			{
-				if (s->best_pos[i] == 0)
-					s->best_pos[i] = node + 1;
-			}
-#endif
 			if (i > m_len)
 			{
 				s->m_len = m_len = i;
@@ -629,10 +615,6 @@ static int swd_search2(struct ucl_swd *s)
 			s->b[s->bp], s->b[s->bp+1], s->b[key], s->b[key+1]);
 #endif
 	assert(memcmp(&s->b[s->bp],&s->b[key],2) == 0);
-#if defined(SWD_BEST_OFF)
-	if (s->best_pos[2] == 0)
-		s->best_pos[2] = key + 1;
-#endif
 	
 	if (s->m_len < 2)
 	{
@@ -681,20 +663,6 @@ void swd_findbest(struct ucl_swd *s)
 		if (s->m_len > len)
 			s->m_off = swd_pos2off(s,s->m_pos);
 		s->best3[s->bp] = (unsigned int)(s->m_len);
-
-#if defined(SWD_BEST_OFF)
-		if (s->use_best_off)
-		{
-			int i;
-			for (i = 2; i < SWD_BEST_OFF; i++)
-				if (s->best_pos[i] > 0)
-					s->best_off[i] =
-						swd_pos2off(s,s->best_pos[i]-1);
-
-				else
-					s->best_off[i] = 0;
-		}
-#endif
 	}

 	swd_remove_node(s,s->rp);
@@ -757,10 +725,6 @@ find_match ( struct ucl_compress *c, struct ucl_swd *s,
 	}
 	
 	s->m_len = THRESHOLD;
-#ifdef SWD_BEST_OFF
-	if (s->use_best_off)
-		memset(s->best_pos,0,sizeof(s->best_pos));
-#endif
 	swd_findbest(s);
 	c->m_len = s->m_len;
 	c->m_off = s->m_off;
-- 
1.7.10



More information about the ipxe-devel mailing list