server-info: simplify cleanup in parse_pack_def()
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>
Jeff King committed
Apr 5, 2019 at 14:13 UTC
965cc517e57f01d8013fa7b10c1d5ce72ba3e272
1 file changed
+4
-3
server-info.c
+4
-3
@@ -133,6 +133,7 @@ static int read_pack_info_file(const char *infofile)
133
FILE *fp;
134
char line[1000];
135
int old_cnt = 0;
136
+ int stale = 1;
137
138
fp = fopen_or_warn(infofile, "r");
139
if (!fp)
@@ -161,11 +162,11 @@ static int read_pack_info_file(const char *infofile)
162
error("unrecognized: %s", line);
163
}
164
}
164
- fclose(fp);
165
- return 0;
165
+ stale = 0;
166
+
167
out_stale:
168
fclose(fp);
168
- return 1;
169
+ return stale;
170
}
171
172
static int compare_info(const void *a_, const void *b_)