summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@fb.com>2017-10-31 09:56:11 -0700
committerAmar Tumballi <amarts@redhat.com>2017-11-03 05:04:11 +0000
commit8e973d3ab96d290a32ae3fdbdd1cf867b7060483 (patch)
treedc20dca53f16dba3489d65837007e87bb4c84650 /xlators
parent917f84b01ff4c485ce548f0daa3d3d51dc81c195 (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>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.h1
-rw-r--r--xlators/cluster/dht/src/dht-shared.c13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c4
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c7
-rw-r--r--xlators/performance/write-behind/src/write-behind.c2
-rw-r--r--xlators/protocol/client/src/client-handshake.c5
6 files changed, 23 insertions, 9 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index f3e2c5c..0b51dba 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 38de31d..f6ca8bd 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 fc31dd2..a61ecab 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 6c65060..50ac993 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 d1a95c9..67dd1f5 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 3cf2b06..6fdea91 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);