]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Use std::min/std::max instead of MIN/MAX macros
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 15 Aug 2019 18:49:53 +0000 (20:49 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 15 Aug 2019 18:49:53 +0000 (20:49 +0200)
src/ccache.cpp
src/ccache.hpp
src/compr_zstd.cpp
src/manifest.cpp
src/result.cpp
src/stats.cpp
src/util.cpp

index 2063492298deff5b1fd462cf118641f0cfd13797..26433531908c3d746e6b1ff0bce5eb7ed71515d8 100644 (file)
@@ -3737,7 +3737,8 @@ ccache(int argc, char* argv[])
   cc_log("Hostname: %s", get_hostname());
   cc_log("Working directory: %s", get_current_working_dir());
 
-  g_config.set_limit_multiple(MIN(MAX(g_config.limit_multiple(), 0.0), 1.0));
+  g_config.set_limit_multiple(
+    std::min(std::max(g_config.limit_multiple(), 0.0), 1.0));
 
   MTR_BEGIN("main", "guess_compiler");
   guessed_compiler = guess_compiler(orig_args->argv[0]);
index 4052e6f93b5c28cf1671e1057ba7a86dd8d78633..b159a236c4f5edf08a1cb7bf97b3d7d19df73000 100644 (file)
@@ -329,10 +329,3 @@ void add_exe_ext_if_no_to_fullpath(char* full_path_win_ext,
 #  define DIR_DELIM_CH '/'
 #  define PATH_DELIM ":"
 #endif
-
-#ifndef MAX
-#  define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-#ifndef MIN
-#  define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
index 005c3f0e728e01e3a92d88e7803b5ab09e98071b..3f726c7f71a1c9c8b89beadfdbba8087940d6928 100644 (file)
@@ -19,6 +19,7 @@
 #include "ccache.hpp"
 #include "compression.hpp"
 
+#include <algorithm>
 #include <zstd.h>
 
 #define DEFAULT_ZSTD_COMPRESSION_LEVEL -1
@@ -59,7 +60,7 @@ compr_zstd_init(FILE* output, int8_t level, XXH64_state_t* checksum)
     level = 1;
   }
 
-  state->compression_level = MIN(level, ZSTD_maxCLevel());
+  state->compression_level = std::min<int>(level, ZSTD_maxCLevel());
   if (state->compression_level != level) {
     cc_log("Using compression level %d (max libzstd level) instead of %d",
            state->compression_level,
index 2b9091f9cedb4806f5e55eac6ce84470876c1140..dc2cc501925e01b21b4bfea65b000772dfc60c8b 100644 (file)
@@ -596,7 +596,8 @@ get_file_info_index(struct manifest* mf,
 
   struct stat file_stat;
   if (stat(path, &file_stat) != -1) {
-    if (time_of_compilation > MAX(file_stat.st_mtime, file_stat.st_ctime)) {
+    if (time_of_compilation
+        > std::max(file_stat.st_mtime, file_stat.st_ctime)) {
       fi.mtime = file_stat.st_mtime;
       fi.ctime = file_stat.st_ctime;
     } else {
index 25762310a1595ee1577a1285e311401fabdacb5f..c7e152e0a66407b05b46d8b9c6cfc04b47288106 100644 (file)
@@ -234,7 +234,7 @@ read_embedded_file_entry(struct decompressor* decompressor,
         char buf[READ_BUFFER_SIZE];
         size_t remain = file_len;
         while (remain > 0) {
-          size_t n = MIN(remain, sizeof(buf));
+          size_t n = std::min(remain, sizeof(buf));
           READ_BYTES(buf, n);
           if (fwrite(buf, 1, n, subfile) != n) {
             goto out;
@@ -254,7 +254,7 @@ read_embedded_file_entry(struct decompressor* decompressor,
     char buf[READ_BUFFER_SIZE];
     size_t remain = file_len;
     while (remain > 0) {
-      size_t n = MIN(remain, sizeof(buf));
+      size_t n = std::min(remain, sizeof(buf));
       READ_BYTES(buf, n);
       remain -= n;
     }
@@ -521,7 +521,7 @@ write_embedded_file_entry(struct compressor* compressor,
   }
   remain = file->size;
   while (remain > 0) {
-    size_t n = MIN(remain, sizeof(buf));
+    size_t n = std::min(remain, sizeof(buf));
     if (fread(buf, 1, n, f) != n) {
       goto error;
     }
index bd02ef9c381b26448f207a495a9fe9a614895d91..9f0727c1ae2fa097dfd3a69a709eefe2d230c057 100644 (file)
@@ -272,7 +272,8 @@ stats_collect(struct counters* counters, time_t* last_updated)
 
     counters->data[STATS_ZEROTIMESTAMP] = 0; // Don't add
     stats_read(fname, counters);
-    zero_timestamp = MAX(counters->data[STATS_ZEROTIMESTAMP], zero_timestamp);
+    zero_timestamp =
+      std::max(counters->data[STATS_ZEROTIMESTAMP], zero_timestamp);
     if (stat(fname, &st) == 0 && st.st_mtime > *last_updated) {
       *last_updated = st.st_mtime;
     }
index 7d5153d7d960c5e90d391cd9c21ae2949c4e53bf..d7226ebc6f959c4e39ac5681a6e83f3c7266141b 100644 (file)
@@ -221,7 +221,7 @@ vlog(const char* format, va_list ap, bool log_updated_time)
     char buf[8192];
     int len = vsnprintf(buf, sizeof(buf), format, aq);
     if (len >= 0) {
-      append_to_debug_log(buf, MIN((size_t)len, sizeof(buf) - 1));
+      append_to_debug_log(buf, std::min((size_t)len, sizeof(buf) - 1));
       append_to_debug_log("\n", 1);
     }
   }