vcs-svn: simplify cleanup in apply_one_window

Currently the cleanup code looks like this: free resources return 0; error_out: free resources return -1; Avoid duplicating the "free resources" part by keeping the return value in a variable and sharing code between the success and exceptional case: ret = 0; out: free resources return ret; Noticed in the svn-dump-fast-export project, where using the error() macro in void context produces a warning. Signed-off-by: David Barr <davidbarr@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

David Barr committed Jun 1, 2012 at 00:41 UTC 4a1613194af218afb99be0e14af449e86852d06e
1 file changed +4 -4
vcs-svn/svndiff.c
+4 -4
@@ -258,6 +258,7 @@ static int apply_window_in_core(struct window *ctx)
258 static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
259 struct sliding_view *preimage, FILE *out)
260 {
261 + int rv = -1;
262 struct window ctx = WINDOW_INIT(preimage);
263 size_t out_len;
264 size_t instructions_len;
@@ -275,16 +276,15 @@ static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
276 if (apply_window_in_core(&ctx))
277 goto error_out;
278 if (ctx.out.len != out_len) {
278 - error("invalid delta: incorrect postimage length");
279 + rv = error("invalid delta: incorrect postimage length");
280 goto error_out;
281 }
282 if (write_strbuf(&ctx.out, out))
283 goto error_out;
283 - window_release(&ctx);
284 - return 0;
284 + rv = 0;
285 error_out:
286 window_release(&ctx);
287 - return -1;
287 + return rv;
288 }
289
290 int svndiff0_apply(struct line_buffer *delta, off_t delta_len,