[rtems commit] Delete or rename MIN/MAX macros and defines

Sebastian Huber sebh at rtems.org
Fri Nov 21 08:05:07 UTC 2014


Module:    rtems
Branch:    master
Commit:    11925eef789566a226d8eaacbceb4d89df787ebc
Changeset: http://git.rtems.org/rtems/commit/?id=11925eef789566a226d8eaacbceb4d89df787ebc

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Nov 21 08:49:57 2014 +0100

Delete or rename MIN/MAX macros and defines

Include <sys/param.h> if necessary to get the MIN()/MAX() macros.

---

 c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c              |  4 +---
 .../lib/libbsp/powerpc/mvme5500/network/if_100MHz/GT64260eth.c |  2 --
 c/src/libchip/ide/ata_internal.h                               |  2 +-
 cpukit/libfs/src/dosfs/fat.h                                   |  5 +----
 cpukit/libfs/src/imfs/imfs_load_tar.c                          |  3 +--
 cpukit/libfs/src/pipe/fifo.c                                   |  4 +---
 cpukit/libmisc/untar/untar.c                                   |  4 +---
 cpukit/librpc/src/rpc/svc_udp.c                                |  2 +-
 cpukit/pppd/pppd.h                                             |  9 +--------
 testsuites/psxtests/psxaio02/init.c                            | 10 +++++-----
 testsuites/psxtests/psxaio03/init.c                            | 10 +++++-----
 testsuites/samples/fileio/init.c                               |  5 +----
 testsuites/sptests/sp48/init.c                                 |  8 ++++----
 testsuites/sptests/sp63/init.c                                 |  3 +--
 14 files changed, 24 insertions(+), 47 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c b/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c
index 9420b4e..e1e9e7d 100644
--- a/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c
+++ b/c/src/lib/libbsp/powerpc/gen5200/ide/pcmcia_ide.c
@@ -75,6 +75,7 @@
 /*                                                                     */
 /***********************************************************************/
 
+#include <sys/param.h>
 #include <rtems.h>
 #include <rtems/error.h>
 #include <rtems/score/sysstate.h>
@@ -88,9 +89,6 @@
 #include <libchip/ide_ctrl_io.h>
 #include <string.h>
 
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
 #define IDE_DMA_TEST            FALSE
 
 /* DMA supported PIO mode is broken */
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/network/if_100MHz/GT64260eth.c b/c/src/lib/libbsp/powerpc/mvme5500/network/if_100MHz/GT64260eth.c
index 2b5295b..fbabe98 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/network/if_100MHz/GT64260eth.c
+++ b/c/src/lib/libbsp/powerpc/mvme5500/network/if_100MHz/GT64260eth.c
@@ -900,8 +900,6 @@ static int txq_high_limit(struct GTeth_softc *sc)
 }
 #endif
 
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-
 static int GT64260eth_sendpacket(struct GTeth_softc *sc,struct mbuf *m)
 {
   volatile struct GTeth_desc *txd = &sc->txq_desc[sc->txq_lo];
diff --git a/c/src/libchip/ide/ata_internal.h b/c/src/libchip/ide/ata_internal.h
index 94b8890..887199d 100644
--- a/c/src/libchip/ide/ata_internal.h
+++ b/c/src/libchip/ide/ata_internal.h
@@ -15,6 +15,7 @@
 #ifndef __ATA_INTERNAL_H__
 #define __ATA_INTERNAL_H__
 
+#include <sys/param.h>
 #include <rtems.h>
 #include <sys/types.h>
 #include <rtems/libio.h>
@@ -45,7 +46,6 @@ extern "C" {
 #    define CT_LE_L(v) (v)
 #endif
 
-#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
 #define ATA_UNDEFINED_VALUE   (-1)
 
 /* Sector size for all ATA devices */
diff --git a/cpukit/libfs/src/dosfs/fat.h b/cpukit/libfs/src/dosfs/fat.h
index 26f0699..6b86679 100644
--- a/cpukit/libfs/src/dosfs/fat.h
+++ b/cpukit/libfs/src/dosfs/fat.h
@@ -22,6 +22,7 @@
 #ifndef __DOSFS_FAT_H__
 #define __DOSFS_FAT_H__
 
+#include <sys/param.h>
 #include <string.h>
 
 #include <rtems/seterr.h>
@@ -68,10 +69,6 @@ extern "C" {
 #    define CT_LE_L(v) (v)
 #endif
 
-#ifndef MIN
-#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
-#endif
-
 #define FAT_HASH_SIZE   2
 #define FAT_HASH_MODULE FAT_HASH_SIZE
 
diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c
index 0c4bb66..5b6f545 100644
--- a/cpukit/libfs/src/imfs/imfs_load_tar.c
+++ b/cpukit/libfs/src/imfs/imfs_load_tar.c
@@ -20,6 +20,7 @@
 
 #include "imfs.h"
 
+#include <sys/param.h>
 #include <sys/stat.h>
 #include <string.h>
 #include <tar.h>
@@ -28,8 +29,6 @@
 
 #define MAX_NAME_FIELD_SIZE      99
 
-#define MIN(a,b)   ((a)>(b)?(b):(a))
-
 int rtems_tarfs_load(
   const char *mountpoint,
   uint8_t *tar_image,
diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 2c8eb99..203b654 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -18,6 +18,7 @@
 #include "config.h"
 #endif
 
+#include <sys/param.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
@@ -29,9 +30,6 @@
 
 #include "pipe.h"
 
-
-#define MIN(a, b) ((a) < (b)? (a): (b))
-
 #define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
 #define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
 
diff --git a/cpukit/libmisc/untar/untar.c b/cpukit/libmisc/untar/untar.c
index 31af31c..04a2d89 100644
--- a/cpukit/libmisc/untar/untar.c
+++ b/cpukit/libmisc/untar/untar.c
@@ -23,6 +23,7 @@
 #include "config.h"
 #endif
 
+#include <sys/param.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -66,9 +67,6 @@
 
 #define MAX_NAME_FIELD_SIZE      99
 
-#define MIN(a,b)   ((a)>(b)?(b):(a))
-
-
 /**************************************************************************
  * This converts octal ASCII number representations into an
  * unsigned long.  Only support 32-bit numbers for now.
diff --git a/cpukit/librpc/src/rpc/svc_udp.c b/cpukit/librpc/src/rpc/svc_udp.c
index 8b7e167..bb99f4a 100644
--- a/cpukit/librpc/src/rpc/svc_udp.c
+++ b/cpukit/librpc/src/rpc/svc_udp.c
@@ -45,6 +45,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_udp.c,v 1.13 2000/01/27 23:
 #include "config.h"
 #endif
 
+#include <sys/param.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -54,7 +55,6 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/svc_udp.c,v 1.13 2000/01/27 23:
 #include <errno.h>
 
 #define rpc_buffer(xprt) ((xprt)->xp_p1)
-#define MAX(a, b)     ((a > b) ? a : b)
 
 static bool_t		svcudp_recv(SVCXPRT *xprt, struct rpc_msg *msg);
 static bool_t		svcudp_reply(SVCXPRT *xprt, struct rpc_msg *msg);
diff --git a/cpukit/pppd/pppd.h b/cpukit/pppd/pppd.h
index 8655f82..98c49e8 100644
--- a/cpukit/pppd/pppd.h
+++ b/cpukit/pppd/pppd.h
@@ -25,7 +25,7 @@
 #include <stdbool.h>		/* bool */
 #include <stdio.h>		/* for FILE */
 #include <limits.h>		/* for NGROUPS_MAX */
-#include <sys/param.h>		/* for MAXPATHLEN and BSD4_4, if defined */
+#include <sys/param.h>
 #include <sys/types.h>		/* for uint32_t, if defined */
 #include <sys/time.h>		/* for struct timeval */
 #include <net/ppp_defs.h>
@@ -653,11 +653,4 @@ extern void (*auth_linkdown_hook)(void);
 #endif /* defined(sun) || defined(SYSV) || defined(POSIX_SOURCE) */
 #endif /* SIGTYPE */
 
-#ifndef MIN
-#define MIN(a, b)	((a) < (b)? (a): (b))
-#endif
-#ifndef MAX
-#define MAX(a, b)	((a) > (b)? (a): (b))
-#endif
-
 #endif /* __PPP_H__ */
diff --git a/testsuites/psxtests/psxaio02/init.c b/testsuites/psxtests/psxaio02/init.c
index 89c4234..3c75a36 100644
--- a/testsuites/psxtests/psxaio02/init.c
+++ b/testsuites/psxtests/psxaio02/init.c
@@ -30,7 +30,7 @@ struct aiocb *create_aiocb(int fd);
 void free_aiocb(struct aiocb *aiocbp);
 
 #define BUFSIZE 32
-#define MAX 10
+#define FD_COUNT 10
 #define WRONG_FD 666
 
 struct aiocb *
@@ -59,8 +59,8 @@ free_aiocb (struct aiocb *aiocbp)
 void *
 POSIX_Init (void *argument)
 {
-  int fd[MAX];
-  struct aiocb *aiocbp[MAX+1];
+  int fd[FD_COUNT];
+  struct aiocb *aiocbp[FD_COUNT+1];
   int status, i, policy = SCHED_FIFO;
   char filename[BUFSIZE];
   struct sched_param param;
@@ -79,7 +79,7 @@ POSIX_Init (void *argument)
   
   puts ("Init: Open files");
 
-  for (i=0; i<MAX; i++)
+  for (i=0; i<FD_COUNT; i++)
     {
       sprintf (filename, "/tmp/aio_fildes%d",i);
       fd[i] = open (filename, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
@@ -175,7 +175,7 @@ POSIX_Init (void *argument)
 
   TEST_END();
 
-  for (i = 0; i < MAX; i++)
+  for (i = 0; i < FD_COUNT; i++)
     {
       close (fd[i]);
       free_aiocb (aiocbp[i]);      
diff --git a/testsuites/psxtests/psxaio03/init.c b/testsuites/psxtests/psxaio03/init.c
index eed3d4e..d8a13fa 100644
--- a/testsuites/psxtests/psxaio03/init.c
+++ b/testsuites/psxtests/psxaio03/init.c
@@ -30,7 +30,7 @@ const char rtems_test_name[] = "PSXAIO 3";
 struct aiocb *create_aiocb(int fd);
 void free_aiocb(struct aiocb *aiocbp);
 
-#define MAX 6
+#define FD_COUNT 6
 #define BUFSIZE 128
 
 struct aiocb *
@@ -60,8 +60,8 @@ free_aiocb (struct aiocb *aiocbp)
 void *
 POSIX_Init (void *argument)
 {
-  int fd[MAX];
-  struct aiocb *aiocbp[MAX+1];
+  int fd[FD_COUNT];
+  struct aiocb *aiocbp[FD_COUNT+1];
   int status, i, policy = SCHED_FIFO;
   char filename[BUFSIZE];
   struct sched_param param;
@@ -80,7 +80,7 @@ POSIX_Init (void *argument)
 
   puts (" Init: Open files ");
 
-  for (i=0; i<MAX; i++)
+  for (i=0; i<FD_COUNT; i++)
     {
       sprintf (filename, "/tmp/aio_fildes%d",i);
       fd[i] = open (filename, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO);
@@ -131,7 +131,7 @@ POSIX_Init (void *argument)
   
   TEST_END();
   
-  for (i = 0; i < MAX; i++)
+  for (i = 0; i < FD_COUNT; i++)
     {
       close (fd[i]);
       free_aiocb (aiocbp[i]);
diff --git a/testsuites/samples/fileio/init.c b/testsuites/samples/fileio/init.c
index 4dd00ed..07ec2c6 100644
--- a/testsuites/samples/fileio/init.c
+++ b/testsuites/samples/fileio/init.c
@@ -13,6 +13,7 @@
 
 #define CONFIGURE_INIT
 #include "system.h"
+#include <sys/param.h>
 #include <crypt.h>
 #include <stdio.h>
 #include <string.h>
@@ -214,10 +215,6 @@ fstab_t fs_table[] = {
   }
 };
 
-#ifndef MIN
-#define MIN(a,b) (((a) > (b)) ? (b) : (a))
-#endif
-
 #define USE_SHELL
 
 #ifdef USE_SHELL
diff --git a/testsuites/sptests/sp48/init.c b/testsuites/sptests/sp48/init.c
index e105528..701aa17 100644
--- a/testsuites/sptests/sp48/init.c
+++ b/testsuites/sptests/sp48/init.c
@@ -20,8 +20,8 @@ const char rtems_test_name[] = "SP 48";
 
 rtems_task Init(rtems_task_argument ignored);
 
-#define MAX 5000
-rtems_id Semaphores[MAX];
+#define SEMA_COUNT 5000
+rtems_id Semaphores[SEMA_COUNT];
 
 rtems_task Init(rtems_task_argument ignored)
 {
@@ -35,7 +35,7 @@ rtems_task Init(rtems_task_argument ignored)
     "Largest C program heap block available: %zu\n",
     malloc_free_space()
   );
-  for (i=0 ; i<MAX ; i++ ) {
+  for (i=0 ; i<SEMA_COUNT ; i++ ) {
     sc = rtems_semaphore_create(
       rtems_build_name('s', 'e', 'm', ' '),
       1,
@@ -57,7 +57,7 @@ rtems_task Init(rtems_task_argument ignored)
   }
 
   created = i;
-  if ( created == MAX )
+  if ( created == SEMA_COUNT )
     puts( "Created all semaphores allowed in this test" );
 
   printf( "%d semaphores created\n", i );
diff --git a/testsuites/sptests/sp63/init.c b/testsuites/sptests/sp63/init.c
index 9b6dd6f..6f1c837 100644
--- a/testsuites/sptests/sp63/init.c
+++ b/testsuites/sptests/sp63/init.c
@@ -23,8 +23,7 @@ void test_case_one(void);
 void test_case_two(void);
 void test_case_three(void);
 
-#define MAX 256
-uint32_t      Memory[MAX];
+uint32_t      Memory[256];
 Heap_Control  Heap;
 
 /*




More information about the vc mailing list