Skip to content

Commit d5e1961

Browse files
peffgitster
authored andcommitted
stop calling UNLEAK() before die()
The point of UNLEAK() is to make a reference to a variable that is about to go out of scope so that leak-checkers will consider it to be not-leaked. Doing so right before die() is therefore pointless; even though we are about to exit the program, the variable will still be on the stack and accessible to leak-checkers. These annotations aren't really hurting anything, but they clutter the code and set a bad example of how to use UNLEAK(). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit d5e1961

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

bugreport.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,8 @@ int cmd_main(int argc, const char **argv)
175175
/* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
176176
report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
177177

178-
if (report < 0) {
179-
UNLEAK(report_path);
178+
if (report < 0)
180179
die(_("couldn't create a new file at '%s'"), report_path.buf);
181-
}
182180

183181
if (write_in_full(report, buffer.buf, buffer.len) < 0)
184182
die_errno(_("unable to write to %s"), report_path.buf);

midx.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,9 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
807807
int result = 0;
808808

809809
midx_name = get_midx_filename(object_dir);
810-
if (safe_create_leading_directories(midx_name)) {
811-
UNLEAK(midx_name);
810+
if (safe_create_leading_directories(midx_name))
812811
die_errno(_("unable to create leading directories of %s"),
813812
midx_name);
814-
}
815813

816814
if (m)
817815
packs.m = m;
@@ -1051,10 +1049,8 @@ void clear_midx_file(struct repository *r)
10511049
r->objects->multi_pack_index = NULL;
10521050
}
10531051

1054-
if (remove_path(midx)) {
1055-
UNLEAK(midx);
1052+
if (remove_path(midx))
10561053
die(_("failed to clear multi-pack-index at %s"), midx);
1057-
}
10581054

10591055
free(midx);
10601056
}

0 commit comments

Comments
 (0)