mirror of
https://github.com/git/git.git
synced 2024-11-18 02:14:03 +01:00
Merge branch 'nd/error-errno'
The code for warning_errno/die_errno has been refactored and a new error_errno() reporting helper is introduced. * nd/error-errno: (41 commits) wrapper.c: use warning_errno() vcs-svn: use error_errno() upload-pack.c: use error_errno() unpack-trees.c: use error_errno() transport-helper.c: use error_errno() sha1_file.c: use {error,die,warning}_errno() server-info.c: use error_errno() sequencer.c: use error_errno() run-command.c: use error_errno() rerere.c: use error_errno() and warning_errno() reachable.c: use error_errno() mailmap.c: use error_errno() ident.c: use warning_errno() http.c: use error_errno() and warning_errno() grep.c: use error_errno() gpg-interface.c: use error_errno() fast-import.c: use error_errno() entry.c: use error_errno() editor.c: use error_errno() diff-no-index.c: use error_errno() ...
This commit is contained in:
commit
40cfc95856
7
bisect.c
7
bisect.c
@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
|
||||
/* Create file BISECT_ANCESTORS_OK. */
|
||||
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
|
||||
if (fd < 0)
|
||||
warning("could not create file '%s': %s",
|
||||
filename, strerror(errno));
|
||||
warning_errno("could not create file '%s'",
|
||||
filename);
|
||||
else
|
||||
close(fd);
|
||||
done:
|
||||
@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
|
||||
*read_good = "good";
|
||||
return;
|
||||
} else {
|
||||
die("could not read file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
die_errno("could not read file '%s'", filename);
|
||||
}
|
||||
} else {
|
||||
strbuf_getline_lf(&str, fp);
|
||||
|
11
builtin/am.c
11
builtin/am.c
@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
|
||||
in = fopen(*paths, "r");
|
||||
|
||||
if (!in)
|
||||
return error(_("could not open '%s' for reading: %s"),
|
||||
*paths, strerror(errno));
|
||||
return error_errno(_("could not open '%s' for reading"),
|
||||
*paths);
|
||||
|
||||
mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
|
||||
|
||||
out = fopen(mail, "w");
|
||||
if (!out)
|
||||
return error(_("could not open '%s' for writing: %s"),
|
||||
mail, strerror(errno));
|
||||
return error_errno(_("could not open '%s' for writing"),
|
||||
mail);
|
||||
|
||||
ret = fn(out, in, keep_cr);
|
||||
|
||||
@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
|
||||
|
||||
fp = fopen(*paths, "r");
|
||||
if (!fp)
|
||||
return error(_("could not open '%s' for reading: %s"), *paths,
|
||||
strerror(errno));
|
||||
return error_errno(_("could not open '%s' for reading"), *paths);
|
||||
|
||||
while (!strbuf_getline_lf(&sb, fp)) {
|
||||
if (*sb.buf == '#')
|
||||
|
@ -595,8 +595,7 @@ static int edit_branch_description(const char *branch_name)
|
||||
branch_name, comment_line_char);
|
||||
if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
|
||||
strbuf_release(&buf);
|
||||
return error(_("could not write branch description template: %s"),
|
||||
strerror(errno));
|
||||
return error_errno(_("could not write branch description template"));
|
||||
}
|
||||
strbuf_reset(&buf);
|
||||
if (launch_editor(git_path(edit_description), &buf, NULL)) {
|
||||
|
@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
||||
|
||||
fp = fopen(filename, "a");
|
||||
if (!fp)
|
||||
return error(_("cannot open %s: %s\n"), filename, strerror(errno));
|
||||
return error_errno(_("cannot open %s"), filename);
|
||||
|
||||
if (raw_url)
|
||||
url = transport_anonymize_url(raw_url);
|
||||
@ -848,7 +848,7 @@ static int truncate_fetch_head(void)
|
||||
FILE *fp = fopen_for_writing(filename);
|
||||
|
||||
if (!fp)
|
||||
return error(_("cannot open %s: %s\n"), filename, strerror(errno));
|
||||
return error_errno(_("cannot open %s"), filename);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)
|
||||
path = "emacsclient";
|
||||
strbuf_addf(&man_page, "(woman \"%s\")", page);
|
||||
execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
|
||||
warning(_("failed to exec '%s': %s"), path, strerror(errno));
|
||||
warning_errno(_("failed to exec '%s'"), path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)
|
||||
path = "kfmclient";
|
||||
strbuf_addf(&man_page, "man:%s(1)", page);
|
||||
execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
|
||||
warning(_("failed to exec '%s': %s"), path, strerror(errno));
|
||||
warning_errno(_("failed to exec '%s'"), path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)
|
||||
if (!path)
|
||||
path = "man";
|
||||
execlp(path, "man", page, (char *)NULL);
|
||||
warning(_("failed to exec '%s': %s"), path, strerror(errno));
|
||||
warning_errno(_("failed to exec '%s'"), path);
|
||||
}
|
||||
|
||||
static void exec_man_cmd(const char *cmd, const char *page)
|
||||
@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
|
||||
struct strbuf shell_cmd = STRBUF_INIT;
|
||||
strbuf_addf(&shell_cmd, "%s %s", cmd, page);
|
||||
execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
|
||||
warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
|
||||
warning(_("failed to exec '%s'"), cmd);
|
||||
}
|
||||
|
||||
static void add_man_viewer(const char *name)
|
||||
|
@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
|
||||
if ((dir = opendir(name)) == NULL) {
|
||||
if (errno == ENOENT)
|
||||
continue;
|
||||
error("cannot opendir %s (%s)", name, strerror(errno));
|
||||
error_errno("cannot opendir %s", name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,
|
||||
|
||||
f = fopen(file, "r");
|
||||
if (!f) {
|
||||
error("cannot open mail %s (%s)", file, strerror(errno));
|
||||
error_errno("cannot open mail %s", file);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strbuf_getwholeline(&buf, f, '\n')) {
|
||||
error("cannot read mail %s (%s)", file, strerror(errno));
|
||||
error_errno("cannot read mail %s", file);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
|
||||
int file_done = 0;
|
||||
|
||||
if (!f) {
|
||||
error("cannot open mbox %s", file);
|
||||
error_errno("cannot open mbox %s", file);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
|
||||
if (stat(arg, &argstat) == -1) {
|
||||
error("cannot stat %s (%s)", arg, strerror(errno));
|
||||
error_errno("cannot stat %s", arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
|
||||
usage_with_options(merge_file_usage, options);
|
||||
if (quiet) {
|
||||
if (!freopen("/dev/null", "w", stderr))
|
||||
return error("failed to redirect stderr to /dev/null: "
|
||||
"%s", strerror(errno));
|
||||
return error_errno("failed to redirect stderr to /dev/null");
|
||||
}
|
||||
|
||||
if (prefix)
|
||||
@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
|
||||
FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
|
||||
|
||||
if (!f)
|
||||
ret = error("Could not open %s for writing", filename);
|
||||
ret = error_errno("Could not open %s for writing",
|
||||
filename);
|
||||
else if (result.size &&
|
||||
fwrite(result.ptr, result.size, 1, f) != 1)
|
||||
ret = error("Could not write to %s", filename);
|
||||
ret = error_errno("Could not write to %s", filename);
|
||||
else if (fclose(f))
|
||||
ret = error("Could not close %s", filename);
|
||||
ret = error_errno("Could not close %s", filename);
|
||||
free(result.ptr);
|
||||
}
|
||||
|
||||
|
@ -835,8 +835,7 @@ static void write_pack_file(void)
|
||||
* to preserve this property.
|
||||
*/
|
||||
if (stat(pack_tmp_name, &st) < 0) {
|
||||
warning("failed to stat %s: %s",
|
||||
pack_tmp_name, strerror(errno));
|
||||
warning_errno("failed to stat %s", pack_tmp_name);
|
||||
} else if (!last_mtime) {
|
||||
last_mtime = st.st_mtime;
|
||||
} else {
|
||||
@ -844,8 +843,7 @@ static void write_pack_file(void)
|
||||
utb.actime = st.st_atime;
|
||||
utb.modtime = --last_mtime;
|
||||
if (utime(pack_tmp_name, &utb) < 0)
|
||||
warning("failed utime() on %s: %s",
|
||||
pack_tmp_name, strerror(errno));
|
||||
warning_errno("failed utime() on %s", pack_tmp_name);
|
||||
}
|
||||
|
||||
strbuf_addf(&tmpname, "%s-", base_name);
|
||||
|
@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
|
||||
|
||||
if (lstat(ce->name, &st) < 0) {
|
||||
if (errno != ENOENT && errno != ENOTDIR)
|
||||
warning("'%s': %s", ce->name, strerror(errno));
|
||||
warning_errno(_("failed to stat '%s'"), ce->name);
|
||||
/* It already vanished from the working tree */
|
||||
continue;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)
|
||||
{
|
||||
if (err == ENOENT || err == ENOTDIR)
|
||||
return remove_one_path(path);
|
||||
return error("lstat(\"%s\"): %s", path, strerror(errno));
|
||||
return error("lstat(\"%s\"): %s", path, strerror(err));
|
||||
}
|
||||
|
||||
static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
|
||||
|
@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
|
||||
pfd[1].events = POLLIN;
|
||||
if (poll(pfd, 2, -1) < 0) {
|
||||
if (errno != EINTR) {
|
||||
error("poll failed resuming: %s",
|
||||
strerror(errno));
|
||||
error_errno("poll failed resuming");
|
||||
sleep(1);
|
||||
}
|
||||
continue;
|
||||
|
@ -110,7 +110,7 @@ static void prune_worktrees(void)
|
||||
if (ret < 0 && errno == ENOTDIR)
|
||||
ret = unlink(path.buf);
|
||||
if (ret)
|
||||
error(_("failed to remove: %s"), strerror(errno));
|
||||
error_errno(_("failed to remove '%s'"), path.buf);
|
||||
}
|
||||
closedir(dir);
|
||||
if (!show_only)
|
||||
|
@ -12,7 +12,7 @@ int main(int ac, char **av)
|
||||
struct stat st;
|
||||
|
||||
if (lstat(ce->name, &st)) {
|
||||
error("lstat(%s): %s", ce->name, strerror(errno));
|
||||
error_errno("lstat(%s)", ce->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {
|
||||
error("readlink(%s): %s", elem->path,
|
||||
strerror(errno));
|
||||
error_errno("readlink(%s)", elem->path);
|
||||
return;
|
||||
}
|
||||
result_size = buf.len;
|
||||
|
@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
|
||||
va_end(ap);
|
||||
|
||||
if (str_len < 0) {
|
||||
warning("vsnprintf failed: '%s'", strerror(errno));
|
||||
warning_errno("vsnprintf failed");
|
||||
return;
|
||||
}
|
||||
|
||||
str = malloc(st_add(str_len, 1));
|
||||
if (!str) {
|
||||
warning("malloc failed: '%s'", strerror(errno));
|
||||
warning_errno("malloc failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)
|
||||
while ((pos = strstr(str, "%1")) != NULL) {
|
||||
str = realloc(str, st_add(++str_len, 1));
|
||||
if (!str) {
|
||||
warning("realloc failed: '%s'", strerror(errno));
|
||||
warning_errno("realloc failed");
|
||||
return;
|
||||
}
|
||||
memmove(pos + 2, pos + 1, strlen(pos));
|
||||
|
22
config.c
22
config.c
@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
lock = xcalloc(1, sizeof(struct lock_file));
|
||||
fd = hold_lock_file_for_update(lock, config_filename, 0);
|
||||
if (fd < 0) {
|
||||
error("could not lock config file %s: %s", config_filename, strerror(errno));
|
||||
error_errno("could not lock config file %s", config_filename);
|
||||
free(store.key);
|
||||
ret = CONFIG_NO_LOCK;
|
||||
goto out_free;
|
||||
@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
free(store.key);
|
||||
|
||||
if ( ENOENT != errno ) {
|
||||
error("opening %s: %s", config_filename,
|
||||
strerror(errno));
|
||||
error_errno("opening %s", config_filename);
|
||||
ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
|
||||
goto out_free;
|
||||
}
|
||||
@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
if (contents == MAP_FAILED) {
|
||||
if (errno == ENODEV && S_ISDIR(st.st_mode))
|
||||
errno = EISDIR;
|
||||
error("unable to mmap '%s': %s",
|
||||
config_filename, strerror(errno));
|
||||
error_errno("unable to mmap '%s'", config_filename);
|
||||
ret = CONFIG_INVALID_FILE;
|
||||
contents = NULL;
|
||||
goto out_free;
|
||||
@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
in_fd = -1;
|
||||
|
||||
if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
|
||||
error("chmod on %s failed: %s",
|
||||
get_lock_file_path(lock), strerror(errno));
|
||||
error_errno("chmod on %s failed", get_lock_file_path(lock));
|
||||
ret = CONFIG_NO_WRITE;
|
||||
goto out_free;
|
||||
}
|
||||
@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
|
||||
}
|
||||
|
||||
if (commit_lock_file(lock) < 0) {
|
||||
error("could not write config file %s: %s", config_filename,
|
||||
strerror(errno));
|
||||
error_errno("could not write config file %s", config_filename);
|
||||
ret = CONFIG_NO_WRITE;
|
||||
lock = NULL;
|
||||
goto out_free;
|
||||
@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,
|
||||
fstat(fileno(config_file), &st);
|
||||
|
||||
if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
|
||||
ret = error("chmod on %s failed: %s",
|
||||
get_lock_file_path(lock), strerror(errno));
|
||||
ret = error_errno("chmod on %s failed",
|
||||
get_lock_file_path(lock));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,
|
||||
fclose(config_file);
|
||||
unlock_and_out:
|
||||
if (commit_lock_file(lock) < 0)
|
||||
ret = error("could not write config file %s: %s",
|
||||
config_filename, strerror(errno));
|
||||
ret = error_errno("could not write config file %s",
|
||||
config_filename);
|
||||
out:
|
||||
free(filename_buf);
|
||||
return ret;
|
||||
|
@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
|
||||
memcpy(commit, sha1_to_hex(sha1), 40);
|
||||
if (write_in_full(rev_list.in, commit, 41) < 0) {
|
||||
if (errno != EPIPE && errno != EINVAL)
|
||||
error(_("failed write to rev-list: %s"),
|
||||
strerror(errno));
|
||||
error_errno(_("failed write to rev-list"));
|
||||
err = -1;
|
||||
break;
|
||||
}
|
||||
} while (!fn(cb_data, sha1));
|
||||
|
||||
if (close(rev_list.in)) {
|
||||
error(_("failed to close rev-list's stdin: %s"), strerror(errno));
|
||||
err = -1;
|
||||
}
|
||||
if (close(rev_list.in))
|
||||
err = error_errno(_("failed to close rev-list's stdin"));
|
||||
|
||||
sigchain_pop(SIGPIPE);
|
||||
return finish_command(&rev_list) || err;
|
||||
|
6
copy.c
6
copy.c
@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)
|
||||
status = copy_fd(fdi, fdo);
|
||||
switch (status) {
|
||||
case COPY_READ_ERROR:
|
||||
error("copy-fd: read returned %s", strerror(errno));
|
||||
error_errno("copy-fd: read returned");
|
||||
break;
|
||||
case COPY_WRITE_ERROR:
|
||||
error("copy-fd: write returned %s", strerror(errno));
|
||||
error_errno("copy-fd: write returned");
|
||||
break;
|
||||
}
|
||||
close(fdi);
|
||||
if (close(fdo) != 0)
|
||||
return error("%s: close error: %s", dst, strerror(errno));
|
||||
return error_errno("%s: close error", dst);
|
||||
|
||||
if (!status && adjust_shared_perm(dst))
|
||||
return -1;
|
||||
|
@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)
|
||||
|
||||
client = accept(fd, NULL, NULL);
|
||||
if (client < 0) {
|
||||
warning("accept failed: %s", strerror(errno));
|
||||
warning_errno("accept failed");
|
||||
return 1;
|
||||
}
|
||||
client2 = dup(client);
|
||||
if (client2 < 0) {
|
||||
warning("dup failed: %s", strerror(errno));
|
||||
warning_errno("dup failed");
|
||||
close(client);
|
||||
return 1;
|
||||
}
|
||||
|
@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)
|
||||
size_t size = 0;
|
||||
|
||||
if (strbuf_read(&buf, 0, 0) < 0)
|
||||
return error("error while reading from stdin %s",
|
||||
strerror(errno));
|
||||
return error_errno("error while reading from stdin");
|
||||
|
||||
s->should_munmap = 0;
|
||||
s->data = strbuf_detach(&buf, &size);
|
||||
|
3
editor.c
3
editor.c
@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
|
||||
if (!buffer)
|
||||
return 0;
|
||||
if (strbuf_read_file(buffer, path, 0) < 0)
|
||||
return error("could not read file '%s': %s",
|
||||
path, strerror(errno));
|
||||
return error_errno("could not read file '%s'", path);
|
||||
return 0;
|
||||
}
|
||||
|
10
entry.c
10
entry.c
@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,
|
||||
ret = symlink(new, path);
|
||||
free(new);
|
||||
if (ret)
|
||||
return error("unable to create symlink %s (%s)",
|
||||
path, strerror(errno));
|
||||
return error_errno("unable to create symlink %s",
|
||||
path);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,
|
||||
fd = open_output_fd(path, ce, to_tempfile);
|
||||
if (fd < 0) {
|
||||
free(new);
|
||||
return error("unable to create file %s (%s)",
|
||||
path, strerror(errno));
|
||||
return error_errno("unable to create file %s", path);
|
||||
}
|
||||
|
||||
wrote = write_in_full(fd, new, size);
|
||||
@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,
|
||||
return error("%s is a directory", path.buf);
|
||||
remove_subtree(&path);
|
||||
} else if (unlink(path.buf))
|
||||
return error("unable to unlink old '%s' (%s)",
|
||||
path.buf, strerror(errno));
|
||||
return error_errno("unable to unlink old '%s'", path.buf);
|
||||
} else if (state->not_new)
|
||||
return 0;
|
||||
|
||||
|
@ -414,7 +414,7 @@ static void write_crash_report(const char *err)
|
||||
struct recent_command *rc;
|
||||
|
||||
if (!rpt) {
|
||||
error("can't write crash report %s: %s", loc, strerror(errno));
|
||||
error_errno("can't write crash report %s", loc);
|
||||
free(loc);
|
||||
return;
|
||||
}
|
||||
@ -1806,8 +1806,8 @@ static void dump_marks(void)
|
||||
return;
|
||||
|
||||
if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
|
||||
failure |= error("Unable to write marks file %s: %s",
|
||||
export_marks_file, strerror(errno));
|
||||
failure |= error_errno("Unable to write marks file %s",
|
||||
export_marks_file);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1822,8 +1822,8 @@ static void dump_marks(void)
|
||||
|
||||
dump_marks_helper(f, 0, marks);
|
||||
if (commit_lock_file(&mark_lock)) {
|
||||
failure |= error("Unable to write file %s: %s",
|
||||
export_marks_file, strerror(errno));
|
||||
failure |= error_errno("Unable to write file %s",
|
||||
export_marks_file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,
|
||||
extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
|
||||
|
||||
#ifndef NO_OPENSSL
|
||||
#ifdef APPLE_COMMON_CRYPTO
|
||||
|
@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
|
||||
args_gpg[0] = gpg_program;
|
||||
fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
|
||||
if (fd < 0)
|
||||
return error(_("could not create temporary file '%s': %s"),
|
||||
path, strerror(errno));
|
||||
return error_errno(_("could not create temporary file '%s'"), path);
|
||||
if (write_in_full(fd, signature, signature_size) < 0)
|
||||
return error(_("failed writing detached signature to '%s': %s"),
|
||||
path, strerror(errno));
|
||||
return error_errno(_("failed writing detached signature to '%s'"), path);
|
||||
close(fd);
|
||||
|
||||
gpg.argv = args_gpg;
|
||||
|
4
grep.c
4
grep.c
@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
|
||||
if (lstat(filename, &st) < 0) {
|
||||
err_ret:
|
||||
if (errno != ENOENT)
|
||||
error(_("'%s': %s"), filename, strerror(errno));
|
||||
error_errno(_("failed to stat '%s'"), filename);
|
||||
return -1;
|
||||
}
|
||||
if (!S_ISREG(st.st_mode))
|
||||
@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)
|
||||
goto err_ret;
|
||||
data = xmallocz(size);
|
||||
if (st.st_size != read_in_full(i, data, size)) {
|
||||
error(_("'%s': short read %s"), filename, strerror(errno));
|
||||
error_errno(_("'%s': short read"), filename);
|
||||
close(i);
|
||||
free(data);
|
||||
return -1;
|
||||
|
10
http.c
10
http.c
@ -460,8 +460,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
|
||||
|
||||
rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);
|
||||
if (rc < 0)
|
||||
warning("unable to set SO_KEEPALIVE on socket %s",
|
||||
strerror(errno));
|
||||
warning_errno("unable to set SO_KEEPALIVE on socket");
|
||||
|
||||
return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
|
||||
}
|
||||
@ -1923,8 +1922,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
|
||||
}
|
||||
|
||||
if (freq->localfile < 0) {
|
||||
error("Couldn't create temporary file %s: %s",
|
||||
freq->tmpfile, strerror(errno));
|
||||
error_errno("Couldn't create temporary file %s", freq->tmpfile);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
@ -1969,8 +1967,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
|
||||
prev_posn = 0;
|
||||
lseek(freq->localfile, 0, SEEK_SET);
|
||||
if (ftruncate(freq->localfile, 0) < 0) {
|
||||
error("Couldn't truncate temporary file %s: %s",
|
||||
freq->tmpfile, strerror(errno));
|
||||
error_errno("Couldn't truncate temporary file %s",
|
||||
freq->tmpfile);
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
|
8
ident.c
8
ident.c
@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)
|
||||
mailname = fopen("/etc/mailname", "r");
|
||||
if (!mailname) {
|
||||
if (errno != ENOENT)
|
||||
warning("cannot open /etc/mailname: %s",
|
||||
strerror(errno));
|
||||
warning_errno("cannot open /etc/mailname");
|
||||
return -1;
|
||||
}
|
||||
if (strbuf_getline(&mailnamebuf, mailname) == EOF) {
|
||||
if (ferror(mailname))
|
||||
warning("cannot read /etc/mailname: %s",
|
||||
strerror(errno));
|
||||
warning_errno("cannot read /etc/mailname");
|
||||
strbuf_release(&mailnamebuf);
|
||||
fclose(mailname);
|
||||
return -1;
|
||||
@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)
|
||||
char buf[1024];
|
||||
|
||||
if (gethostname(buf, sizeof(buf))) {
|
||||
warning("cannot get host name: %s", strerror(errno));
|
||||
warning_errno("cannot get host name");
|
||||
strbuf_addstr(out, "(none)");
|
||||
*is_bogus = 1;
|
||||
return;
|
||||
|
@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
return error("unable to open mailmap at %s: %s",
|
||||
filename, strerror(errno));
|
||||
return error_errno("unable to open mailmap at %s", filename);
|
||||
}
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), f) != NULL)
|
||||
|
@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,
|
||||
*/
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
return error("unable to stat %s: %s",
|
||||
sha1_to_hex(sha1), strerror(errno));
|
||||
return error_errno("unable to stat %s", sha1_to_hex(sha1));
|
||||
}
|
||||
|
||||
add_recent_object(sha1, st.st_mtime, data);
|
||||
|
18
rerere.c
18
rerere.c
@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
|
||||
error("There were errors while writing %s (%s)",
|
||||
path, strerror(io.io.wrerror));
|
||||
if (io.io.output && fclose(io.io.output))
|
||||
io.io.wrerror = error("Failed to flush %s: %s",
|
||||
path, strerror(errno));
|
||||
io.io.wrerror = error_errno("Failed to flush %s", path);
|
||||
|
||||
if (hunk_no < 0) {
|
||||
if (output)
|
||||
@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)
|
||||
* Mark that "postimage" was used to help gc.
|
||||
*/
|
||||
if (utime(rerere_path(id, "postimage"), NULL) < 0)
|
||||
warning("failed utime() on %s: %s",
|
||||
rerere_path(id, "postimage"),
|
||||
strerror(errno));
|
||||
warning_errno("failed utime() on %s",
|
||||
rerere_path(id, "postimage"));
|
||||
|
||||
/* Update "path" with the resolution */
|
||||
f = fopen(path, "w");
|
||||
if (!f)
|
||||
return error("Could not open %s: %s", path,
|
||||
strerror(errno));
|
||||
return error_errno("Could not open %s", path);
|
||||
if (fwrite(result.ptr, result.size, 1, f) != 1)
|
||||
error("Could not write %s: %s", path, strerror(errno));
|
||||
error_errno("Could not write %s", path);
|
||||
if (fclose(f))
|
||||
return error("Writing %s failed: %s", path,
|
||||
strerror(errno));
|
||||
return error_errno("Writing %s failed", path);
|
||||
|
||||
out:
|
||||
free(cur.ptr);
|
||||
@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
|
||||
if (unlink(filename))
|
||||
return (errno == ENOENT
|
||||
? error("no remembered resolution for %s", path)
|
||||
: error("cannot unlink %s: %s", filename, strerror(errno)));
|
||||
: error_errno("cannot unlink %s", filename));
|
||||
|
||||
/*
|
||||
* Update the preimage so that the user can resolve the
|
||||
|
@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
|
||||
|
||||
if (waiting < 0) {
|
||||
failed_errno = errno;
|
||||
error("waitpid for %s failed: %s", argv0, strerror(errno));
|
||||
error_errno("waitpid for %s failed", argv0);
|
||||
} else if (waiting != pid) {
|
||||
error("waitpid is confused (%s)", argv0);
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
@ -420,8 +420,7 @@ fail_pipe:
|
||||
}
|
||||
}
|
||||
if (cmd->pid < 0)
|
||||
error("cannot fork() for %s: %s", cmd->argv[0],
|
||||
strerror(errno));
|
||||
error_errno("cannot fork() for %s", cmd->argv[0]);
|
||||
else if (cmd->clean_on_exit)
|
||||
mark_child_for_cleanup(cmd->pid);
|
||||
|
||||
@ -482,7 +481,7 @@ fail_pipe:
|
||||
cmd->dir, fhin, fhout, fherr);
|
||||
failed_errno = errno;
|
||||
if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
|
||||
error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
|
||||
error_errno("cannot spawn %s", cmd->argv[0]);
|
||||
if (cmd->clean_on_exit && cmd->pid >= 0)
|
||||
mark_child_for_cleanup(cmd->pid);
|
||||
|
||||
@ -703,7 +702,7 @@ int start_async(struct async *async)
|
||||
if (pipe(fdin) < 0) {
|
||||
if (async->out > 0)
|
||||
close(async->out);
|
||||
return error("cannot create pipe: %s", strerror(errno));
|
||||
return error_errno("cannot create pipe");
|
||||
}
|
||||
async->in = fdin[1];
|
||||
}
|
||||
@ -715,7 +714,7 @@ int start_async(struct async *async)
|
||||
close_pair(fdin);
|
||||
else if (async->in)
|
||||
close(async->in);
|
||||
return error("cannot create pipe: %s", strerror(errno));
|
||||
return error_errno("cannot create pipe");
|
||||
}
|
||||
async->out = fdout[0];
|
||||
}
|
||||
@ -740,7 +739,7 @@ int start_async(struct async *async)
|
||||
|
||||
async->pid = fork();
|
||||
if (async->pid < 0) {
|
||||
error("fork (async) failed: %s", strerror(errno));
|
||||
error_errno("fork (async) failed");
|
||||
goto error;
|
||||
}
|
||||
if (!async->pid) {
|
||||
@ -787,7 +786,7 @@ int start_async(struct async *async)
|
||||
{
|
||||
int err = pthread_create(&async->tid, NULL, run_thread, async);
|
||||
if (err) {
|
||||
error("cannot create thread: %s", strerror(err));
|
||||
error_errno("cannot create thread");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)
|
||||
return rollback_single_pick();
|
||||
}
|
||||
if (!f)
|
||||
return error(_("cannot open %s: %s"), git_path_head_file(),
|
||||
strerror(errno));
|
||||
return error_errno(_("cannot open %s"), git_path_head_file());
|
||||
if (strbuf_getline_lf(&buf, f)) {
|
||||
error(_("cannot read %s: %s"), git_path_head_file(),
|
||||
ferror(f) ? strerror(errno) : _("unexpected end of file"));
|
||||
|
@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
|
||||
|
||||
out:
|
||||
if (ret) {
|
||||
error("unable to update %s: %s", path, strerror(errno));
|
||||
error_errno("unable to update %s", path);
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
else if (fd >= 0)
|
||||
|
32
sha1_file.c
32
sha1_file.c
@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,
|
||||
PROT_READ, MAP_PRIVATE,
|
||||
p->pack_fd, win->offset);
|
||||
if (win->base == MAP_FAILED)
|
||||
die("packfile %s cannot be mapped: %s",
|
||||
p->pack_name,
|
||||
strerror(errno));
|
||||
die_errno("packfile %s cannot be mapped",
|
||||
p->pack_name);
|
||||
if (!win->offset && win->len == p->pack_size
|
||||
&& !p->do_not_close)
|
||||
close_pack_fd(p);
|
||||
@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)
|
||||
dir = opendir(path.buf);
|
||||
if (!dir) {
|
||||
if (errno != ENOENT)
|
||||
error("unable to open object pack directory: %s: %s",
|
||||
path.buf, strerror(errno));
|
||||
error_errno("unable to open object pack directory: %s",
|
||||
path.buf);
|
||||
strbuf_release(&path);
|
||||
return;
|
||||
}
|
||||
@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)
|
||||
unlink_or_warn(tmpfile);
|
||||
if (ret) {
|
||||
if (ret != EEXIST) {
|
||||
return error("unable to write sha1 filename %s: %s", filename, strerror(ret));
|
||||
return error_errno("unable to write sha1 filename %s", filename);
|
||||
}
|
||||
/* FIXME!!! Collision check here ? */
|
||||
}
|
||||
@ -2998,7 +2997,7 @@ out:
|
||||
static int write_buffer(int fd, const void *buf, size_t len)
|
||||
{
|
||||
if (write_in_full(fd, buf, len) < 0)
|
||||
return error("file write error (%s)", strerror(errno));
|
||||
return error_errno("file write error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
|
||||
if (errno == EACCES)
|
||||
return error("insufficient permission for adding an object to repository database %s", get_object_directory());
|
||||
else
|
||||
return error("unable to create temporary file: %s", strerror(errno));
|
||||
return error_errno("unable to create temporary file");
|
||||
}
|
||||
|
||||
/* Set it up */
|
||||
@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
|
||||
utb.actime = mtime;
|
||||
utb.modtime = mtime;
|
||||
if (utime(tmp_file.buf, &utb) < 0)
|
||||
warning("failed utime() on %s: %s",
|
||||
tmp_file.buf, strerror(errno));
|
||||
warning_errno("failed utime() on %s", tmp_file.buf);
|
||||
}
|
||||
|
||||
return finalize_object_file(tmp_file.buf, filename);
|
||||
@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,
|
||||
if (size == read_in_full(fd, buf, size))
|
||||
ret = index_mem(sha1, buf, size, type, path, flags);
|
||||
else
|
||||
ret = error("short read %s", strerror(errno));
|
||||
ret = error_errno("short read");
|
||||
free(buf);
|
||||
} else {
|
||||
void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
|
||||
case S_IFREG:
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return error("open(\"%s\"): %s", path,
|
||||
strerror(errno));
|
||||
return error_errno("open(\"%s\")", path);
|
||||
if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)
|
||||
return error("%s: failed to insert into database",
|
||||
path);
|
||||
break;
|
||||
case S_IFLNK:
|
||||
if (strbuf_readlink(&sb, path, st->st_size)) {
|
||||
char *errstr = strerror(errno);
|
||||
return error("readlink(\"%s\"): %s", path,
|
||||
errstr);
|
||||
}
|
||||
if (strbuf_readlink(&sb, path, st->st_size))
|
||||
return error_errno("readlink(\"%s\")", path);
|
||||
if (!(flags & HASH_WRITE_OBJECT))
|
||||
hash_sha1_file(sb.buf, sb.len, blob_type, sha1);
|
||||
else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))
|
||||
@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
|
||||
if (!dir) {
|
||||
if (errno == ENOENT)
|
||||
return 0;
|
||||
return error("unable to open %s: %s", path->buf, strerror(errno));
|
||||
return error_errno("unable to open %s", path->buf);
|
||||
}
|
||||
|
||||
while ((de = readdir(dir))) {
|
||||
|
@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
|
||||
bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
|
||||
if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
|
||||
errno != EINTR) {
|
||||
error("read(%s) failed: %s", t->src_name, strerror(errno));
|
||||
error_errno("read(%s) failed", t->src_name);
|
||||
return -1;
|
||||
} else if (bytes == 0) {
|
||||
transfer_debug("%s EOF (with %i bytes in buffer)",
|
||||
@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
|
||||
transfer_debug("%s is writable", t->dest_name);
|
||||
bytes = xwrite(t->dest, t->buf, t->bufuse);
|
||||
if (bytes < 0 && errno != EWOULDBLOCK) {
|
||||
error("write(%s) failed: %s", t->dest_name, strerror(errno));
|
||||
error_errno("write(%s) failed", t->dest_name);
|
||||
return -1;
|
||||
} else if (bytes > 0) {
|
||||
t->bufuse -= bytes;
|
||||
@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)
|
||||
{
|
||||
int tret;
|
||||
if (waitpid(pid, &tret, 0) < 0) {
|
||||
error("%s process failed to wait: %s", name, strerror(errno));
|
||||
error_errno("%s process failed to wait", name);
|
||||
return 1;
|
||||
}
|
||||
if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
|
||||
|
@ -1533,8 +1533,7 @@ static int verify_absent_1(const struct cache_entry *ce,
|
||||
|
||||
path = xmemdupz(ce->name, len);
|
||||
if (lstat(path, &st))
|
||||
ret = error("cannot stat '%s': %s", path,
|
||||
strerror(errno));
|
||||
ret = error_errno("cannot stat '%s'", path);
|
||||
else
|
||||
ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
|
||||
&st, error_type, o);
|
||||
@ -1542,8 +1541,7 @@ static int verify_absent_1(const struct cache_entry *ce,
|
||||
return ret;
|
||||
} else if (lstat(ce->name, &st)) {
|
||||
if (errno != ENOENT)
|
||||
return error("cannot stat '%s': %s", ce->name,
|
||||
strerror(errno));
|
||||
return error_errno("cannot stat '%s'", ce->name);
|
||||
return 0;
|
||||
} else {
|
||||
return check_ok_to_remove(ce->name, ce_namelen(ce),
|
||||
|
@ -174,8 +174,7 @@ static void create_pack_file(void)
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno != EINTR) {
|
||||
error("poll failed, resuming: %s",
|
||||
strerror(errno));
|
||||
error_errno("poll failed, resuming");
|
||||
sleep(1);
|
||||
}
|
||||
continue;
|
||||
|
48
usage.c
48
usage.c
@ -109,19 +109,11 @@ void NORETURN die(const char *err, ...)
|
||||
va_end(params);
|
||||
}
|
||||
|
||||
void NORETURN die_errno(const char *fmt, ...)
|
||||
static const char *fmt_with_err(char *buf, int n, const char *fmt)
|
||||
{
|
||||
va_list params;
|
||||
char fmt_with_err[1024];
|
||||
char str_error[256], *err;
|
||||
int i, j;
|
||||
|
||||
if (die_is_recursing()) {
|
||||
fputs("fatal: recursion detected in die_errno handler\n",
|
||||
stderr);
|
||||
exit(128);
|
||||
}
|
||||
|
||||
err = strerror(errno);
|
||||
for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
|
||||
if ((str_error[j++] = err[i++]) != '%')
|
||||
@ -136,13 +128,37 @@ void NORETURN die_errno(const char *fmt, ...)
|
||||
}
|
||||
}
|
||||
str_error[j] = 0;
|
||||
snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
|
||||
snprintf(buf, n, "%s: %s", fmt, str_error);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void NORETURN die_errno(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list params;
|
||||
|
||||
if (die_is_recursing()) {
|
||||
fputs("fatal: recursion detected in die_errno handler\n",
|
||||
stderr);
|
||||
exit(128);
|
||||
}
|
||||
|
||||
va_start(params, fmt);
|
||||
die_routine(fmt_with_err, params);
|
||||
die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
|
||||
va_end(params);
|
||||
}
|
||||
|
||||
int error_errno(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list params;
|
||||
|
||||
va_start(params, fmt);
|
||||
error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
|
||||
va_end(params);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#undef error
|
||||
int error(const char *err, ...)
|
||||
{
|
||||
@ -154,6 +170,16 @@ int error(const char *err, ...)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void warning_errno(const char *warn, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list params;
|
||||
|
||||
va_start(params, warn);
|
||||
warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
|
||||
va_end(params);
|
||||
}
|
||||
|
||||
void warning(const char *warn, ...)
|
||||
{
|
||||
va_list params;
|
||||
|
@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)
|
||||
{
|
||||
long pos = ftell(buf->infile);
|
||||
if (pos < 0)
|
||||
return error("ftell error: %s", strerror(errno));
|
||||
return error_errno("ftell error");
|
||||
if (fseek(buf->infile, 0, SEEK_SET))
|
||||
return error("seek error: %s", strerror(errno));
|
||||
return error_errno("seek error");
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)
|
||||
{
|
||||
if (!buffer_ferror(file))
|
||||
return error("delta preimage ends early");
|
||||
return error("cannot read delta preimage: %s", strerror(errno));
|
||||
return error_errno("cannot read delta preimage");
|
||||
}
|
||||
|
||||
static int skip_or_whine(struct line_buffer *file, off_t gap)
|
||||
|
@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)
|
||||
{
|
||||
if (fwrite(sb->buf, 1, sb->len, out) == sb->len) /* Success. */
|
||||
return 0;
|
||||
return error("cannot write delta postimage: %s", strerror(errno));
|
||||
return error_errno("cannot write delta postimage");
|
||||
}
|
||||
|
||||
static int error_short_read(struct line_buffer *input)
|
||||
{
|
||||
if (buffer_ferror(input))
|
||||
return error("error reading delta: %s", strerror(errno));
|
||||
return error_errno("error reading delta");
|
||||
return error("invalid delta: unexpected end of file");
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ static void init(int report_fd)
|
||||
int svndump_init(const char *filename)
|
||||
{
|
||||
if (buffer_init(&input, filename))
|
||||
return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
|
||||
return error_errno("cannot open %s", filename ? filename : "NULL");
|
||||
init(REPORT_FILENO);
|
||||
return 0;
|
||||
}
|
||||
@ -509,7 +509,7 @@ int svndump_init(const char *filename)
|
||||
int svndump_init_fd(int in_fd, int back_fd)
|
||||
{
|
||||
if(buffer_fdinit(&input, xdup(in_fd)))
|
||||
return error("cannot open fd %d: %s", in_fd, strerror(errno));
|
||||
return error_errno("cannot open fd %d", in_fd);
|
||||
init(xdup(back_fd));
|
||||
return 0;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)
|
||||
if (!rc || errno == ENOENT)
|
||||
return 0;
|
||||
err = errno;
|
||||
warning("unable to %s %s: %s", op, file, strerror(errno));
|
||||
warning_errno("unable to %s %s", op, file);
|
||||
errno = err;
|
||||
return rc;
|
||||
}
|
||||
@ -591,7 +591,7 @@ int remove_or_warn(unsigned int mode, const char *file)
|
||||
|
||||
void warn_on_inaccessible(const char *path)
|
||||
{
|
||||
warning(_("unable to access '%s': %s"), path, strerror(errno));
|
||||
warning_errno(_("unable to access '%s'"), path);
|
||||
}
|
||||
|
||||
static int access_error_is_ok(int err, unsigned flag)
|
||||
|
Loading…
Reference in New Issue
Block a user