Skip to content

Commit 4982516

Browse files
Denton-Lgitster
authored andcommitted
revision: make get_revision_mark() return const pointer
get_revision_mark() used to return a `char *`, even though all of the strings it was returning were string literals. Make get_revision_mark() return a `const char *` so that callers won't be tempted to modify the returned string. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0f9de2 commit 4982516

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,7 +3934,7 @@ struct commit *get_revision(struct rev_info *revs)
39343934
return c;
39353935
}
39363936

3937-
char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
3937+
const char *get_revision_mark(const struct rev_info *revs, const struct commit *commit)
39383938
{
39393939
if (commit->object.flags & BOUNDARY)
39403940
return "-";
@@ -3956,7 +3956,7 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
39563956

39573957
void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
39583958
{
3959-
char *mark = get_revision_mark(revs, commit);
3959+
const char *mark = get_revision_mark(revs, commit);
39603960
if (!strlen(mark))
39613961
return;
39623962
fputs(mark, stdout);

revision.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
322322
void reset_revision_walk(void);
323323
int prepare_revision_walk(struct rev_info *revs);
324324
struct commit *get_revision(struct rev_info *revs);
325-
char *get_revision_mark(const struct rev_info *revs,
326-
const struct commit *commit);
325+
const char *get_revision_mark(const struct rev_info *revs,
326+
const struct commit *commit);
327327
void put_revision_mark(const struct rev_info *revs,
328328
const struct commit *commit);
329329

0 commit comments

Comments
 (0)