You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/08 18:58:51 UTC

[incubator-nuttx] 01/04: fs: fully parenthesize MIN and MAX macros

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit cd41ed9b6d8b968d535ba50ed0bbacb1ab314952
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Tue Dec 8 18:29:58 2020 +0200

    fs: fully parenthesize MIN and MAX macros
    
    Signed-off-by: Juha Niskanen <ju...@haltian.com>
---
 fs/fat/fs_fat32.h         | 14 --------------
 fs/fat/fs_fat32dirent.c   |  8 ++++++++
 fs/hostfs/hostfs.h        | 10 ----------
 fs/nxffs/nxffs.h          |  4 ++--
 fs/procfs/fs_procfsutil.c | 13 +++++--------
 fs/smartfs/smartfs.h      | 10 ----------
 6 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/fs/fat/fs_fat32.h b/fs/fat/fs_fat32.h
index c88179d..f646b1a 100644
--- a/fs/fat/fs_fat32.h
+++ b/fs/fat/fs_fat32.h
@@ -983,20 +983,6 @@ struct fat_dirinfo_s
   struct fs_fatdir_s dir;          /* Used with opendir, readdir, etc. */
 };
 
-/* Generic helper macros ****************************************************/
-
-#ifndef MIN
-#  define MIN(a,b) (a < b ? a : b)
-#endif
-
-#ifndef MAX
-#  define MAX(a,b) (a > b ? a : b)
-#endif
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c
index 8ba2aae..f8a7d58 100644
--- a/fs/fat/fs_fat32dirent.c
+++ b/fs/fat/fs_fat32dirent.c
@@ -72,6 +72,14 @@
 #include "fs_fat32.h"
 
 /****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef MIN
+#  define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+/****************************************************************************
  * Private Types
  ****************************************************************************/
 
diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h
index 47053b2..a796d4e 100644
--- a/fs/hostfs/hostfs.h
+++ b/fs/hostfs/hostfs.h
@@ -52,16 +52,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Quasi-standard definitions */
-
-#ifndef MIN
-#  define MIN(a,b)          (a < b ? a : b)
-#endif
-
-#ifndef MAX
-#  define MAX(a,b)          (a > b ? a : b)
-#endif
-
 #define HOSTFS_MAX_PATH     256
 
 /****************************************************************************
diff --git a/fs/nxffs/nxffs.h b/fs/nxffs/nxffs.h
index 610af72..1f9866d 100644
--- a/fs/nxffs/nxffs.h
+++ b/fs/nxffs/nxffs.h
@@ -191,11 +191,11 @@
 /* Quasi-standard definitions */
 
 #ifndef MIN
-#  define MIN(a,b)                (a < b ? a : b)
+#  define MIN(a,b)                ((a) < (b) ? (a) : (b))
 #endif
 
 #ifndef MAX
-#  define MAX(a,b)                (a > b ? a : b)
+#  define MAX(a,b)                ((a) > (b) ? (a) : (b))
 #endif
 
 /****************************************************************************
diff --git a/fs/procfs/fs_procfsutil.c b/fs/procfs/fs_procfsutil.c
index 9dd4f53..dbf7987 100644
--- a/fs/procfs/fs_procfsutil.c
+++ b/fs/procfs/fs_procfsutil.c
@@ -51,11 +51,7 @@
  ****************************************************************************/
 
 #ifndef MIN
-#  define MIN(a,b) ((a < b) ? a : b)
-#endif
-
-#ifndef MAX
-#  define MAX(a,b) ((a > b) ? a : b)
+#  define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
 /****************************************************************************
@@ -78,9 +74,10 @@
  *
  *   procfs_memcpy() is a helper function.  Each read() method should
  *   provide data in a local data buffer ('src' and 'srclen').  This
- *   will transfer the data to the user receive buffer ('dest' and 'destlen'),
- *   respecting both (1) the size of the destination buffer so that it will
- *   write beyond the user receiver and (1) the file position, 'offset'.
+ *   will transfer the data to the user receive buffer ('dest' and
+ *   'destlen'), respecting both (1) the size of the destination buffer so
+ *   that it will write beyond the user receiver and (1) the file position,
+ *   'offset'.
  *
  *   This function will skip over data until the under of bytes specified
  *   by 'offset' have been skipped.  Then it will transfer data from the
diff --git a/fs/smartfs/smartfs.h b/fs/smartfs/smartfs.h
index 3b887ff..f1ed3bb 100644
--- a/fs/smartfs/smartfs.h
+++ b/fs/smartfs/smartfs.h
@@ -176,16 +176,6 @@
 
 #define SMART_MAGICSIZE           4
 
-/* Quasi-standard definitions */
-
-#ifndef MIN
-#  define MIN(a,b)                (a < b ? a : b)
-#endif
-
-#ifndef MAX
-#  define MAX(a,b)                (a > b ? a : b)
-#endif
-
 /* Underlying MTD Block driver access functions */
 
 #define FS_BOPS(f)        (f)->fs_blkdriver->u.i_bops