public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Trivial Patch] Remove JFFS2 dependency on internal Zlib header
@ 2007-06-02 19:20 Daniel Hazelton
  2007-06-03  0:21 ` Prakash Punnoor
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Hazelton @ 2007-06-02 19:20 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-kernel, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]

History:
  During the discussion over the speed and stability of the proposed inclusion 
of a stripped-down, minimized version of the LZO compression algorithm it was 
noted that the way that patch handled separation of compression and 
decompression could be used for zlib as well. Then it was noted that moving 
the private zlib header 'zutil.h' to a combined zlib directory would break 
JFFS2, which used it. On examining JFFS2 it became clear that the only thing 
JFFS2 used the header for was a single constant. Since his code was involved, 
Mark Adler was contacted and he stated that that constant - PRESET_DICT - was 
part of the zlib standard and defined in RFC 1950. So, to remove the 
dependency the simplest recourse is to replace PRESET_DICT with the 'magic 
number' it represents.

Signed-off-by: Daniel Hazelton <dhazelton@enter.net>

DRH

diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index 2b87fcc..9f1b935 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/zlib.h>
-#include <linux/zutil.h>
 #include "nodelist.h"
 #include "compr.h"

@@ -154,7 +153,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,

        /* If it's deflate, and it's got no preset dictionary, then
           we can tell zlib to skip the adler32 check. */
-       if (srclen > 2 && !(data_in[1] & PRESET_DICT) &&
+       if (srclen > 2 && !(data_in[1] & 0x20) &&
            ((data_in[0] & 0x0f) == Z_DEFLATED) &&
            !(((data_in[0]<<8) + data_in[1]) % 31)) {

[-- Attachment #2: remove-jffs2-zutil.h-dependency.patch --]
[-- Type: text/x-diff, Size: 694 bytes --]

diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c
index 2b87fcc..9f1b935 100644
--- a/fs/jffs2/compr_zlib.c
+++ b/fs/jffs2/compr_zlib.c
@@ -16,7 +16,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/zlib.h>
-#include <linux/zutil.h>
 #include "nodelist.h"
 #include "compr.h"
 
@@ -154,7 +153,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
 
 	/* If it's deflate, and it's got no preset dictionary, then
 	   we can tell zlib to skip the adler32 check. */
-	if (srclen > 2 && !(data_in[1] & PRESET_DICT) &&
+	if (srclen > 2 && !(data_in[1] & 0x20) &&
 	    ((data_in[0] & 0x0f) == Z_DEFLATED) &&
 	    !(((data_in[0]<<8) + data_in[1]) % 31)) {
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-06-03  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-02 19:20 [Trivial Patch] Remove JFFS2 dependency on internal Zlib header Daniel Hazelton
2007-06-03  0:21 ` Prakash Punnoor
2007-06-03  1:46   ` Daniel Hazelton
2007-06-03  1:50   ` [Trivial Patch] Remove JFFS2 dependency on internal Zlib header (take 2) Daniel Hazelton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox