]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/secret.c: reduce the scope of some variables
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 27 Feb 2013 17:22:24 +0000 (18:22 +0100)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 27 Feb 2013 17:22:24 +0000 (18:22 +0100)
Reduce the scope of error_buf to the place where it's used.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/common/secret.c

index f37619a72dad29a296822ba880bcdc67e962febf..82150930eabe832c85136d4d66cb262d02660f37 100644 (file)
@@ -57,7 +57,6 @@ int set_kernel_secret(const char *secret, const char *key_name)
   int ret;
   int secret_len = strlen(secret);
   char payload[((secret_len * 3) / 4) + 4];
-  char error_buf[80];
 
   if (!secret_len) {
     fprintf(stderr, "secret is empty.\n");
@@ -66,6 +65,7 @@ int set_kernel_secret(const char *secret, const char *key_name)
 
   ret = ceph_unarmor(payload, payload+sizeof(payload), secret, secret+secret_len);
   if (ret < 0) {
+    char error_buf[80];
     fprintf(stderr, "secret is not valid base64: %s.\n",
            strerror_r(-ret, error_buf, sizeof(error_buf)));
     return ret;
@@ -99,7 +99,6 @@ int get_secret_option(const char *secret, const char *key_name,
     olen += strlen(secret);
   }
   char option[olen+1];
-  char error_buf[80];
   int use_key = 1;
 
   option[olen] = '\0';
@@ -114,6 +113,7 @@ int get_secret_option(const char *secret, const char *key_name,
        ret = 0;
        use_key = 0;
       } else {
+        char error_buf[80];
        fprintf(stderr, "adding ceph secret key to kernel failed: %s.\n",
                strerror_r(-ret, error_buf, sizeof(error_buf)));
        return ret;