git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/6] vcs-svn: simplify cleanup in apply_one_window()

From
David Barr <davidbarr@google.com>
Date
May 31, 2012, 14:41 UTC
Message-ID
<1338475290-22644-3-git-send-email-davidbarr@google.com>
In-Reply-To
<1338475290-22644-1-git-send-email-davidbarr@google.com>
As a side-effect, fix clang-analyzer warning:
vcs-svn/svndiff.c:278:3: warning: expression result unused [-Wunused-value]
                error("invalid delta: incorrect postimage length");
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This warning caused by an insanely concise error() upstream.
Signed-off-by: David Barr <davidbarr@google.com>
---
 vcs-svn/svndiff.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 57d647d..11a0e38 100644
--- 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)
 {
+	int rv = -1;
 	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) {
-		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;
-	window_release(&ctx);
-	return 0;
+	rv = 0;
 error_out:
 	window_release(&ctx);
-	return -1;
+	return rv;
 }
 
 int svndiff0_apply(struct line_buffer *delta, off_t delta_len,
-- 
1.7.10.2
Previous: David BarrNext: David Barr
Message 3 of 10 in “vcs-svn: housekeeping”
  1. 0/6 vcs-svn: housekeepingDavid Barr, May 31, 2012
  2. 1/6 vcs-svn: fix clang-analyzer errorDavid Barr, May 31, 2012
  3. 2/6 vcs-svn: simplify cleanup in apply_one_window()David Barr, May 31, 2012
  4. 3/6 vcs-svn: prefer constcmp to prefixcmpDavid Barr, May 31, 2012
  5. Junio C HamanoJun 1, 2012
  6. David Michael BarrJun 1, 2012
  7. 4/6 vcs-svn: prefer strstr over memmemDavid Barr, May 31, 2012
  8. 5/6 vcs-svn: fix signedness warningsDavid Barr, May 31, 2012
  9. 6/6 vcs-svn: drop no-op reset methodsDavid Barr, May 31, 2012
  10. David Michael BarrJun 1, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.