Patchwork mtd-utils: convert to common.h/min

login
register
mail settings
Submitter Mike Frysinger
Date Sept. 24, 2010, 1:52 a.m.
Message ID <1285293137-24887-1-git-send-email-vapier@gentoo.org>
Download mbox | patch
Permalink /patch/65611/
State Accepted, archived
Commit fa50c60d7b3b4963a9e3810c41a216577f76d7af
Headers show

Comments

Mike Frysinger - Sept. 24, 2010, 1:52 a.m.
Kill off duplicated min() defines and convert to the common.h one.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 compr_zlib.c     |    3 +--
 include/common.h |    1 +
 jffs-dump.c      |    4 ++--
 mkfs.jffs2.c     |    3 ++-
 recv_image.c     |    2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)
Artem Bityutskiy - Sept. 24, 2010, 12:24 p.m.
On Thu, 2010-09-23 at 21:52 -0400, Mike Frysinger wrote:
> Kill off duplicated min() defines and convert to the common.h one.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Pushed, thanks.

Patch

diff --git a/compr_zlib.c b/compr_zlib.c
index dda3e40..0564f16 100644
--- a/compr_zlib.c
+++ b/compr_zlib.c
@@ -39,10 +39,9 @@ 
 #include <stdio.h>
 #include <asm/types.h>
 #include <linux/jffs2.h>
+#include "common.h"
 #include "compr.h"
 
-#define min(x,y) ((x)<(y)?(x):(y))
-
 /* Plan: call deflate() with avail_in == *sourcelen,
    avail_out = *dstlen - 12 and flush == Z_FINISH.
    If it doesn't manage to finish,	call it again with
diff --git a/include/common.h b/include/common.h
index 03e6f7c..f2b7b6b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -34,6 +34,7 @@  extern "C" {
 #endif
 
 #define MIN(a ,b) ((a) < (b) ? (a) : (b))
+#define min(a, b) MIN(a, b) /* glue for linux kernel source */
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 /* Verbose messages */
diff --git a/jffs-dump.c b/jffs-dump.c
index 31cdad2..3176469 100644
--- a/jffs-dump.c
+++ b/jffs-dump.c
@@ -14,6 +14,8 @@ 
 #include <linux/types.h>
 #include <asm/byteorder.h>
 
+#include "common.h"
+
 #define BLOCK_SIZE 1024
 #define JFFS_MAGIC 0x34383931 /* "1984" */
 #define JFFS_MAX_NAME_LEN 256
@@ -32,8 +34,6 @@ 
 #define JFFS_MAGIC_BITMASK 0x34383931
 #define JFFS_DIRTY_BITMASK 0x00000000
 
-#define min(x,y) (x) > (y) ? (y) : (x)
-
 struct jffs_raw_inode
 {
 	uint32_t magic;    /* A constant magic number.  */
diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c
index 5c18eb1..c83b725 100644
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -72,13 +72,14 @@ 
 #include <crc32.h>
 #include "rbtree.h"
 
+#include "common.h"
+
 /* Do not use the weird XPG version of basename */
 #undef basename
 
 //#define DMALLOC
 //#define mkfs_debug_msg    error_msg
 #define mkfs_debug_msg(a...)	{ }
-#define min(x,y) ({ typeof((x)) _x = (x); typeof((y)) _y = (y); (_x>_y)?_y:_x; })
 
 #define PAD(x) (((x)+3)&~3)
 
diff --git a/recv_image.c b/recv_image.c
index 617711c..6d27f3b 100644
--- a/recv_image.c
+++ b/recv_image.c
@@ -20,7 +20,7 @@ 
 #include "mtd/mtd-user.h"
 #include "mcast_image.h"
 
-#define min(x,y) (  (x)>(y)?(y):(x) )
+#include "common.h"
 
 #define WBUF_SIZE 4096
 struct eraseblock {