mtd/util compr.c, 1.3, 1.4 compr.h, 1.2, 1.3 compr_rtime.c, 1.2, 1.3 compr_zlib.c, 1.2, 1.3

havasi at infradead.org havasi at infradead.org
Wed Jun 23 11:00:17 EDT 2004


Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/home/havasi/mtd/util

Modified Files:
	compr.c compr.h compr_rtime.c compr_zlib.c 
Log Message:
Preparing for model file support.

Nothing relevant change, just the two following:
- one additional parameter for (de)compress: "void *model"
  (not used yet)
- replace fprintf(stderr,...) with JFFS2_PRINT macro. It can be used by compressor modules, too.




Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/util/compr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- compr.c	17 Jun 2004 16:31:40 -0000	1.3
+++ compr.c	23 Jun 2004 15:00:14 -0000	1.4
@@ -128,9 +128,9 @@
         /* buffer overflow test */
         for (i=buf_size;i>cdatalen;i--) {
                 if (output_buf[i]!=JFFS2_BUFFER_FILL) {
-                        fprintf(stderr,"COMPR_ERROR: buffer overflow at %s. "
-                                       "(bs=%d csize=%d b[%d]=%d)\n", compr->name, 
-                                       buf_size, cdatalen, i, (int)(output_buf[i]));
+                        JFFS2_PRINT("COMPR_ERROR: buffer overflow at %s. "
+                                    "(bs=%d csize=%d b[%d]=%d)\n", compr->name, 
+                                    buf_size, cdatalen, i, (int)(output_buf[i]));
                         jffs2_error_cnt++;
                         return;
                 }
@@ -139,26 +139,26 @@
         if (!jffs2_compression_check_buf) {
                 jffs2_compression_check_buf = JFFS2_MALLOC(page_size);
                 if (!jffs2_compression_check_buf) {
-                        fprintf(stderr,"No memory for buffer allocation. Compression check disabled.\n");
+                        JFFS2_PRINT("No memory for buffer allocation. Compression check disabled.\n");
                         jffs2_compression_check = 0;
                         return;
                 }
         }
         /* decompressing */
         if (!compr->decompress) {
-                fprintf(stderr,"JFFS2 compression check: there is no decompress function at %s.\n", compr->name);
+                JFFS2_PRINT("JFFS2 compression check: there is no decompress function at %s.\n", compr->name);
                 jffs2_error_cnt++;
                 return;
         }
-        if (compr->decompress(output_buf,jffs2_compression_check_buf,cdatalen,datalen)) {
-                fprintf(stderr,"JFFS2 compression check: decompression failed at %s.\n", compr->name);
+        if (compr->decompress(output_buf,jffs2_compression_check_buf,cdatalen,datalen,NULL)) {
+                JFFS2_PRINT("JFFS2 compression check: decompression failed at %s.\n", compr->name);
                 jffs2_error_cnt++;
         }
         /* validate decompression */
         else {
                 for (i=0;i<datalen;i++) {
                         if (data_in[i]!=jffs2_compression_check_buf[i]) {
-                                fprintf(stderr,"JFFS2 compression check: data mismatch at %s (pos %d).\n", compr->name, i);
+                                JFFS2_PRINT("JFFS2 compression check: data mismatch at %s (pos %d).\n", compr->name, i);
                                 jffs2_error_cnt++;
                                 break;
                         }
@@ -202,7 +202,7 @@
                 orig_dlen = *cdatalen;
                 output_buf = JFFS2_MALLOC(orig_dlen+jffs2_compression_check);
                 if (!output_buf) {
-                        fprintf(stderr, "mkfs.jffs2: No memory for compressor allocation. Compression failed.\n");
+                        JFFS2_PRINT("mkfs.jffs2: No memory for compressor allocation. Compression failed.\n");
                         goto out;
                 }
                 list_for_each_entry(this, &jffs2_compressor_list, list) {
@@ -217,7 +217,7 @@
 
                         *datalen  = orig_slen;
                         *cdatalen = orig_dlen;
-                        compr_ret = this->compress(data_in, output_buf, datalen, cdatalen);
+                        compr_ret = this->compress(data_in, output_buf, datalen, cdatalen, NULL);
                         this->usecount--;
                         if (!compr_ret) {
                                 ret = this->compr;
@@ -247,7 +247,7 @@
                         if (!this->compr_buf) {
                                 tmp_buf = JFFS2_MALLOC(orig_dlen+jffs2_compression_check);
                                 if (!tmp_buf) {
-                                        fprintf(stderr, "mkfs.jffs2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
+                                        JFFS2_PRINT("mkfs.jffs2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
                                         continue;
                                 }
                                 else {
@@ -260,7 +260,7 @@
                                 jffs2_decompression_test_prepare(this->compr_buf,this->compr_buf_size);
                         *datalen  = orig_slen;
                         *cdatalen = orig_dlen;
-                        compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen);
+                        compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen, NULL);
                         this->usecount--;
                         if (!compr_ret) {
                                 if (jffs2_compression_check)
@@ -285,7 +285,7 @@
                 }
                 break;
         default:
-                fprintf(stderr,"mkfs.jffs2: unknow compression mode.\n");
+                JFFS2_PRINT("mkfs.jffs2: unknow compression mode.\n");
         }
  out:
         if (ret == JFFS2_COMPR_NONE) {
@@ -306,7 +306,7 @@
         struct jffs2_compressor *this;
 
         if (!comp->name) {
-                fprintf(stderr,"NULL compressor name at registering JFFS2 compressor. Failed.\n");
+                JFFS2_PRINT("NULL compressor name at registering JFFS2 compressor. Failed.\n");
                 return -1;
         }
         comp->compr_buf_size=0;
@@ -332,7 +332,7 @@
 {
 
         if (comp->usecount) {
-                fprintf(stderr,"mkfs.jffs2: Compressor modul is in use. Unregister failed.\n");
+                JFFS2_PRINT("mkfs.jffs2: Compressor modul is in use. Unregister failed.\n");
                 return -1;
         }
         list_del(&comp->list);
@@ -448,7 +448,7 @@
                         goto reinsert;
                 }
         }
-        fprintf(stderr,"mkfs.jffs2: compressor %s not found.\n",name);
+        JFFS2_PRINT("mkfs.jffs2: compressor %s not found.\n",name);
         return 1;
 reinsert:
         /* list is sorted in the order of priority, so if

Index: compr.h
===================================================================
RCS file: /home/cvs/mtd/util/compr.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- compr.h	25 May 2004 11:31:59 -0000	1.2
+++ compr.h	23 Jun 2004 15:00:14 -0000	1.3
@@ -42,6 +42,8 @@
 #define JFFS2_MALLOC_BIG(a)         malloc(a)
 #define JFFS2_FREE_BIG(a)           free(a)
 
+#define JFFS2_PRINT(...)            fprintf(stderr,__VA_ARGS__)
+
 struct list_head {
         struct list_head *next, *prev;
 };
@@ -61,9 +63,9 @@
         char *name;
         char compr;               /* JFFS2_COMPR_XXX */
         int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
-                        uint32_t *srclen, uint32_t *destlen);
+                        uint32_t *srclen, uint32_t *destlen, void *model);
         int (*decompress)(unsigned char *cdata_in, unsigned char *data_out,
-                        uint32_t cdatalen, uint32_t datalen);
+                        uint32_t cdatalen, uint32_t datalen, void *model);
         int usecount;
         int disabled;             /* if seted the compressor won't compress */
         unsigned char *compr_buf; /* used by size compr. mode */

Index: compr_rtime.c
===================================================================
RCS file: /home/cvs/mtd/util/compr_rtime.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- compr_rtime.c	25 May 2004 11:20:45 -0000	1.2
+++ compr_rtime.c	23 Jun 2004 15:00:14 -0000	1.3
@@ -27,7 +27,7 @@
 
 /* _compress returns the compressed size, -1 if bigger */
 static int jffs2_rtime_compress(unsigned char *data_in, unsigned char *cpage_out, 
-		   uint32_t *sourcelen, uint32_t *dstlen)
+		   uint32_t *sourcelen, uint32_t *dstlen, void *model)
 {
 	short positions[256];
 	int outpos = 0;
@@ -67,7 +67,7 @@
 
 
 static int jffs2_rtime_decompress(unsigned char *data_in, unsigned char *cpage_out,
-		      uint32_t srclen, uint32_t destlen)
+		      uint32_t srclen, uint32_t destlen, void *model)
 {
 	short positions[256];
 	int outpos = 0;

Index: compr_zlib.c
===================================================================
RCS file: /home/cvs/mtd/util/compr_zlib.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- compr_zlib.c	25 May 2004 11:20:45 -0000	1.2
+++ compr_zlib.c	23 Jun 2004 15:00:14 -0000	1.3
@@ -54,7 +54,7 @@
 #define STREAM_END_SPACE 12
 
 int jffs2_zlib_compress(unsigned char *data_in, unsigned char *cpage_out, 
-		   uint32_t *sourcelen, uint32_t *dstlen)
+		   uint32_t *sourcelen, uint32_t *dstlen, void *model)
 {
 	z_stream strm;
 	int ret;
@@ -102,7 +102,7 @@
 }
 
 int jffs2_zlib_decompress(unsigned char *data_in, unsigned char *cpage_out,
-		      uint32_t srclen, uint32_t destlen)
+		      uint32_t srclen, uint32_t destlen, void *model)
 {
 	z_stream strm;
 	int ret;





More information about the linux-mtd-cvs mailing list