summaryrefslogtreecommitdiff
path: root/src/cursor/cur_backup.c
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-09-25 09:47:19 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2015-09-29 16:56:36 +1000
commit4b6157e191d644603e6c0642aed1e9f07eee596d (patch)
treea3bc4859b2dac87d4cbc571e8b9fefe2377f49c5 /src/cursor/cur_backup.c
parentd1dff562e256cf3726f8ec229feced879f212096 (diff)
downloadmongo-4b6157e191d644603e6c0642aed1e9f07eee596d.tar.gz
WT-2112 Use bool in more places
Merge pull request #2216 from wiredtiger/more-bool (cherry picked from commit 53638a10713925406f92d20fa840a94cd2cfa22a)
Diffstat (limited to 'src/cursor/cur_backup.c')
-rw-r--r--src/cursor/cur_backup.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/src/cursor/cur_backup.c b/src/cursor/cur_backup.c
index d34e3ea10a1..6882175362a 100644
--- a/src/cursor/cur_backup.c
+++ b/src/cursor/cur_backup.c
@@ -10,7 +10,7 @@
static int __backup_all(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *);
static int __backup_cleanup_handles(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *);
-static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, int);
+static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, bool);
static int __backup_list_all_append(WT_SESSION_IMPL *, const char *[]);
static int __backup_list_append(
WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *);
@@ -18,7 +18,7 @@ static int __backup_start(
WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[]);
static int __backup_stop(WT_SESSION_IMPL *);
static int __backup_uri(
- WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], int *, int *);
+ WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], bool *, bool *);
/*
* __curbackup_next --
@@ -158,7 +158,7 @@ err: __wt_free(session, cb);
* Append log files needed for backup.
*/
static int
-__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int active)
+__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool active)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
@@ -191,8 +191,7 @@ __backup_start(
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
- bool exist;
- int log_only, target_list;
+ bool exist, log_only, target_list;
conn = S2C(session);
@@ -223,7 +222,7 @@ __backup_start(
__wt_spin_unlock(session, &conn->hot_backup_lock);
/* Create the hot backup file. */
- WT_ERR(__backup_file_create(session, cb, 0));
+ WT_ERR(__backup_file_create(session, cb, false));
/* Add log files if logging is enabled. */
@@ -235,11 +234,11 @@ __backup_start(
* copying data files to avoid rolling the metadata forward across
* a checkpoint that completes during the backup.
*/
- target_list = 0;
+ target_list = false;
WT_ERR(__backup_uri(session, cb, cfg, &target_list, &log_only));
if (!target_list) {
- WT_ERR(__backup_log_append(session, cb, 1));
+ WT_ERR(__backup_log_append(session, cb, true));
WT_ERR(__backup_all(session, cb));
}
@@ -392,17 +391,16 @@ err: if (cursor != NULL)
*/
static int
__backup_uri(WT_SESSION_IMPL *session,
- WT_CURSOR_BACKUP *cb, const char *cfg[], int *foundp, int *log_only)
+ WT_CURSOR_BACKUP *cb, const char *cfg[], bool *foundp, bool *log_only)
{
WT_CONFIG targetconf;
WT_CONFIG_ITEM cval, k, v;
WT_DECL_ITEM(tmp);
WT_DECL_RET;
- int target_list;
+ bool target_list;
const char *uri;
- *foundp = 0;
- *log_only = 0;
+ *foundp = *log_only = false;
/*
* If we find a non-empty target configuration string, we have a job,
@@ -410,11 +408,12 @@ __backup_uri(WT_SESSION_IMPL *session,
*/
WT_RET(__wt_config_gets(session, cfg, "target", &cval));
WT_RET(__wt_config_subinit(session, &targetconf, &cval));
- for (cb->list_next = 0, target_list = 0;
- (ret = __wt_config_next(&targetconf, &k, &v)) == 0; ++target_list) {
+ for (cb->list_next = 0, target_list = false;
+ (ret = __wt_config_next(&targetconf, &k, &v)) == 0;
+ target_list = true) {
/* If it is our first time through, allocate. */
- if (target_list == 0) {
- *foundp = 1;
+ if (!target_list) {
+ *foundp = true;
WT_ERR(__wt_scr_alloc(session, 512, &tmp));
}
@@ -431,12 +430,8 @@ __backup_uri(WT_SESSION_IMPL *session,
* Set log_only only if it is our only URI target.
*/
if (WT_PREFIX_MATCH(uri, "log:")) {
- if (target_list == 0)
- *log_only = 1;
- else
- *log_only = 0;
- WT_ERR(__wt_backup_list_uri_append(
- session, uri, NULL));
+ *log_only = !target_list;
+ WT_ERR(__wt_backup_list_uri_append(session, uri, NULL));
} else
WT_ERR(__wt_schema_worker(session,
uri, NULL, __wt_backup_list_uri_append, cfg, 0));
@@ -453,7 +448,7 @@ err: __wt_scr_free(session, &tmp);
*/
static int
__backup_file_create(
- WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int incremental)
+ WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool incremental)
{
return (__wt_fopen(session,
incremental ? WT_INCREMENTAL_BACKUP : WT_METADATA_BACKUP,
@@ -490,7 +485,7 @@ __wt_backup_list_uri_append(
WT_UNUSED(skip);
if (WT_PREFIX_MATCH(name, "log:")) {
- WT_RET(__backup_log_append(session, cb, 0));
+ WT_RET(__backup_log_append(session, cb, false));
return (0);
}
@@ -539,8 +534,8 @@ __backup_list_append(
WT_CURSOR_BACKUP_ENTRY *p;
WT_DATA_HANDLE *old_dhandle;
WT_DECL_RET;
+ bool need_handle;
const char *name;
- int need_handle;
/* Leave a NULL at the end to mark the end of the list. */
WT_RET(__wt_realloc_def(session, &cb->list_allocated,
@@ -549,10 +544,10 @@ __backup_list_append(
p[0].name = p[1].name = NULL;
p[0].handle = p[1].handle = NULL;
- need_handle = 0;
+ need_handle = false;
name = uri;
if (WT_PREFIX_MATCH(uri, "file:")) {
- need_handle = 1;
+ need_handle = true;
name += strlen("file:");
}