Signed-off-by: Matthieu Moy <matthieu....@imag.fr>
---
Consider squashing this into PATCH 2/2.

 test-config.c | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/test-config.c b/test-config.c
index dc313c2..07b61ef 100644
--- a/test-config.c
+++ b/test-config.c
@@ -41,17 +41,17 @@ int main(int argc, char **argv)
 
        if (argc < 2) {
                fprintf(stderr, "Please, provide a command name on the 
command-line\n");
-               return 1;
+               goto exit1;
        } else if (argc == 3 && !strcmp(argv[1], "get_value")) {
                if (!git_config_get_value(argv[2], &v)) {
                        if (!v)
                                printf("(NULL)\n");
                        else
                                printf("%s\n", v);
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        } else if (argc == 3 && !strcmp(argv[1], "get_value_multi")) {
                strptr = git_config_get_value_multi(argv[2]);
@@ -63,46 +63,46 @@ int main(int argc, char **argv)
                                else
                                        printf("%s\n", v);
                        }
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        } else if (argc == 3 && !strcmp(argv[1], "get_int")) {
                if (!git_config_get_int(argv[2], &val)) {
                        printf("%d\n", val);
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        } else if (argc == 3 && !strcmp(argv[1], "get_bool")) {
                if (!git_config_get_bool(argv[2], &val)) {
                        printf("%d\n", val);
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        } else if (!strcmp(argv[1], "configset_get_value")) {
                for (i = 3; i < argc; i++) {
                        if (git_configset_add_file(&cs, argv[i]))
-                               return 2;
+                               goto exit2;
                }
                if (!git_configset_get_value(&cs, argv[2], &v)) {
                        if (!v)
                                printf("(NULL)\n");
                        else
                                printf("%s\n", v);
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        } else if (!strcmp(argv[1], "configset_get_value_multi")) {
                for (i = 3; i < argc; i++) {
                        if (git_configset_add_file(&cs, argv[i]))
-                               return 2;
+                               goto exit2;
                }
                strptr = git_configset_get_value_multi(&cs, argv[2]);
                if (strptr) {
@@ -113,13 +113,25 @@ int main(int argc, char **argv)
                                else
                                        printf("%s\n", v);
                        }
-                       return 0;
+                       goto exit0;
                } else {
                        printf("Value not found for \"%s\"\n", argv[2]);
-                       return 1;
+                       goto exit1;
                }
        }
 
        fprintf(stderr, "%s: Please check the syntax and the function name\n", 
argv[0]);
+       goto exit1;
+
+exit0:
+       git_configset_clear(&cs);
+       return 0;
+
+exit1:
+       git_configset_clear(&cs);
        return 1;
+
+exit2:
+       git_configset_clear(&cs);
+       return 2;
 }
-- 
2.0.0.262.gdafc651

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to