]> git.itanic.dy.fi Git - rrdd/commitdiff
utils.h: min() max() cleanup
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Fri, 28 Oct 2016 17:33:35 +0000 (20:33 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Fri, 28 Oct 2016 17:33:35 +0000 (20:33 +0300)
min() and max() macros belong to utils.h. They should also be lower
case, just like the rest of the world tends to have them.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
onewire_parser.c
process.c
utils.h

index 834ea9a624068e3bb8b47088841f6ede5513b279..effd097619f0f1421e2a0b2bc5f546c42198b692 100644 (file)
@@ -215,7 +215,7 @@ undefined:
                }
 
                /* The data from OWNET_read appears to not be NULL terminated */
                }
 
                /* The data from OWNET_read appears to not be NULL terminated */
-               memcpy(buf, tmp, MIN(ret, sizeof(buf) -1));
+               memcpy(buf, tmp, min(ret, sizeof(buf) -1));
                free(tmp);
                buf[ret] = 0;
 
                free(tmp);
                buf[ret] = 0;
 
index 1b06e598c04ee58c5a8e0ebbc53c298c45b44554..98033f0a5f4bc5a0650c4f7e94cc54a9fa2ef310 100644 (file)
--- a/process.c
+++ b/process.c
@@ -9,6 +9,7 @@
 
 #include "process.h"
 #include "debug.h"
 
 #include "process.h"
 #include "debug.h"
+#include "utils.h"
 
 static int epoll_fd;
 static unsigned int max_jobs;
 
 static int epoll_fd;
 static unsigned int max_jobs;
@@ -480,7 +481,6 @@ int run_piped_stream(const char *cmd, char *const argv[],
  * Forks a child and executes a command to run on parallel
  */
 
  * Forks a child and executes a command to run on parallel
  */
 
-#define max(a,b) (a) < (b) ? (b) : (a)
 #define BUF_SIZE (128*1024)
 int run(const char *cmd, char *const argv[])
 {
 #define BUF_SIZE (128*1024)
 int run(const char *cmd, char *const argv[])
 {
diff --git a/utils.h b/utils.h
index 3269e7d3bfbe0d5c31db54cf3b16617f79ac614e..40c212d93b4c67a90f5f36cc128aecb9007d7f28 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -1,7 +1,8 @@
 #ifndef _UTILS_H_
 #define _UTILS_H_
 
 #ifndef _UTILS_H_
 #define _UTILS_H_
 
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define max(a,b) (a) < (b) ? (b) : (a)
 
 #define ARRAY_SIZE(a) (sizeof(a) / (sizeof((a)[0])))
 
 
 #define ARRAY_SIZE(a) (sizeof(a) / (sizeof((a)[0])))