]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/tools: initialize variables before the goto statement
authorsongweibin <song.weibin@zte.com.cn>
Thu, 25 Jul 2019 11:12:05 +0000 (19:12 +0800)
committersongweibin <song.weibin@zte.com.cn>
Fri, 26 Jul 2019 06:27:02 +0000 (14:27 +0800)
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 <song.weibin@zte.com.cn>
src/tools/scratchtool.c

index 19d5e01d2d3635926bebb14b6ab1a9267a135147..b344f0b7473433b4a164e013359c2daf213000d1 100644 (file)
@@ -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);