]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Use booleans for truth values
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 8 Jan 2012 14:29:19 +0000 (15:29 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 8 Jan 2012 14:29:19 +0000 (15:29 +0100)
manifest.c
test/framework.c
test/framework.h

index ae6c2ff4a52131a7ac6e32bb852fb92a0b533b01..5b2169816cf87b53e911ed9036b03b18e13cd729 100644 (file)
@@ -66,7 +66,7 @@ static const uint32_t MAGIC = 0x63436d46U;
 static const uint8_t  VERSION = 0;
 static const uint32_t MAX_MANIFEST_ENTRIES = 100;
 
-#define static_assert(e) do { enum { static_assert__ = 1/(e) }; } while (0)
+#define static_assert(e) do { enum { static_assert__ = 1/(e) }; } while (false)
 
 struct file_info {
        /* Index to n_files. */
@@ -155,7 +155,7 @@ free_manifest(struct manifest *mf)
                        (var) <<= 8; \
                        (var) |= ch_ & 0xFF; \
                } \
-       } while (0)
+       } while (false)
 
 #define READ_STR(var) \
        do { \
@@ -176,7 +176,7 @@ free_manifest(struct manifest *mf)
                        goto error; \
                } \
                (var) = x_strdup(buf_); \
-       } while (0)
+       } while (false)
 
 #define READ_BYTES(n, var) \
        do { \
@@ -189,7 +189,7 @@ free_manifest(struct manifest *mf)
                        } \
                        (var)[i_] = ch_; \
                } \
-       } while (0)
+       } while (false)
 
 static struct manifest *
 create_empty_manifest(void)
@@ -286,14 +286,14 @@ error:
                                goto error; \
                        } \
                } \
-       } while (0)
+       } while (false)
 
 #define WRITE_STR(var) \
        do { \
                if (gzputs(f, var) == EOF || gzputc(f, '\0') == EOF) { \
                        goto error; \
                } \
-       } while (0)
+       } while (false)
 
 #define WRITE_BYTES(n, var) \
        do { \
@@ -303,7 +303,7 @@ error:
                                goto error; \
                        } \
                } \
-       } while (0)
+       } while (false)
 
 static int
 write_manifest(gzFile f, const struct manifest *mf)
index fd6ce721d008da9e81ffdf877f2deb234b2e4d08..bbb0480099f696ebf8489677ebd98b37a07339e3 100644 (file)
@@ -170,13 +170,13 @@ cct_check_failed(const char *file, int line, const char *what,
        fprintf(stderr, "\n");
 }
 
-int
+bool
 cct_check_int_eq(const char *file, int line, const char *expression,
                  int64_t expected, int64_t actual)
 {
        if (expected == actual) {
                cct_check_passed(file, line, expression);
-               return 1;
+               return true;
        } else {
 #ifdef HAVE_LONG_LONG
                char *exp_str = format("%lld", (long long)expected);
@@ -188,27 +188,27 @@ cct_check_int_eq(const char *file, int line, const char *expression,
                cct_check_failed(file, line, expression, exp_str, act_str);
                free(exp_str);
                free(act_str);
-               return 0;
+               return false;
        }
 }
 
-int
+bool
 cct_check_str_eq(const char *file, int line, const char *expression,
-                 const char *expected, const char *actual, int free1,
-                 int free2)
+                 const char *expected, const char *actual, bool free1,
+                 bool free2)
 {
-       int result;
+       bool result;
 
        if (expected && actual && str_eq(actual, expected)) {
                cct_check_passed(file, line, expression);
-               result = 1;
+               result = true;
        } else {
                char *exp_str = expected ? format("\"%s\"", expected) : x_strdup("(null)");
                char *act_str = actual ? format("\"%s\"", actual) : x_strdup("(null)");
                cct_check_failed(file, line, expression, exp_str, act_str);
                free(exp_str);
                free(act_str);
-               result = 0;
+               result = false;
        }
 
        if (free1) {
@@ -220,23 +220,23 @@ cct_check_str_eq(const char *file, int line, const char *expression,
        return result;
 }
 
-int
+bool
 cct_check_args_eq(const char *file, int line, const char *expression,
                   struct args *expected, struct args *actual,
-                  int free1, int free2)
+                  bool free1, bool free2)
 {
-       int result;
+       bool result;
 
        if (expected && actual && args_equal(actual, expected)) {
                cct_check_passed(file, line, expression);
-               result = 1;
+               result = true;
        } else {
                char *exp_str = expected ? args_to_string(expected) : x_strdup("(null)");
                char *act_str = actual ? args_to_string(actual) : x_strdup("(null)");
                cct_check_failed(file, line, expression, exp_str, act_str);
                free(exp_str);
                free(act_str);
-               result = 0;
+               result = false;
        }
 
        if (free1) {
index ac86b5d3aa45207ed7b18216b5a5e69df648b9a0..fc9ff8df06c6cae68432933429a68e28fe8ed093 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2011 Joel Rosdahl
+ * Copyright (C) 2010-2012 Joel Rosdahl
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -58,7 +58,7 @@
                        cct_suite_end(); \
                        return _test_counter; \
                } \
-       } while (0)
+       } while (false)
 
 #define CHECK(assertion) \
        CHECKM(assertion, NULL)
@@ -70,7 +70,7 @@
                        cct_suite_end(); \
                        return _test_counter; \
                } \
-       } while (0)
+       } while (false)
 
 /*****************************************************************************/
 
                        cct_suite_end(); \
                        return _test_counter; \
                } \
-       } while (0)
+       } while (false)
 
 /*****************************************************************************/
 
 #define CHECK_STR_EQ(expected, actual) \
-       CHECK_POINTER_EQ_BASE(str, expected, actual, 0, 0)
+       CHECK_POINTER_EQ_BASE(str, expected, actual, false, false)
 
 #define CHECK_STR_EQ_FREE1(expected, actual) \
-       CHECK_POINTER_EQ_BASE(str, expected, actual, 1, 0)
+       CHECK_POINTER_EQ_BASE(str, expected, actual, true, false)
 
 #define CHECK_STR_EQ_FREE2(expected, actual) \
-       CHECK_POINTER_EQ_BASE(str, expected, actual, 0, 1)
+       CHECK_POINTER_EQ_BASE(str, expected, actual, false, true)
 
 #define CHECK_STR_EQ_FREE12(expected, actual) \
-       CHECK_POINTER_EQ_BASE(str, expected, actual, 1, 1)
+       CHECK_POINTER_EQ_BASE(str, expected, actual, true, true)
 
 /*****************************************************************************/
 
 #define CHECK_ARGS_EQ(expected, actual) \
-       CHECK_POINTER_EQ_BASE(args, expected, actual, 0, 0)
+       CHECK_POINTER_EQ_BASE(args, expected, actual, false, false)
 
 #define CHECK_ARGS_EQ_FREE1(expected, actual) \
-       CHECK_POINTER_EQ_BASE(args, expected, actual, 1, 0)
+       CHECK_POINTER_EQ_BASE(args, expected, actual, true, false)
 
 #define CHECK_ARGS_EQ_FREE2(expected, actual) \
-       CHECK_POINTER_EQ_BASE(args, expected, actual, 0, 1)
+       CHECK_POINTER_EQ_BASE(args, expected, actual, false, true)
 
 #define CHECK_ARGS_EQ_FREE12(expected, actual) \
-       CHECK_POINTER_EQ_BASE(args, expected, actual, 1, 1)
+       CHECK_POINTER_EQ_BASE(args, expected, actual, true, true)
 
 /*****************************************************************************/
 
@@ -124,14 +124,14 @@ void cct_test_end(void);
 void cct_check_passed(const char *file, int line, const char *assertion);
 void cct_check_failed(const char *file, int line, const char *assertion,
                       const char *expected, const char *actual);
-int cct_check_int_eq(const char *file, int line, const char *expression,
-                     int64_t expected, int64_t actual);
-int cct_check_str_eq(const char *file, int line, const char *expression,
-                     const char *expected, const char *actual, int free1,
-                     int free2);
-int cct_check_args_eq(const char *file, int line, const char *expression,
-                      struct args *expected, struct args *actual,
-                      int free1, int free2);
+bool cct_check_int_eq(const char *file, int line, const char *expression,
+                      int64_t expected, int64_t actual);
+bool cct_check_str_eq(const char *file, int line, const char *expression,
+                      const char *expected, const char *actual, bool free1,
+                      bool free2);
+bool cct_check_args_eq(const char *file, int line, const char *expression,
+                       struct args *expected, struct args *actual,
+                       bool free1, bool free2);
 void cct_chdir(const char *path);
 void cct_wipe(const char *path);
 void cct_create_fresh_dir(const char *path);