Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
vcs-svn: simplify cleanup in apply_one_window
author
David Barr
<davidbarr@google.com>
Thu, 31 May 2012 14:41:26 +0000
(
00:41
+1000)
committer
Jonathan Nieder
<jrnieder@gmail.com>
Fri, 6 Jul 2012 04:26:52 +0000
(23:26 -0500)
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>
vcs-svn/svndiff.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4a5de8d
)
diff --git
a/vcs-svn/svndiff.c
b/vcs-svn/svndiff.c
index c89d9623f4e87642269f32f1a4422bde7ab2c645..e810d0c3ff34ecd52c00b57342867b0fdb4f1f57 100644
(file)
--- a/
vcs-svn/svndiff.c
+++ b/
vcs-svn/svndiff.c
@@
-258,6
+258,7
@@
static int apply_window_in_core(struct window *ctx)
static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
struct sliding_view *preimage, FILE *out)
{
static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
struct sliding_view *preimage, FILE *out)
{
+ int rv = -1;
struct window ctx = WINDOW_INIT(preimage);
size_t out_len;
size_t instructions_len;
struct window ctx = WINDOW_INIT(preimage);
size_t out_len;
size_t instructions_len;
@@
-275,16
+276,15
@@
static int apply_one_window(struct line_buffer *delta, off_t *delta_len,
if (apply_window_in_core(&ctx))
goto error_out;
if (ctx.out.len != out_len) {
if (apply_window_in_core(&ctx))
goto error_out;
if (ctx.out.len != out_len) {
- error("invalid delta: incorrect postimage length");
+
rv =
error("invalid delta: incorrect postimage length");
goto error_out;
}
if (write_strbuf(&ctx.out, out))
goto error_out;
goto error_out;
}
if (write_strbuf(&ctx.out, out))
goto error_out;
- window_release(&ctx);
- return 0;
+ rv = 0;
error_out:
window_release(&ctx);
error_out:
window_release(&ctx);
- return
-1
;
+ return
rv
;
}
int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
}
int svndiff0_apply(struct line_buffer *delta, off_t delta_len,