mtd/util compr.c,1.4,1.5 compr.h,1.3,1.4

havasi at infradead.org havasi at infradead.org
Wed Jun 23 12:36:01 EDT 2004


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

Modified Files:
	compr.c compr.h 
Log Message:
Applying David's suggestion:
- define printk, kmalloc, kfree, vmalloc, vfre
- remove JFFS2_MALLOC/FREE/PRINT macros from compr.c




Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/util/compr.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- compr.c	23 Jun 2004 15:00:14 -0000	1.4
+++ compr.c	23 Jun 2004 16:35:58 -0000	1.5
@@ -128,7 +128,7 @@
         /* buffer overflow test */
         for (i=buf_size;i>cdatalen;i--) {
                 if (output_buf[i]!=JFFS2_BUFFER_FILL) {
-                        JFFS2_PRINT("COMPR_ERROR: buffer overflow at %s. "
+                        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_error_cnt++;
@@ -137,28 +137,28 @@
         }
         /* allocing temporary buffer for decompression */
         if (!jffs2_compression_check_buf) {
-                jffs2_compression_check_buf = JFFS2_MALLOC(page_size);
+                jffs2_compression_check_buf = malloc(page_size);
                 if (!jffs2_compression_check_buf) {
-                        JFFS2_PRINT("No memory for buffer allocation. Compression check disabled.\n");
+                        fprintf(stderr,"No memory for buffer allocation. Compression check disabled.\n");
                         jffs2_compression_check = 0;
                         return;
                 }
         }
         /* decompressing */
         if (!compr->decompress) {
-                JFFS2_PRINT("JFFS2 compression check: there is no decompress function at %s.\n", compr->name);
+                fprintf(stderr,"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,NULL)) {
-                JFFS2_PRINT("JFFS2 compression check: decompression failed at %s.\n", compr->name);
+                fprintf(stderr,"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]) {
-                                JFFS2_PRINT("JFFS2 compression check: data mismatch at %s (pos %d).\n", compr->name, i);
+                                fprintf(stderr,"JFFS2 compression check: data mismatch at %s (pos %d).\n", compr->name, i);
                                 jffs2_error_cnt++;
                                 break;
                         }
@@ -200,9 +200,9 @@
         case JFFS2_COMPR_MODE_PRIORITY:
                 orig_slen = *datalen;
                 orig_dlen = *cdatalen;
-                output_buf = JFFS2_MALLOC(orig_dlen+jffs2_compression_check);
+                output_buf = malloc(orig_dlen+jffs2_compression_check);
                 if (!output_buf) {
-                        JFFS2_PRINT("mkfs.jffs2: No memory for compressor allocation. Compression failed.\n");
+                        fprintf(stderr,"mkfs.jffs2: No memory for compressor allocation. Compression failed.\n");
                         goto out;
                 }
                 list_for_each_entry(this, &jffs2_compressor_list, list) {
@@ -229,7 +229,7 @@
                                 break;
                         }
                 }
-                if (ret == JFFS2_COMPR_NONE) JFFS2_FREE(output_buf);
+                if (ret == JFFS2_COMPR_NONE) free(output_buf);
                 break;
         case JFFS2_COMPR_MODE_SIZE:
                 orig_slen = *datalen;
@@ -240,14 +240,14 @@
                                 continue;
                         /* Allocating memory for output buffer if necessary */
                         if ((this->compr_buf_size<orig_dlen+jffs2_compression_check)&&(this->compr_buf)) {
-                                JFFS2_FREE(this->compr_buf);
+                                free(this->compr_buf);
                                 this->compr_buf_size=0;
                                 this->compr_buf=NULL;
                         }
                         if (!this->compr_buf) {
-                                tmp_buf = JFFS2_MALLOC(orig_dlen+jffs2_compression_check);
+                                tmp_buf = malloc(orig_dlen+jffs2_compression_check);
                                 if (!tmp_buf) {
-                                        JFFS2_PRINT("mkfs.jffs2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
+                                        fprintf(stderr,"mkfs.jffs2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
                                         continue;
                                 }
                                 else {
@@ -285,7 +285,7 @@
                 }
                 break;
         default:
-                JFFS2_PRINT("mkfs.jffs2: unknow compression mode.\n");
+                fprintf(stderr,"mkfs.jffs2: unknow compression mode.\n");
         }
  out:
         if (ret == JFFS2_COMPR_NONE) {
@@ -306,7 +306,7 @@
         struct jffs2_compressor *this;
 
         if (!comp->name) {
-                JFFS2_PRINT("NULL compressor name at registering JFFS2 compressor. Failed.\n");
+                fprintf(stderr,"NULL compressor name at registering JFFS2 compressor. Failed.\n");
                 return -1;
         }
         comp->compr_buf_size=0;
@@ -332,7 +332,7 @@
 {
 
         if (comp->usecount) {
-                JFFS2_PRINT("mkfs.jffs2: Compressor modul is in use. Unregister failed.\n");
+                fprintf(stderr,"mkfs.jffs2: Compressor modul is in use. Unregister failed.\n");
                 return -1;
         }
         list_del(&comp->list);
@@ -347,7 +347,7 @@
         struct jffs2_compressor *this;
         char *buf, *act_buf;
 
-        act_buf = buf = JFFS2_MALLOC(JFFS2_STAT_BUF_SIZE);
+        act_buf = buf = malloc(JFFS2_STAT_BUF_SIZE);
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 act_buf += sprintf(act_buf, "%10s priority:%d ", this->name, this->priority);
                 if ((this->disabled)||(!this->compress))
@@ -364,7 +364,7 @@
         struct jffs2_compressor *this;
         char *buf, *act_buf;
 
-        act_buf = buf = JFFS2_MALLOC(JFFS2_STAT_BUF_SIZE);
+        act_buf = buf = malloc(JFFS2_STAT_BUF_SIZE);
 
         act_buf += sprintf(act_buf,"Compression mode: ");
         switch (jffs2_compression_mode) {
@@ -448,7 +448,7 @@
                         goto reinsert;
                 }
         }
-        JFFS2_PRINT("mkfs.jffs2: compressor %s not found.\n",name);
+        fprintf(stderr,"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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- compr.h	23 Jun 2004 15:00:14 -0000	1.3
+++ compr.h	23 Jun 2004 16:35:58 -0000	1.4
@@ -37,12 +37,16 @@
 #define JFFS2_COMPR_MODE_PRIORITY   1
 #define JFFS2_COMPR_MODE_SIZE       2
 
-#define JFFS2_MALLOC(a)             malloc(a)
-#define JFFS2_FREE(a)               free(a)
-#define JFFS2_MALLOC_BIG(a)         malloc(a)
-#define JFFS2_FREE_BIG(a)           free(a)
+#define kmalloc(a,b)                malloc(a)
+#define kfree(a)                    free(a)
+#ifndef GFP_KERNEL
+#define GFP_KERNEL                  0
+#endif
+
+#define vmalloc(a)                  malloc(a)
+#define vfree(a)                    free(a)
 
-#define JFFS2_PRINT(...)            fprintf(stderr,__VA_ARGS__)
+#define printk(...)                 fprintf(stderr,__VA_ARGS__)
 
 struct list_head {
         struct list_head *next, *prev;





More information about the linux-mtd-cvs mailing list