From: songweibin Date: Thu, 25 Jul 2019 11:12:05 +0000 (+0800) Subject: src/tools: initialize variables before the goto statement X-Git-Tag: v15.1.0~2056^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1428c6e447ea445ecfa36f033d8020bdeb493cd2;p=ceph-ci.git src/tools: initialize variables before the goto statement CID 172143 (#15 of 15): Branch past initialization (PW.BRANCH_PAST_INITIALIZATION) 1. branch_past_initialization: 2. name_at_decl_position: variable "oid" (declared at line 220) 3. name_at_decl_position: variable "exkeys" (declared at line 241) 4. name_at_decl_position: variable "exvals" (declared at line 242) 5. name_at_decl_position: variable "safe" (declared at line 278) Signed-off-by: songweibin --- diff --git a/src/tools/scratchtool.c b/src/tools/scratchtool.c index 19d5e01d2d3..b344f0b7473 100644 --- a/src/tools/scratchtool.c +++ b/src/tools/scratchtool.c @@ -106,9 +106,12 @@ out_err: static int testrados(void) { char tmp[32]; - int i, r; + int i, r, safe; int ret = 1; //set 1 as error case rados_t cl; + const char *oid = "foo_object"; + const char *exkeys[] = { "a", "b", "c", NULL }; + const char *exvals[] = { "1", "2", "3", NULL }; if (rados_create(&cl, NULL) < 0) { printf("error initializing\n"); @@ -217,7 +220,6 @@ static int testrados(void) char buf[128], buf2[128]; time(&tm); snprintf(buf, 128, "%s", ctime(&tm)); - const char *oid = "foo_object"; r = rados_write(io_ctx, oid, buf, strlen(buf) + 1, 0); printf("rados_write = %d\n", r); r = rados_read(io_ctx, oid, buf2, sizeof(buf2), 0); @@ -238,8 +240,6 @@ static int testrados(void) goto out_err_cleanup; if (do_rados_getxattr(io_ctx, oid, "c", "3")) goto out_err_cleanup; - const char *exkeys[] = { "a", "b", "c", NULL }; - const char *exvals[] = { "1", "2", "3", NULL }; if (do_rados_getxattrs(io_ctx, oid, exkeys, exvals)) goto out_err_cleanup; @@ -275,7 +275,7 @@ static int testrados(void) rados_completion_t c; rados_aio_create_completion(0, 0, 0, &c); rados_aio_write(io_ctx, "c", c, buf, 100, 0); - int safe = rados_aio_is_safe(c); + safe = rados_aio_is_safe(c); printf("a should not yet be safe and ... %s\n", safe ? "is":"is not"); assert(!safe); rados_aio_flush(io_ctx);