diff options
author | Jeff Darcy <jdarcy@fb.com> | 2017-10-31 09:56:11 -0700 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2017-11-03 05:04:11 +0000 |
commit | 8e973d3ab96d290a32ae3fdbdd1cf867b7060483 (patch) | |
tree | dc20dca53f16dba3489d65837007e87bb4c84650 | |
parent | 917f84b01ff4c485ce548f0daa3d3d51dc81c195 (diff) |
core: make gf_boolean_t a C99 bool instead of an enum
This reduces the space used from four bytes to one, and allows
new code to use familiar C99 types/values interoperably with our
old cruft. It does *not* change current declarations or code;
that will be left for a separate - much larger - patch.
Updates: #80
Change-Id: I5baedd17d3fb05b38f0d8b8bb9dd62824475842e
Signed-off-by: Jeff Darcy <jdarcy@fb.com>
-rw-r--r-- | libglusterfs/src/common-utils.h | 10 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-shared.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 4 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 7 | ||||
-rw-r--r-- | xlators/performance/write-behind/src/write-behind.c | 2 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 5 |
7 files changed, 27 insertions, 15 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 76dfe0666f9..18ab56aeb9b 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -136,11 +136,10 @@ void trap (void); #define GF_THREAD_NAME_PREFIX "gluster" #define GF_THREAD_NAME_PREFIX_LEN 7 -enum _gf_boolean -{ - _gf_false = 0, - _gf_true = 1 -}; +#include <stdbool.h> +#define gf_boolean_t bool +#define _gf_false false +#define _gf_true true /* * we could have initialized these as +ve values and treated @@ -170,7 +169,6 @@ enum _gf_xlator_ipc_targets { GF_IPC_TARGET_UPCALL = 2 }; -typedef enum _gf_boolean gf_boolean_t; typedef enum _gf_special_pid gf_special_pid_t; typedef enum _gf_xlator_ipc_targets _gf_xlator_ipc_targets_t; diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index f3e2c5cf41e..0b51dbac5e0 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -29,6 +29,7 @@ #define GF_XATTR_TIER_LAYOUT_FIXED_KEY "trusted.tier.fix.layout.complete" #define GF_XATTR_FILE_MIGRATE_KEY "trusted.distribute.migrate-data" #define DHT_MDS_STR "mds" +#define GF_DHT_LOOKUP_UNHASHED_OFF 0 #define GF_DHT_LOOKUP_UNHASHED_ON 1 #define GF_DHT_LOOKUP_UNHASHED_AUTO 2 #define DHT_PATHINFO_HEADER "DISTRIBUTE:" diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 38de31d1ec9..f6ca8bd0926 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -769,13 +769,18 @@ dht_init (xlator_t *this) if (dict_get_str (this->options, "lookup-unhashed", &temp_str) == 0) { /* If option is not "auto", other options _should_ be boolean */ if (strcasecmp (temp_str, "auto")) { - ret = gf_string2boolean (temp_str, - &conf->search_unhashed); - if (ret == -1) + gf_boolean_t search_unhashed_bool; + ret = gf_string2boolean (temp_str, &search_unhashed_bool); + if (ret == -1) { goto err; + } + conf->search_unhashed = search_unhashed_bool + ? GF_DHT_LOOKUP_UNHASHED_ON + : GF_DHT_LOOKUP_UNHASHED_OFF; } - else + else { conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_AUTO; + } } GF_OPTION_INIT ("lookup-optimize", conf->lookup_optimize, bool, err); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index fc31dd2820b..a61ecab84d6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -968,13 +968,15 @@ gd_import_volume_snap_details (dict_t *dict, glusterd_volinfo_t *volinfo, } snprintf (key, sizeof (key), "%s.is_snap_volume", prefix); - ret = dict_get_uint32 (dict, key, &volinfo->is_snap_volume); + uint32_t is_snap_int; + ret = dict_get_uint32 (dict, key, &is_snap_int); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED, "%s missing in payload " "for %s", key, volname); goto out; } + volinfo->is_snap_volume = (is_snap_int != 0); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "%s.restored_from_snap", prefix); diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 6c6506009cb..50ac9931a5a 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -5583,8 +5583,11 @@ init (xlator_t *this_xl) priv->direct_io_mode = 2; ret = dict_get_str (options, ZR_DIRECT_IO_OPT, &value_string); if (ret == 0) { - ret = gf_string2boolean (value_string, &priv->direct_io_mode); - GF_ASSERT (ret == 0); + gf_boolean_t direct_io_mode_bool; + ret = gf_string2boolean (value_string, &direct_io_mode_bool); + if (ret == 0) { + priv->direct_io_mode = direct_io_mode_bool ? 1 : 0; + } } GF_OPTION_INIT (ZR_STRICT_VOLFILE_CHECK, priv->strict_volfile_check, diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index d1a95c97d7a..67dd1f51ea1 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -251,7 +251,7 @@ wb_requests_overlap (wb_request_t *req1, wb_request_t *req2) uint64_t r1_end = 0; uint64_t r2_start = 0; uint64_t r2_end = 0; - enum _gf_boolean do_overlap = 0; + gf_boolean_t do_overlap = _gf_false; r1_start = req1->ordering.off; if (req1->ordering.size) diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 3cf2b06cb03..6fdea91fa38 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1179,7 +1179,8 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m goto out; } - ret = dict_get_uint32 (reply, "child_up", &conf->child_up); + uint32_t child_up_int; + ret = dict_get_uint32 (reply, "child_up", &child_up_int); if (ret) { /* * This would happen in cases where the server trying to * @@ -1189,6 +1190,8 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m gf_msg (this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_GET_FAILED, "failed to find key 'child_up' in the options"); conf->child_up = _gf_true; + } else { + conf->child_up = (child_up_int != 0); } ret = dict_get_uint32 (reply, "clnt-lk-version", &lk_ver); |