Re: [PATCH 17/18] revert: Introduce --continue to continue the operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 28 July 2011 18:52:30 Ramkumar Ramachandra wrote:
> +static void read_populate_todo(struct commit_list **todo_list,
> +			struct replay_opts *opts)
> +{
> +	const char *todo_file = git_path(SEQ_TODO_FILE);
> +	struct strbuf buf = STRBUF_INIT;
> +	struct commit_list **next;
> +	struct commit *commit;
> +	char *p;
> +	int fd;
> +
> +	fd = open(todo_file, O_RDONLY);
> +	if (fd < 0) {
> +		strbuf_release(&buf);

We don't need to release buf here.

> +		die_errno(_("Could not open %s."), todo_file);
> +	}
> +	if (strbuf_read(&buf, fd, 0) < buf.len) {

The other places in the code are using "strbuf_read(...) < 0" to detect an 
error.

> +		close(fd);
> +		strbuf_release(&buf);
> +		die(_("Could not read %s."), todo_file);
> +	}
> +	close(fd);
> +
> +	next = todo_list;
> +	for (p = buf.buf; *p; p = strchr(p, '\n') + 1) {

This relies on a "\n" at the end of the last line...

> +		commit = parse_insn_line(p, opts);
> +		if (!commit)
> +			goto error;
> +		next = commit_list_append(commit, next);
> +	}
> +	if (!*todo_list)
> +		goto error;
> +	strbuf_release(&buf);
> +	return;
> +error:
> +	strbuf_release(&buf);
> +	die(_("Unusable instruction sheet: %s"), todo_file);
> +}

Thanks,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]