Skip to content

Commit 14bca6c

Browse files
Martin Ågrengitster
authored andcommitted
sequencer: make lockfiles non-static
After 076aa2c (tempfile: auto-allocate tempfiles on heap, 2017-09-05), we can have lockfiles on the stack. One of these functions fails to always roll back the lock. That will be fixed in the next commit. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e3a8078 commit 14bca6c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sequencer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static void print_advice(int show_hint, struct replay_opts *opts)
339339
static int write_message(const void *buf, size_t len, const char *filename,
340340
int append_eol)
341341
{
342-
static struct lock_file msg_file;
342+
struct lock_file msg_file = LOCK_INIT;
343343

344344
int msg_fd = hold_lock_file_for_update(&msg_file, filename, 0);
345345
if (msg_fd < 0)
@@ -485,7 +485,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
485485
struct tree *result, *next_tree, *base_tree, *head_tree;
486486
int clean;
487487
char **xopt;
488-
static struct lock_file index_lock;
488+
struct lock_file index_lock = LOCK_INIT;
489489

490490
if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)
491491
return -1;
@@ -1705,7 +1705,7 @@ static int prepare_revs(struct replay_opts *opts)
17051705

17061706
static int read_and_refresh_cache(struct replay_opts *opts)
17071707
{
1708-
static struct lock_file index_lock;
1708+
struct lock_file index_lock = LOCK_INIT;
17091709
int index_fd = hold_locked_index(&index_lock, 0);
17101710
if (read_index_preload(&the_index, NULL) < 0) {
17111711
rollback_lock_file(&index_lock);
@@ -2099,7 +2099,7 @@ static int create_seq_dir(void)
20992099

21002100
static int save_head(const char *head)
21012101
{
2102-
static struct lock_file head_lock;
2102+
struct lock_file head_lock = LOCK_INIT;
21032103
struct strbuf buf = STRBUF_INIT;
21042104
int fd;
21052105
ssize_t written;
@@ -2224,7 +2224,7 @@ int sequencer_rollback(struct replay_opts *opts)
22242224

22252225
static int save_todo(struct todo_list *todo_list, struct replay_opts *opts)
22262226
{
2227-
static struct lock_file todo_lock;
2227+
struct lock_file todo_lock = LOCK_INIT;
22282228
const char *todo_path = get_todo_path(opts);
22292229
int next = todo_list->current, offset, fd;
22302230

0 commit comments

Comments
 (0)