From 49b5a4d2e8e4fb1e4f67c2a368d8d2e3e76b765f Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 3 Dec 2014 22:20:45 +0100 Subject: [PATCH] Use stdbool.h's bool type instead of _Bool. That'll work with C++ as well. --- src/client/sock.c | 4 ++-- src/core/data.c | 6 +++--- src/core/plugin.c | 4 ++-- src/core/store.c | 4 ++-- src/core/store_lookup.c | 4 ++-- src/core/time.c | 3 ++- src/frontend/connection-private.h | 2 +- src/frontend/connection.c | 2 +- src/include/client/sock.h | 5 ++--- src/include/core/data.h | 5 +++-- src/include/core/plugin.h | 3 ++- src/include/core/store.h | 3 ++- src/include/frontend/sock.h | 3 ++- src/include/utils/avltree.h | 6 ++++-- src/include/utils/llist.h | 4 +++- src/liboconfig/utils.c | 3 ++- src/liboconfig/utils.h | 4 +++- src/plugins/backend/mk-livestatus.c | 2 +- src/plugins/timeseries/rrdtool.c | 2 +- src/tools/sysdb/input.h | 4 ++-- src/tools/sysdbd/main.c | 2 +- src/utils/avltree.c | 6 +++--- src/utils/channel.c | 6 +++--- src/utils/error.c | 8 ++++---- src/utils/llist.c | 2 +- 25 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/client/sock.c b/src/client/sock.c index 8602532..ef35166 100644 --- a/src/client/sock.c +++ b/src/client/sock.c @@ -56,7 +56,7 @@ struct sdb_client { char *address; int fd; - _Bool eof; + bool eof; }; /* @@ -327,7 +327,7 @@ sdb_client_recv(sdb_client_t *client, return (ssize_t)total; } /* sdb_client_recv */ -_Bool +bool sdb_client_eof(sdb_client_t *client) { if ((! client) || (client->fd < 0)) diff --git a/src/core/data.c b/src/core/data.c index 9f2b1f6..503db29 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -610,7 +610,7 @@ sdb_data_strcmp(const sdb_data_t *d1, const sdb_data_t *d2) #undef CMP_NULL } /* sdb_data_strcmp */ -_Bool +bool sdb_data_isnull(const sdb_data_t *datum) { if (! datum) @@ -626,7 +626,7 @@ sdb_data_isnull(const sdb_data_t *datum) return 0; } /* sdb_data_isnull */ -_Bool +bool sdb_data_inarray(const sdb_data_t *value, const sdb_data_t *array) { const void *values; @@ -839,7 +839,7 @@ sdb_data_format(const sdb_data_t *datum, char *buf, size_t buflen, int quoted) { char tmp[sdb_data_strlen(datum) + 1]; char *data = NULL; - _Bool is_null = 0; + bool is_null = 0; int ret = -1; size_t i, pos; diff --git a/src/core/plugin.c b/src/core/plugin.c index 79df55e..20fe61c 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -107,7 +107,7 @@ static sdb_plugin_ctx_t plugin_default_ctx = SDB_PLUGIN_CTX_INIT; static sdb_plugin_info_t plugin_default_info = SDB_PLUGIN_INFO_INIT; static pthread_key_t plugin_ctx_key; -static _Bool plugin_ctx_key_initialized = 0; +static bool plugin_ctx_key_initialized = 0; /* a list of the plugin contexts of all registered plugins */ static sdb_llist_t *all_plugins = NULL; @@ -1140,7 +1140,7 @@ sdb_plugin_log(int prio, const char *msg) sdb_llist_iter_t *iter; int ret = -1; - _Bool logged = 0; + bool logged = 0; if (! msg) return 0; diff --git a/src/core/store.c b/src/core/store.c index ad59a2e..25691dc 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -256,7 +256,7 @@ static sdb_type_t sdb_attribute_type = { */ static sdb_host_t * -lookup_host(const char *name, _Bool canonicalize) +lookup_host(const char *name, bool canonicalize) { sdb_host_t *host; char *cname; @@ -540,7 +540,7 @@ sdb_store_host(const char *name, sdb_time_t last_update) return status; } /* sdb_store_host */ -_Bool +bool sdb_store_has_host(const char *name) { sdb_host_t *host; diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index e1e0396..a95f587 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -92,7 +92,7 @@ expr_free_datum2(sdb_store_expr_t *e1, sdb_data_t *v1, * is enabled, compare the string values in case of a type mismatch. */ static int -match_cmp_value(int op, sdb_data_t *v1, sdb_data_t *v2, _Bool strcmp_fallback) +match_cmp_value(int op, sdb_data_t *v1, sdb_data_t *v2, bool strcmp_fallback) { int status; @@ -153,7 +153,7 @@ match_regex_value(int op, sdb_data_t *v, sdb_data_t *re) } /* match_regex_value */ static int -match_value(int op, sdb_data_t *v1, sdb_data_t *v2, _Bool strcmp_fallback) +match_value(int op, sdb_data_t *v1, sdb_data_t *v2, bool strcmp_fallback) { if ((op == MATCHER_REGEX) || (op == MATCHER_NREGEX)) return match_regex_value(op, v1, v2); diff --git a/src/core/time.c b/src/core/time.c index 5d34e18..d0ed0b8 100644 --- a/src/core/time.c +++ b/src/core/time.c @@ -34,6 +34,7 @@ #include +#include #include #include @@ -98,7 +99,7 @@ sdb_strfinterval(char *s, size_t len, sdb_time_t interval) size_t i; /* special case the optional fractional part for seconds */ - _Bool have_seconds = 0; + bool have_seconds = 0; struct { sdb_time_t interval; diff --git a/src/frontend/connection-private.h b/src/frontend/connection-private.h index 042091a..1e5e9e5 100644 --- a/src/frontend/connection-private.h +++ b/src/frontend/connection-private.h @@ -73,7 +73,7 @@ struct sdb_conn { /* user information */ char *username; /* NULL if the user has not been authenticated */ - _Bool ready; /* indicates that startup finished successfully */ + bool ready; /* indicates that startup finished successfully */ }; #define CONN(obj) ((sdb_conn_t *)(obj)) diff --git a/src/frontend/connection.c b/src/frontend/connection.c index 1d8b8b3..e384baf 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -49,7 +49,7 @@ */ static pthread_key_t conn_ctx_key; -static _Bool conn_ctx_key_initialized = 0; +static bool conn_ctx_key_initialized = 0; /* * private types diff --git a/src/include/client/sock.h b/src/include/client/sock.h index aeed8a2..638f862 100644 --- a/src/include/client/sock.h +++ b/src/include/client/sock.h @@ -30,13 +30,12 @@ #include "core/object.h" #include "core/data.h" - #include "frontend/proto.h" - #include "utils/strbuf.h" #include +#include #include #ifdef __cplusplus @@ -134,7 +133,7 @@ sdb_client_recv(sdb_client_t *client, * Returns true if end of file on the client connection was reached, that is, * if the remote side closed the connection. */ -_Bool +bool sdb_client_eof(sdb_client_t *client); #ifdef __cplusplus diff --git a/src/include/core/data.h b/src/include/core/data.h index 997cf9f..c179fea 100644 --- a/src/include/core/data.h +++ b/src/include/core/data.h @@ -31,6 +31,7 @@ #include "core/time.h" #include +#include #include #include @@ -161,7 +162,7 @@ sdb_data_strcmp(const sdb_data_t *d1, const sdb_data_t *d2); * either datum is NULL or if the type is SDB_TYPE_NULL or if the string or * binary datum is NULL. */ -_Bool +bool sdb_data_isnull(const sdb_data_t *datum); /* @@ -173,7 +174,7 @@ sdb_data_isnull(const sdb_data_t *datum); * elements of the first array are included in the second where order does not * matter. */ -_Bool +bool sdb_data_inarray(const sdb_data_t *value, const sdb_data_t *array); /* diff --git a/src/include/core/plugin.h b/src/include/core/plugin.h index 4e5d104..6580e90 100644 --- a/src/include/core/plugin.h +++ b/src/include/core/plugin.h @@ -36,6 +36,7 @@ #include "liboconfig/oconfig.h" #include +#include #ifdef __cplusplus extern "C" { @@ -70,7 +71,7 @@ typedef struct { int sdb_module_init(sdb_plugin_info_t *info) typedef struct { - _Bool do_loop; + bool do_loop; sdb_time_t default_interval; } sdb_plugin_loop_t; #define SDB_PLUGIN_LOOP_INIT { 1, 0 } diff --git a/src/include/core/store.h b/src/include/core/store.h index 5507436..6edbea4 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -35,6 +35,7 @@ #include "core/timeseries.h" #include "utils/strbuf.h" +#include #include #ifdef __cplusplus @@ -151,7 +152,7 @@ sdb_store_host(const char *name, sdb_time_t last_update); * sdb_store_get_host increments the ref count of the host object. The caller * needs to deref it when no longer using it. */ -_Bool +bool sdb_store_has_host(const char *name); sdb_store_obj_t * diff --git a/src/include/frontend/sock.h b/src/include/frontend/sock.h index 2b93a6f..be07329 100644 --- a/src/include/frontend/sock.h +++ b/src/include/frontend/sock.h @@ -25,6 +25,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #ifndef SDB_FRONTEND_SOCK_H @@ -40,7 +41,7 @@ typedef struct { size_t num_threads; /* front-end listener shuts down when this is set to false */ - _Bool do_loop; + bool do_loop; } sdb_fe_loop_t; #define SDB_FE_LOOP_INIT { 5, 1 } diff --git a/src/include/utils/avltree.h b/src/include/utils/avltree.h index 28efbdf..de51c7e 100644 --- a/src/include/utils/avltree.h +++ b/src/include/utils/avltree.h @@ -30,6 +30,8 @@ #include "core/object.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -106,7 +108,7 @@ sdb_avltree_get_iter(sdb_avltree_t *tree); void sdb_avltree_iter_destroy(sdb_avltree_iter_t *iter); -_Bool +bool sdb_avltree_iter_has_next(sdb_avltree_iter_t *iter); sdb_object_t * sdb_avltree_iter_get_next(sdb_avltree_iter_t *iter); @@ -128,7 +130,7 @@ sdb_avltree_size(sdb_avltree_t *tree); * - true if the tree is valid * - false else */ -_Bool +bool sdb_avltree_valid(sdb_avltree_t *tree); #ifdef __cplusplus diff --git a/src/include/utils/llist.h b/src/include/utils/llist.h index 1dddb7e..8d2b96e 100644 --- a/src/include/utils/llist.h +++ b/src/include/utils/llist.h @@ -30,6 +30,8 @@ #include "core/object.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -211,7 +213,7 @@ sdb_llist_get_iter(sdb_llist_t *list); void sdb_llist_iter_destroy(sdb_llist_iter_t *iter); -_Bool +bool sdb_llist_iter_has_next(sdb_llist_iter_t *iter); sdb_object_t * sdb_llist_iter_get_next(sdb_llist_iter_t *iter); diff --git a/src/liboconfig/utils.c b/src/liboconfig/utils.c index 26e3dc6..e5a1312 100644 --- a/src/liboconfig/utils.c +++ b/src/liboconfig/utils.c @@ -22,6 +22,7 @@ */ #include "oconfig.h" +#include "utils.h" int oconfig_get_string(oconfig_item_t *ci, char **value) @@ -52,7 +53,7 @@ oconfig_get_number(oconfig_item_t *ci, double *value) } /* oconfig_get_number */ int -oconfig_get_boolean(oconfig_item_t *ci, _Bool *value) +oconfig_get_boolean(oconfig_item_t *ci, bool *value) { if (! ci) return -1; diff --git a/src/liboconfig/utils.h b/src/liboconfig/utils.h index 6e8c61e..f37c830 100644 --- a/src/liboconfig/utils.h +++ b/src/liboconfig/utils.h @@ -26,6 +26,8 @@ #include "oconfig.h" +#include + #ifdef __cplusplus extern "C" { #endif @@ -43,7 +45,7 @@ oconfig_get_string(oconfig_item_t *ci, char **value); int oconfig_get_number(oconfig_item_t *ci, double *value); int -oconfig_get_boolean(oconfig_item_t *ci, _Bool *value); +oconfig_get_boolean(oconfig_item_t *ci, bool *value); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/plugins/backend/mk-livestatus.c b/src/plugins/backend/mk-livestatus.c index 599758b..7d9e320 100644 --- a/src/plugins/backend/mk-livestatus.c +++ b/src/plugins/backend/mk-livestatus.c @@ -327,7 +327,7 @@ sdb_module_init(sdb_plugin_info_t *info) sdb_plugin_register_config(sdb_livestatus_config); return 0; -} /* sdb_version_extra */ +} /* sdb_module_init */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */ diff --git a/src/plugins/timeseries/rrdtool.c b/src/plugins/timeseries/rrdtool.c index 8ea734f..7d6c30b 100644 --- a/src/plugins/timeseries/rrdtool.c +++ b/src/plugins/timeseries/rrdtool.c @@ -47,7 +47,7 @@ SDB_PLUGIN_MAGIC; /* Current versions of RRDtool do not support multiple RRDCacheD client * connections. Use this to guard against multiple configured RRDCacheD * instances. */ -static _Bool rrdcached_in_use = 0; +static bool rrdcached_in_use = 0; /* * plugin API diff --git a/src/tools/sysdb/input.h b/src/tools/sysdb/input.h index ccdce03..0ba5c0a 100644 --- a/src/tools/sysdb/input.h +++ b/src/tools/sysdb/input.h @@ -38,8 +38,8 @@ typedef struct { size_t tokenizer_pos; size_t query_len; - _Bool interactive; - _Bool eof; + bool interactive; + bool eof; } sdb_input_t; #define SDB_INPUT_INIT { NULL, NULL, 0, 0, 1, 0 } diff --git a/src/tools/sysdbd/main.c b/src/tools/sysdbd/main.c index 96fe6a6..bf56656 100644 --- a/src/tools/sysdbd/main.c +++ b/src/tools/sysdbd/main.c @@ -304,7 +304,7 @@ main_loop(void) int main(int argc, char **argv) { - _Bool do_daemonize = 1; + bool do_daemonize = 1; struct sigaction sa_intterm; struct sigaction sa_hup; diff --git a/src/utils/avltree.c b/src/utils/avltree.c index aad2b9a..54c1895 100644 --- a/src/utils/avltree.c +++ b/src/utils/avltree.c @@ -435,7 +435,7 @@ sdb_avltree_iter_destroy(sdb_avltree_iter_t *iter) free(iter); } /* sdb_avltree_iter_destroy */ -_Bool +bool sdb_avltree_iter_has_next(sdb_avltree_iter_t *iter) { if (! iter) @@ -463,12 +463,12 @@ sdb_avltree_size(sdb_avltree_t *tree) return tree ? tree->size : 0; } /* sdb_avltree_size */ -_Bool +bool sdb_avltree_valid(sdb_avltree_t *tree) { node_t *n; - _Bool status = 1; + bool status = 1; size_t size = 0; if (! tree) diff --git a/src/utils/channel.c b/src/utils/channel.c index 7c5c002..c72953e 100644 --- a/src/utils/channel.c +++ b/src/utils/channel.c @@ -32,9 +32,9 @@ #include "utils/channel.h" #include - #include +#include #include #include @@ -60,9 +60,9 @@ struct sdb_channel { size_t head; size_t tail; - _Bool full; + bool full; - _Bool shutdown; + bool shutdown; }; /* diff --git a/src/utils/error.c b/src/utils/error.c index f4ff99a..f940be6 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -35,10 +35,10 @@ #include #include +#include #include -#include - #include +#include /* * private data types @@ -47,7 +47,7 @@ typedef struct { int prio; sdb_strbuf_t *msg; - _Bool logged; + bool logged; } sdb_error_ctx_t; #define SDB_ERROR_INIT { -1, NULL, 1 } @@ -58,7 +58,7 @@ typedef struct { static sdb_error_ctx_t default_error_ctx = SDB_ERROR_INIT; static pthread_key_t error_ctx_key; -static _Bool error_ctx_key_initialized = 0; +static bool error_ctx_key_initialized = 0; static int (*logger)(int prio, const char *msg) = NULL; diff --git a/src/utils/llist.c b/src/utils/llist.c index 03ffd95..8a5e3f2 100644 --- a/src/utils/llist.c +++ b/src/utils/llist.c @@ -469,7 +469,7 @@ sdb_llist_iter_destroy(sdb_llist_iter_t *iter) free(iter); } /* sdb_llist_iter_destroy */ -_Bool +bool sdb_llist_iter_has_next(sdb_llist_iter_t *iter) { if (! iter) -- 2.30.2