mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/5] rafactor _*MAX, *_MIN macros
@ 2015-01-21  5:09 Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 1/5] fs: ubifs: remove redundant macro defines Masahiro Yamada
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox




Masahiro Yamada (5):
  fs: ubifs: remove redundant macro defines
  lib: decompress: remove redundant INT_MAX define
  linux/kernel.h: move *_MAX, *_MIN macros
  linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN
  linux/kernel.h: add more *_MAX, *_MIN macros

 fs/parseopt.c            |  2 +-
 fs/ubifs/ubifs.h         |  4 ----
 include/common.h         | 13 -------------
 include/linux/kernel.h   | 27 +++++++++++++++++++++++++++
 lib/decompress_bunzip2.c |  4 ----
 5 files changed, 28 insertions(+), 22 deletions(-)

-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/5] fs: ubifs: remove redundant macro defines
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
@ 2015-01-21  5:09 ` Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 2/5] lib: decompress: remove redundant INT_MAX define Masahiro Yamada
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox

fs/ubifs/ubifs.h includes <common.h> and the macros INT_MAX, INT_MIN,
LLONG_MAX are already defined there.

The same defines in fs/ubifs/ubifs.h are redundant.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 fs/ubifs/ubifs.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index b4a9d76..c025d34 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -318,10 +318,6 @@ struct file {
 #define MAX_LFS_FILESIZE 	0x7fffffffffffffffUL
 #endif
 
-#define INT_MAX		((int)(~0U>>1))
-#define INT_MIN		(-INT_MAX - 1)
-#define LLONG_MAX	((long long)(~0ULL>>1))
-
 /*
  * These are the fs-independent mount-flags: up to 32 flags are supported
  */
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/5] lib: decompress: remove redundant INT_MAX define
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 1/5] fs: ubifs: remove redundant macro defines Masahiro Yamada
@ 2015-01-21  5:09 ` Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 3/5] linux/kernel.h: move *_MAX, *_MIN macros Masahiro Yamada
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox

lib/decompress_bunzip2.c includes <common.h> and INT_MAX is already
defined there.  The definition in this file is redundant.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 lib/decompress_bunzip2.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 0ca2dcd..ee2862b 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -53,10 +53,6 @@
 #include <bunzip2.h>
 #endif /* STATIC */
 
-#ifndef INT_MAX
-#define INT_MAX 0x7fffffff
-#endif
-
 /* Constants for Huffman coding */
 #define MAX_GROUPS		6
 #define GROUP_SIZE   		50	/* 64 would have been more efficient */
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/5] linux/kernel.h: move *_MAX, *_MIN macros
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 1/5] fs: ubifs: remove redundant macro defines Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 2/5] lib: decompress: remove redundant INT_MAX define Masahiro Yamada
@ 2015-01-21  5:09 ` Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 4/5] linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN Masahiro Yamada
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox

Linux defines *_MAX, *_MIN macros in include/linux/kernel.h.
Let's follow this way to slim down the common.h.

This change should have no impact because include/common.h already
includes <linux/kernel.h>.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 include/common.h       | 13 -------------
 include/linux/kernel.h | 13 +++++++++++++
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/common.h b/include/common.h
index fca9798..f3f5c0f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -225,19 +225,6 @@ static inline char *shell_expand(char *str)
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
-#define USHORT_MAX	((u16)(~0U))
-#define SHORT_MAX	((s16)(USHORT_MAX>>1))
-#define SHORT_MIN	(-SHORT_MAX - 1)
-#define INT_MAX		((int)(~0U>>1))
-#define INT_MIN		(-INT_MAX - 1)
-#define UINT_MAX	(~0U)
-#define LONG_MAX	((long)(~0UL>>1))
-#define LONG_MIN	(-LONG_MAX - 1)
-#define ULONG_MAX	(~0UL)
-#define LLONG_MAX	((long long)(~0ULL>>1))
-#define LLONG_MIN	(-LLONG_MAX - 1)
-#define ULLONG_MAX	(~0ULL)
-
 #define PAGE_SIZE	4096
 #define PAGE_SHIFT	12
 #define PAGE_ALIGN(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 98f12e1..33cf62e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -4,6 +4,19 @@
 #include <linux/compiler.h>
 #include <linux/barebox-wrapper.h>
 
+#define USHORT_MAX	((u16)(~0U))
+#define SHORT_MAX	((s16)(USHORT_MAX>>1))
+#define SHORT_MIN	(-SHORT_MAX - 1)
+#define INT_MAX		((int)(~0U>>1))
+#define INT_MIN		(-INT_MAX - 1)
+#define UINT_MAX	(~0U)
+#define LONG_MAX	((long)(~0UL>>1))
+#define LONG_MIN	(-LONG_MAX - 1)
+#define ULONG_MAX	(~0UL)
+#define LLONG_MAX	((long long)(~0ULL>>1))
+#define LLONG_MIN	(-LLONG_MAX - 1)
+#define ULLONG_MAX	(~0ULL)
+
 /*
  * This looks more complex than it should be. But we need to
  * get the type for the ~ right in round_down (it needs to be
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/5] linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
                   ` (2 preceding siblings ...)
  2015-01-21  5:09 ` [PATCH 3/5] linux/kernel.h: move *_MAX, *_MIN macros Masahiro Yamada
@ 2015-01-21  5:09 ` Masahiro Yamada
  2015-01-21  5:09 ` [PATCH 5/5] linux/kernel.h: add more *_MAX, *_MIN macros Masahiro Yamada
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox

Linux uses SHRT_* instead of SHORT_*.  The <limits.h> of C does
the same.  Let's follow this standard.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 fs/parseopt.c          | 2 +-
 include/linux/kernel.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/parseopt.c b/fs/parseopt.c
index fbe53cf..12dbe18 100644
--- a/fs/parseopt.c
+++ b/fs/parseopt.c
@@ -26,7 +26,7 @@ again:
 	}
 
 	v = simple_strtoul(start + optlen + 1, &endp, 0);
-	if (v > USHORT_MAX)
+	if (v > USHRT_MAX)
 		return;
 
 	if (*endp == ',' || *endp == '\0')
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 33cf62e..4d7e41e 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -4,9 +4,9 @@
 #include <linux/compiler.h>
 #include <linux/barebox-wrapper.h>
 
-#define USHORT_MAX	((u16)(~0U))
-#define SHORT_MAX	((s16)(USHORT_MAX>>1))
-#define SHORT_MIN	(-SHORT_MAX - 1)
+#define USHRT_MAX	((u16)(~0U))
+#define SHRT_MAX	((s16)(USHRT_MAX>>1))
+#define SHRT_MIN	((s16)(-SHRT_MAX - 1))
 #define INT_MAX		((int)(~0U>>1))
 #define INT_MIN		(-INT_MAX - 1)
 #define UINT_MAX	(~0U)
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/5] linux/kernel.h: add more *_MAX, *_MIN macros
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
                   ` (3 preceding siblings ...)
  2015-01-21  5:09 ` [PATCH 4/5] linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN Masahiro Yamada
@ 2015-01-21  5:09 ` Masahiro Yamada
  2015-01-21  6:30 ` [PATCH 0/5] rafactor _*MAX, " Jean-Christophe PLAGNIOL-VILLARD
  2015-01-21 13:59 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2015-01-21  5:09 UTC (permalink / raw)
  To: barebox

Imported from Linux 3.19-rc5.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

 include/linux/kernel.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4d7e41e..a039590 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -16,6 +16,20 @@
 #define LLONG_MAX	((long long)(~0ULL>>1))
 #define LLONG_MIN	(-LLONG_MAX - 1)
 #define ULLONG_MAX	(~0ULL)
+#define SIZE_MAX	(~(size_t)0)
+
+#define U8_MAX		((u8)~0U)
+#define S8_MAX		((s8)(U8_MAX>>1))
+#define S8_MIN		((s8)(-S8_MAX - 1))
+#define U16_MAX		((u16)~0U)
+#define S16_MAX		((s16)(U16_MAX>>1))
+#define S16_MIN		((s16)(-S16_MAX - 1))
+#define U32_MAX		((u32)~0U)
+#define S32_MAX		((s32)(U32_MAX>>1))
+#define S32_MIN		((s32)(-S32_MAX - 1))
+#define U64_MAX		((u64)~0ULL)
+#define S64_MAX		((s64)(U64_MAX>>1))
+#define S64_MIN		((s64)(-S64_MAX - 1))
 
 /*
  * This looks more complex than it should be. But we need to
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/5] rafactor _*MAX, *_MIN macros
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
                   ` (4 preceding siblings ...)
  2015-01-21  5:09 ` [PATCH 5/5] linux/kernel.h: add more *_MAX, *_MIN macros Masahiro Yamada
@ 2015-01-21  6:30 ` Jean-Christophe PLAGNIOL-VILLARD
  2015-01-21 13:59 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2015-01-21  6:30 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: barebox

Ack common.h should nearly been drop ASAP

Best Regards,
J.
> On Jan 21, 2015, at 1:09 PM, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> 
> 
> 
> 
> Masahiro Yamada (5):
>  fs: ubifs: remove redundant macro defines
>  lib: decompress: remove redundant INT_MAX define
>  linux/kernel.h: move *_MAX, *_MIN macros
>  linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN
>  linux/kernel.h: add more *_MAX, *_MIN macros
> 
> fs/parseopt.c            |  2 +-
> fs/ubifs/ubifs.h         |  4 ----
> include/common.h         | 13 -------------
> include/linux/kernel.h   | 27 +++++++++++++++++++++++++++
> lib/decompress_bunzip2.c |  4 ----
> 5 files changed, 28 insertions(+), 22 deletions(-)
> 
> -- 
> 1.9.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 0/5] rafactor _*MAX, *_MIN macros
  2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
                   ` (5 preceding siblings ...)
  2015-01-21  6:30 ` [PATCH 0/5] rafactor _*MAX, " Jean-Christophe PLAGNIOL-VILLARD
@ 2015-01-21 13:59 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2015-01-21 13:59 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: barebox

On Wed, Jan 21, 2015 at 02:09:14PM +0900, Masahiro Yamada wrote:
> 
> 
> 
> Masahiro Yamada (5):
>   fs: ubifs: remove redundant macro defines
>   lib: decompress: remove redundant INT_MAX define
>   linux/kernel.h: move *_MAX, *_MIN macros
>   linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN
>   linux/kernel.h: add more *_MAX, *_MIN macros
> 
>  fs/parseopt.c            |  2 +-
>  fs/ubifs/ubifs.h         |  4 ----
>  include/common.h         | 13 -------------
>  include/linux/kernel.h   | 27 +++++++++++++++++++++++++++
>  lib/decompress_bunzip2.c |  4 ----
>  5 files changed, 28 insertions(+), 22 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-01-21 13:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21  5:09 [PATCH 0/5] rafactor _*MAX, *_MIN macros Masahiro Yamada
2015-01-21  5:09 ` [PATCH 1/5] fs: ubifs: remove redundant macro defines Masahiro Yamada
2015-01-21  5:09 ` [PATCH 2/5] lib: decompress: remove redundant INT_MAX define Masahiro Yamada
2015-01-21  5:09 ` [PATCH 3/5] linux/kernel.h: move *_MAX, *_MIN macros Masahiro Yamada
2015-01-21  5:09 ` [PATCH 4/5] linux/kernel.h: rename USHORT_MAX, SHORT_MAX, SHORT_MIN Masahiro Yamada
2015-01-21  5:09 ` [PATCH 5/5] linux/kernel.h: add more *_MAX, *_MIN macros Masahiro Yamada
2015-01-21  6:30 ` [PATCH 0/5] rafactor _*MAX, " Jean-Christophe PLAGNIOL-VILLARD
2015-01-21 13:59 ` Sascha Hauer

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