server-info: simplify cleanup in parse_pack_def()
authorJeff King <peff@peff.net>
Fri, 5 Apr 2019 18:13:14 +0000 (14:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Apr 2019 07:58:21 +0000 (16:58 +0900)
We have two exits from the function: either we jump to the out_stale
label or not. But in both exits we repeat our cleanup, and the only
difference is our return value. Let's just use a variable for the return
value to avoid repeating ourselves.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
server-info.c
index b61a6be4c26da4f31e337913986ca7a5e09923be..ba44cece7f5fe62218060547a46de5d910926763 100644 (file)
@@ -133,6 +133,7 @@ static int read_pack_info_file(const char *infofile)
        FILE *fp;
        char line[1000];
        int old_cnt = 0;
+       int stale = 1;
 
        fp = fopen_or_warn(infofile, "r");
        if (!fp)
@@ -161,11 +162,11 @@ static int read_pack_info_file(const char *infofile)
                        error("unrecognized: %s", line);
                }
        }
-       fclose(fp);
-       return 0;
+       stale = 0;
+
  out_stale:
        fclose(fp);
-       return 1;
+       return stale;
 }
 
 static int compare_info(const void *a_, const void *b_)