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

[PATCH 2/3] range-diff: mark pointers as const

From
Denton Liu <liu.denton@gmail.com>
Date
Dec 6, 2019, 20:16 UTC
Message-ID
<159516cf99c445604d82d8760e8d2f7497db05a5.1575663345.git.liu.denton@gmail.com>
In-Reply-To
<cover.1575663345.git.liu.denton@gmail.com>

The contents pointed to by `diffopt` and `other_arg` should not be modified. Mark these as `const` to indicate this.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 range-diff.c | 6 +++---
 range-diff.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/range-diff.c b/range-diff.c
index f56b4012a2..f745567cf6 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -41,7 +41,7 @@ static size_t find_end_of_line(char *buffer, unsigned long size)
  * as struct object_id (will need to be free()d).
  */
 static int read_patches(const char *range, struct string_list *list,
-			struct argv_array *other_arg)
+			const struct argv_array *other_arg)
 {
 	struct child_process cp = CHILD_PROCESS_INIT;
 	struct strbuf buf = STRBUF_INIT, contents = STRBUF_INIT;
@@ -506,8 +506,8 @@ static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
 
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
-		    struct diff_options *diffopt,
-		    struct argv_array *other_arg)
+		    const struct diff_options *diffopt,
+		    const struct argv_array *other_arg)
 {
 	int res = 0;
 
diff --git a/range-diff.h b/range-diff.h
index 7d918ab9ed..381d52f4d3 100644
--- a/range-diff.h
+++ b/range-diff.h
@@ -13,7 +13,7 @@
  */
 int show_range_diff(const char *range1, const char *range2,
 		    int creation_factor, int dual_color,
-		    struct diff_options *diffopt,
-		    struct argv_array *other_arg);
+		    const struct diff_options *diffopt,
+		    const struct argv_array *other_arg);
 
 #endif
-- 
2.24.0.612.g9b7bad38f5
Previous: Denton LiuNext: Denton Liu
Message 3 of 4 in “cleanup for 'dl/range-diff-with-notes'”
  1. 0/3 cleanup for 'dl/range-diff-with-notes'Denton Liu, Dec 6, 2019
  2. 1/3 t3206: fix incorrect test nameDenton Liu, Dec 6, 2019
  3. 2/3 range-diff: mark pointers as constDenton Liu, Dec 6, 2019
  4. 3/3 range-diff: clear `other_arg` at end of functionDenton Liu, Dec 6, 2019

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.