commit - e0870e443a8dfb50091e64747658a3e0740f82bb
commit + 638f9024045bbe2420143f8868dcc484c231c634
blob - 8c9793810718d7086090d59a084fe0d09f7c2d28
blob + 1b3478d6fcd84eda39aed0a1c511c6d4f9a58084
--- got/got.c
+++ got/got.c
*editorp = realpath(editor, NULL);
if (*editorp == NULL)
- return got_error_prefix_errno("relpath");
+ return got_error_from_errno("relpath");
return NULL;
}
}
if (repo_path && unveil(repo_path, repo_read_only ? "r" : "rwc") != 0)
- return got_error_prefix_errno2("unveil", repo_path);
+ return got_error_from_errno2("unveil", repo_path);
if (worktree_path && unveil(worktree_path, "rwc") != 0)
- return got_error_prefix_errno2("unveil", worktree_path);
+ return got_error_from_errno2("unveil", worktree_path);
if (unveil("/tmp", "rwc") != 0)
- return got_error_prefix_errno2("unveil", "/tmp");
+ return got_error_from_errno2("unveil", "/tmp");
error = got_privsep_unveil_exec_helpers();
if (error != NULL)
return error;
if (unveil(NULL, NULL) != 0)
- return got_error_prefix_errno("unveil");
+ return got_error_from_errno("unveil");
return NULL;
}
case 'c':
commit_id_str = strdup(optarg);
if (commit_id_str == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
break;
case 'p':
path_prefix = optarg;
char *cwd, *base, *dotgit;
repo_path = realpath(argv[0], NULL);
if (repo_path == NULL)
- return got_error_prefix_errno2("realpath", argv[0]);
+ return got_error_from_errno2("realpath", argv[0]);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (path_prefix[0]) {
base = basename(path_prefix);
if (base == NULL) {
- error = got_error_prefix_errno2("basename",
+ error = got_error_from_errno2("basename",
path_prefix);
goto done;
}
} else {
base = basename(repo_path);
if (base == NULL) {
- error = got_error_prefix_errno2("basename",
+ error = got_error_from_errno2("basename",
repo_path);
goto done;
}
if (dotgit)
*dotgit = '\0';
if (asprintf(&worktree_path, "%s/%s", cwd, base) == -1) {
- error = got_error_prefix_errno("asprintf");
+ error = got_error_from_errno("asprintf");
free(cwd);
goto done;
}
} else if (argc == 2) {
repo_path = realpath(argv[0], NULL);
if (repo_path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[0]);
+ error = got_error_from_errno2("realpath", argv[0]);
goto done;
}
worktree_path = realpath(argv[1], NULL);
if (worktree_path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[1]);
+ error = got_error_from_errno2("realpath", argv[1]);
goto done;
}
} else
case 'c':
commit_id_str = strdup(optarg);
if (commit_id_str == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
break;
default:
usage_update();
#endif
worktree_path = getcwd(NULL, 0);
if (worktree_path == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, worktree_path);
if (argc == 0) {
path = strdup("");
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
} else if (argc == 1) {
s = refs_str;
if (asprintf(&refs_str, "%s%s%s", s ? s : "", s ? ", " : "",
name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(s);
break;
}
logmsg0 = strdup(got_object_commit_get_logmsg(commit));
if (logmsg0 == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
logmsg = logmsg0;
do {
}
if (fflush(stdout) != 0 && err == NULL)
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
return err;
}
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (argc == 0) {
path = strdup("");
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
} else if (argc == 1) {
} else {
path = strdup(argv[0]);
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
}
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
id = got_object_id_dup(
got_object_tag_get_object_id(tag));
if (id == NULL)
- error = got_error_prefix_errno(
+ error = got_error_from_errno(
"got_object_id_dup");
got_object_tag_close(tag);
if (error)
if (status != GOT_STATUS_DELETE) {
if (asprintf(&abspath, "%s/%s",
got_worktree_get_root_path(a->worktree), path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
f2 = fopen(abspath, "r");
if (f2 == NULL) {
- err = got_error_prefix_errno2("fopen", abspath);
+ err = got_error_from_errno2("fopen", abspath);
goto done;
}
if (lstat(abspath, &sb) == -1) {
- err = got_error_prefix_errno2("lstat", abspath);
+ err = got_error_from_errno2("lstat", abspath);
goto done;
}
} else
if (blob1)
got_object_blob_close(blob1);
if (f2 && fclose(f2) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
free(abspath);
return err;
}
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, cwd);
"-r option can't be used when diffing a work tree");
repo_path = strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
if (argc == 1) {
} else {
path = strdup("");
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
if (repo_path == NULL) {
repo_path = getcwd(NULL, 0);
if (repo_path == NULL)
- return got_error_prefix_errno("getcwd");
+ return got_error_from_errno("getcwd");
}
error = got_repo_open(&repo, repo_path);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (repo_path == NULL) {
repo_path =
strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL)
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
if (error)
goto done;
} else {
repo_path = strdup(cwd);
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
prefix, (strcmp(prefix, "/") != 0) ? "/" : "",
worktree_subdir, worktree_subdir[0] ? "/" : "",
path) == -1) {
- error = got_error_prefix_errno("asprintf");
+ error = got_error_from_errno("asprintf");
goto done;
}
error = got_repo_map_path(&in_repo_path, repo, p, 0);
if (err)
goto done;
if (asprintf(&id, "%s ", id_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(id_str);
goto done;
}
if (asprintf(&child_path, "%s%s%s", path,
path[0] == '/' && path[1] == '\0' ? "" : "/",
te->name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
err = print_tree(child_path, commit_id, show_ids, 1,
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (repo_path == NULL) {
repo_path =
strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL)
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
if (error)
goto done;
} else {
repo_path = strdup(cwd);
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
if (asprintf(&p, "%s/%s",
got_worktree_get_path_prefix(worktree),
worktree_subdir) == -1) {
- error = got_error_prefix_errno("asprintf");
+ error = got_error_from_errno("asprintf");
goto done;
}
error = got_repo_map_path(&in_repo_path, repo, p, 1);
#endif
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (argc == 0) {
path = strdup("");
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
} else if (argc == 1) {
char *refstr;
refstr = got_ref_to_str(re->ref);
if (refstr == NULL)
- return got_error_prefix_errno("got_ref_to_str");
+ return got_error_from_errno("got_ref_to_str");
printf("%s: %s\n", got_ref_get_name(re->ref), refstr);
free(refstr);
}
#endif
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
repo_path =
strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL)
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
if (error)
goto done;
} else {
repo_path = strdup(cwd);
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
for (x = 0; x < argc; x++) {
char *path = realpath(argv[x], NULL);
if (path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[x]);
+ error = got_error_from_errno2("realpath", argv[x]);
goto done;
}
free(path);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
for (x = 0; x < argc; x++) {
char *path = realpath(argv[x], NULL);
if (path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[x]);
+ error = got_error_from_errno2("realpath", argv[x]);
goto done;
}
path = realpath(argv[0], NULL);
if (path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[0]);
+ error = got_error_from_errno2("realpath", argv[0]);
goto done;
}
got_path_strip_trailing_slashes(path);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, cwd);
path = realpath(argv[0], NULL);
if (path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[0]);
+ error = got_error_from_errno2("realpath", argv[0]);
goto done;
}
got_path_strip_trailing_slashes(path);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, cwd);
len = strlen(a->cmdline_log) + 1;
*logmsg = malloc(len + 1);
if (*logmsg == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
strlcpy(*logmsg, a->cmdline_log, len);
return NULL;
}
if (asprintf(&template, "%s/logmsg", a->worktree_path) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = got_opentemp_named_fd(&a->logmsg_path, &fd, template);
if (err)
close(fd);
if (stat(a->logmsg_path, &st) == -1) {
- err = got_error_prefix_errno2("stat", a->logmsg_path);
+ err = got_error_from_errno2("stat", a->logmsg_path);
goto done;
}
if (spawn_editor(a->editor, a->logmsg_path) == -1) {
- err = got_error_prefix_errno("failed spawning editor");
+ err = got_error_from_errno("failed spawning editor");
goto done;
}
if (stat(a->logmsg_path, &st2) == -1) {
- err = got_error_prefix_errno("stat");
+ err = got_error_from_errno("stat");
goto done;
}
/* remove comments */
*logmsg = malloc(st2.st_size + 1);
if (*logmsg == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
len = 0;
if (argc == 1) {
path = realpath(argv[0], NULL);
if (path == NULL) {
- error = got_error_prefix_errno2("realpath", argv[0]);
+ error = got_error_from_errno2("realpath", argv[0]);
goto done;
}
got_path_strip_trailing_slashes(path);
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, cwd);
blob - 8c60816b6a8c0f225778df8ccd601ec24c75905d
blob + ac0dd60795055f7852165994cc7a04140e98ade4
--- include/got_error.h
+++ include/got_error.h
* and an error message obtained from strerror(3), prefixed with a
* string.
*/
-const struct got_error *got_error_prefix_errno(const char *);
+const struct got_error *got_error_from_errno(const char *);
/*
* Get a statically allocated error object with code GOT_ERR_ERRNO
* and an error message obtained from strerror(3), prefixed with two
* strings.
*/
-const struct got_error *got_error_prefix_errno2(const char *, const char *);
+const struct got_error *got_error_from_errno2(const char *, const char *);
/*
* Get a statically allocated error object with code GOT_ERR_ERRNO
* and an error message obtained from strerror(3), prefixed with three
* strings.
*/
-const struct got_error *got_error_prefix_errno3(const char *, const char *,
+const struct got_error *got_error_from_errno3(const char *, const char *,
const char *);
/*
/*
* If ferror(3) indicates an error status for the FILE, obtain an error
- * from got_error_prefix_errno(). Else, obtain the error via got_error()
+ * from got_error_from_errno(). Else, obtain the error via got_error()
* with the error code provided in the second argument.
*/
const struct got_error *got_ferror(FILE *, int);
blob - 7774b2b34372b9bb7b0a2cf749c68e2bf015b105
blob + b4f8b83d691aa50dc051471e60fc030370cb8298
--- lib/blame.c
+++ lib/blame.c
*diff_offsets = calloc(1, sizeof(**diff_offsets));
if (*diff_offsets == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*diff_offsets)->commit_id = got_object_id_dup(commit_id);
if ((*diff_offsets)->commit_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
free_diff_offsets(*diff_offsets);
*diff_offsets = NULL;
return err;
struct got_blame_diff_offsets *diff_offsets;
if (blame->f && fclose(blame->f) != 0)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
free(blame->lines);
while (!SLIST_EMPTY(&blame->diff_offsets_list)) {
diff_offsets = SLIST_FIRST(&blame->diff_offsets_list);
blame = calloc(1, sizeof(*blame));
if (blame == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
blame->f = got_opentemp();
if (blame->f == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
err = got_object_blob_dump_to_file(NULL, &blame->nlines, blame->f,
blame->lines = calloc(blame->nlines, sizeof(*blame->lines));
if (blame->lines == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
char *abspath;
if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
- return got_error_prefix_errno2("asprintf", path);
+ return got_error_from_errno2("asprintf", path);
err = blame_open(&blame, abspath, start_commit_id, repo, NULL, NULL);
if (err) {
char *abspath;
if (asprintf(&abspath, "%s%s", path[0] == '/' ? "" : "/", path) == -1)
- return got_error_prefix_errno2("asprintf", path);
+ return got_error_from_errno2("asprintf", path);
err = blame_open(&blame, abspath, commit_id, repo, cb, arg);
free(abspath);
blob - 6f412d212911276fa303f51f02ccb124f9aa32bf
blob + 32d933f695c149153b60e1f90ede46c6fbb4a444
--- lib/buf.c
+++ lib/buf.c
if (errno == EACCES && unlink(path) != -1)
goto open;
else
- return got_error_prefix_errno2("open", path);
+ return got_error_from_errno2("open", path);
}
if (buf_write_fd(b, fd) == -1) {
- err = got_error_prefix_errno("buf_write_fd");
+ err = got_error_from_errno("buf_write_fd");
(void)unlink(path);
return err;
}
if (fchmod(fd, mode) < 0)
- err = got_error_prefix_errno2("fchmod", path);
+ err = got_error_from_errno2("fchmod", path);
if (close(fd) != 0 && err == NULL)
- err = got_error_prefix_errno2("close", path);
+ err = got_error_from_errno2("close", path);
return err;
}
int fd;
if ((fd = mkstemp(template)) == -1)
- return got_error_prefix_errno("mkstemp");
+ return got_error_from_errno("mkstemp");
worklist_add(template, temp_files);
if (buf_write_fd(b, fd) == -1) {
- err = got_error_prefix_errno("buf_write_fd");
+ err = got_error_from_errno("buf_write_fd");
(void)unlink(template);
}
if (close(fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err;
}
u_char *buf;
buf = reallocarray(b->cb_buf, 1, b->cb_size + len);
if (buf == NULL)
- return got_error_prefix_errno("reallocarray");
+ return got_error_from_errno("reallocarray");
b->cb_buf = buf;
b->cb_size += len;
return NULL;
blob - 4139ee71bae49e6be558c89523897640d2432187
blob + d33c70cf31264d8857f215e6d0b539fd4fe38c40
--- lib/commit_graph.c
+++ lib/commit_graph.c
node = calloc(1, sizeof(*node));
if (node == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
memcpy(&node->id, commit_id, sizeof(node->id));
node->timestamp = commit->committer_time;
*graph = alloc_graph(path);
if (*graph == NULL) {
got_object_commit_close(commit);
- return got_error_prefix_errno("alloc_graph");
+ return got_error_from_errno("alloc_graph");
}
if (first_parent_traversal)
tips = recallocarray(graph->tips, graph->ntips, ntips,
sizeof(*tips));
if (tips == NULL)
- return got_error_prefix_errno("recallocarray");
+ return got_error_from_errno("recallocarray");
graph->tips = tips;
graph->ntips = ntips;
}
commit_ids = got_object_idset_alloc();
if (commit_ids == NULL)
- return got_error_prefix_errno("got_object_idset_alloc");
+ return got_error_from_errno("got_object_idset_alloc");
err = got_commit_graph_open(&graph, commit_id, "/", 1, repo);
if (err)
if (*yca_id)
break;
else
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"got_object_id_up");
break;
if (*yca_id)
break;
else
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"got_object_id_up");
break;
blob - 9132c5f35b58d61b77c0903aae8453c5c904e90e
blob + c7771b4a68393727bf41bbc946aa8bf453fc98b8
--- lib/deflate.c
+++ lib/deflate.c
zerr = deflateInit(&zb->z, Z_DEFAULT_COMPRESSION);
if (zerr != Z_OK) {
if (zerr == Z_ERRNO)
- return got_error_prefix_errno("deflateInit");
+ return got_error_from_errno("deflateInit");
if (zerr == Z_MEM_ERROR) {
errno = ENOMEM;
- return got_error_prefix_errno("deflateInit");
+ return got_error_from_errno("deflateInit");
}
return got_error(GOT_ERR_COMPRESSION);
}
zb->inbuf = calloc(1, zb->inlen);
if (zb->inbuf == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
if (outbuf == NULL) {
zb->outbuf = calloc(1, zb->outlen);
if (zb->outbuf == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
zb->flags |= GOT_DEFLATE_F_OWN_OUTBUF;
blob - ecf6c0c261edbaf1cf5ae722612ff9a3662b761c
blob + 2bed5349b29f99b725d2d2023834eb1bf00a304f
--- lib/delta.c
+++ lib/delta.c
copy_from_base(FILE *base_file, off_t offset, size_t size, FILE *outfile)
{
if (fseeko(base_file, offset, SEEK_SET) != 0)
- return got_error_prefix_errno("fseeko");
+ return got_error_from_errno("fseeko");
while (size > 0) {
uint8_t data[2048];
if (memstream != NULL) {
if (fclose(memstream) != 0)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (err == NULL) {
size_t n;
n = fwrite(memstream_buf, 1, memstream_size, outfile);
blob - 52b0c876d15b2cc0cd2b50756652b61ded1a1258
blob + e2adb32c5a3b01901892c591b614ba36ebf26127
--- lib/diff.c
+++ lib/diff.c
if (blob1) {
f1 = got_opentemp();
if (f1 == NULL)
- return got_error_prefix_errno("got_opentemp");
+ return got_error_from_errno("got_opentemp");
} else
flags |= D_EMPTY1;
if (blob2) {
f2 = got_opentemp();
if (f2 == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
fclose(f1);
return err;
}
err = got_diffreg(&res, f1, f2, flags, &args, &ds, outfile, changes);
done:
if (f1 && fclose(f1) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (f2 && fclose(f2) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
if (blob1) {
f1 = got_opentemp();
if (f1 == NULL)
- return got_error_prefix_errno("got_opentemp");
+ return got_error_from_errno("got_opentemp");
idstr1 = got_object_blob_id_str(blob1, hex1, sizeof(hex1));
err = got_object_blob_dump_to_file(&size1, NULL, f1, blob1);
if (err)
err = got_diffreg(&res, f1, f2, flags, &args, &ds, outfile, NULL);
done:
if (f1 && fclose(f1) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
*changes = calloc(1, sizeof(**changes));
if (*changes == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
SIMPLEQ_INIT(&(*changes)->entries);
err = diff_blobs(blob1, blob2, NULL, NULL, 3, NULL, *changes);
te1 = SIMPLEQ_FIRST(&entries->head);
if (te1 && asprintf(&l1, "%s%s%s", label1, label1[0] ? "/" : "",
te1->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
if (tree2) {
const struct got_tree_entries *entries;
te2 = SIMPLEQ_FIRST(&entries->head);
if (te2 && asprintf(&l2, "%s%s%s", label2, label2[0] ? "/" : "",
te2->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
do {
if (te && asprintf(&l2, "%s%s%s", label2,
label2[0] ? "/" : "", te->name) == -1)
return
- got_error_prefix_errno("asprintf");
+ got_error_from_errno("asprintf");
}
err = diff_entry_old_new(te1, te, l1, l2, diff_context,
repo, outfile);
if (asprintf(&l2, "%s%s%s", label2,
label2[0] ? "/" : "", te->name) == -1)
return
- got_error_prefix_errno("asprintf");
+ got_error_from_errno("asprintf");
} else {
if (asprintf(&l2, "%s%s%s", label2,
label2[0] ? "/" : "", te2->name) == -1)
return
- got_error_prefix_errno("asprintf");
+ got_error_from_errno("asprintf");
}
err = diff_entry_new_old(te2, te, l2, diff_context,
repo, outfile);
if (te1 &&
asprintf(&l1, "%s%s%s", label1,
label1[0] ? "/" : "", te1->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
free(l2);
l2 = NULL;
if (te2 &&
asprintf(&l2, "%s%s%s", label2,
label2[0] ? "/" : "", te2->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
} while (te1 || te2);
blob - 8c259646842fa5061eae66ddd6cb0663f52071cb
blob + a04f3902152bc7dff80ea77f5d7132f765ac13b4
--- lib/diff3.c
+++ lib/diff3.c
i = vasprintf(&str, fmt, vap);
va_end(vap);
if (i == -1)
- return got_error_prefix_errno("vasprintf");
+ return got_error_from_errno("vasprintf");
buf_append(&newsize, diffbuf, str, strlen(str));
free(str);
return NULL;
f1 = fopen(path1, "r");
if (f1 == NULL) {
- err = got_error_prefix_errno2("fopen", path1);
+ err = got_error_from_errno2("fopen", path1);
goto done;
}
f2 = fopen(path2, "r");
if (f1 == NULL) {
- err = got_error_prefix_errno2("fopen", path2);
+ err = got_error_from_errno2("fopen", path2);
goto done;
}
memset(&ds, 0, sizeof(ds));
/* XXX should stat buffers be passed in args instead of ds? */
if (stat(path1, &ds.stb1) == -1) {
- err = got_error_prefix_errno2("stat", path1);
+ err = got_error_from_errno2("stat", path1);
goto done;
}
if (stat(path2, &ds.stb2) == -1) {
- err = got_error_prefix_errno2("stat", path2);
+ err = got_error_from_errno2("stat", path2);
goto done;
}
goto done;
if (fflush(outfile) != 0) {
- err = got_error_prefix_errno2("fflush", outpath);
+ err = got_error_from_errno2("fflush", outpath);
goto done;
}
*d = buf_load(outpath);
if (*d == NULL)
- err = got_error_prefix_errno("buf_load");
+ err = got_error_from_errno("buf_load");
done:
if (outpath) {
unlink(outpath);
free(outpath);
}
if (outfile && fclose(outfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (f1 && fclose(f1) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (f2 && fclose(f2) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
d3s = calloc(1, sizeof(*d3s));
if (d3s == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
d3s->eflag = 3; /* default -E for compatibility with former RCS */
d3s->oflag = 1; /* default -E for compatibility with former RCS */
diffb = buf_alloc(128);
if (asprintf(&path1, "/tmp/got-diff1.XXXXXXXX") == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto out;
}
if (asprintf(&path2, "/tmp/got-diff2.XXXXXXXX") == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto out;
}
if (asprintf(&path3, "/tmp/got-diff3.XXXXXXXX") == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto out;
}
}
if (asprintf(&dp13, "/tmp/got-d13.XXXXXXXXXX") == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto out;
}
err = buf_write_stmp(d1, dp13, &temp_files);
d1 = NULL;
if (asprintf(&dp23, "/tmp/got-d23.XXXXXXXXXX") == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto out;
}
err = buf_write_stmp(d2, dp23, &temp_files);
for (i = 0; i < nitems(d3s->fp); i++) {
if (d3s->fp[i] && fclose(d3s->fp[i]) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
if (err == NULL && diffb) {
if (buf_write_fd(diffb, outfd) < 0)
- err = got_error_prefix_errno("buf_write_fd");
+ err = got_error_from_errno("buf_write_fd");
*overlapcnt = d3s->overlapcnt;
}
free(d3s);
return err;
if ((d3s->fp[0] = fopen(path1, "r")) == NULL)
- return got_error_prefix_errno2("fopen", path1);
+ return got_error_from_errno2("fopen", path1);
if ((d3s->fp[1] = fopen(path2, "r")) == NULL)
- return got_error_prefix_errno2("fopen", path2);
+ return got_error_from_errno2("fopen", path2);
if ((d3s->fp[2] = fopen(path3, "r")) == NULL)
- return got_error_prefix_errno2("fopen", path3);
+ return got_error_from_errno2("fopen", path3);
if (merge(m, n, d3s) < 0)
- return got_error_prefix_errno("merge");
+ return got_error_from_errno("merge");
return NULL;
}
d3s->fp[0] = fopen(name, "r");
if (d3s->fp[0] == NULL)
- return got_error_prefix_errno2("fopen", name);
+ return got_error_from_errno2("fopen", name);
for (i = 0; (p = getchange(d3s->fp[0], d3s)); i++) {
if (i >= d3s->szchanges - 1) {
err = increase(d3s);
}
if (fclose(d3s->fp[0]) != 0)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
*n = i;
return err;
d = reallocarray(d3s->d13, newsz, sizeof(*d3s->d13));
if (d == NULL)
- return got_error_prefix_errno("reallocarray");
+ return got_error_from_errno("reallocarray");
d3s->d13 = d;
memset(d3s->d13 + d3s->szchanges, 0, incr * sizeof(*d3s->d13));
d = reallocarray(d3s->d23, newsz, sizeof(*d3s->d23));
if (d == NULL)
- return got_error_prefix_errno("reallocarray");
+ return got_error_from_errno("reallocarray");
d3s->d23 = d;
memset(d3s->d23 + d3s->szchanges, 0, incr * sizeof(*d3s->d23));
d = reallocarray(d3s->de, newsz, sizeof(*d3s->de));
if (d == NULL)
- return got_error_prefix_errno("reallocarray");
+ return got_error_from_errno("reallocarray");
d3s->de = d;
memset(d3s->de + d3s->szchanges, 0, incr * sizeof(*d3s->de));
s = reallocarray(d3s->overlap, newsz, sizeof(*d3s->overlap));
if (s == NULL)
- return got_error_prefix_errno("reallocarray");
+ return got_error_from_errno("reallocarray");
d3s->overlap = s;
memset(d3s->overlap + d3s->szchanges, 0, incr * sizeof(*d3s->overlap));
d3s->szchanges = newsz;
blob - 87f54533f4efc138efcb8ffe4b2043bae52623cd
blob + 5f4d297389d1fcdcdda02f1929bea4e8ecd572bf
--- lib/diffoffset.c
+++ lib/diffoffset.c
first = alloc_chunk(0, 0);
if (first == NULL)
- return got_error_prefix_errno("alloc_chunk");
+ return got_error_from_errno("alloc_chunk");
*chunks = calloc(1, sizeof(**chunks));
if (*chunks == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
free(first);
return err;
}
chunk1 = alloc_chunk(old_lineno, new_lineno - old_lineno);
if (chunk1 == NULL)
- return got_error_prefix_errno("alloc_chunk");
+ return got_error_from_errno("alloc_chunk");
chunk2 = alloc_chunk(old_lineno + old_length,
new_lineno - old_lineno + new_length - old_length);
if (chunk2 == NULL) {
const struct got_error *err =
- got_error_prefix_errno("alloc_chunk");
+ got_error_from_errno("alloc_chunk");
free(chunk1);
return err;
}
blob - fa4938c7bfaefec7a8494a0d6081ac999207a3e8
blob + e48ec98a28c616599460c2ff17bc027b86e2cddb
--- lib/diffreg.c
+++ lib/diffreg.c
if (flags & D_EMPTY1) {
f1 = fopen(_PATH_DEVNULL, "r");
if (f1 == NULL) {
- err = got_error_prefix_errno2("fopen", _PATH_DEVNULL);
+ err = got_error_from_errno2("fopen", _PATH_DEVNULL);
goto closem;
}
}
if (flags & D_EMPTY2) {
f2 = fopen(_PATH_DEVNULL, "r");
if (f2 == NULL) {
- err = got_error_prefix_errno2("fopen", _PATH_DEVNULL);
+ err = got_error_from_errno2("fopen", _PATH_DEVNULL);
goto closem;
}
} else if (f2 == NULL) {
goto closem;
}
if (prepare(ds, 0, f1, ds->stb1.st_size, flags)) {
- err = got_error_prefix_errno("prepare");
+ err = got_error_from_errno("prepare");
goto closem;
}
if (prepare(ds, 1, f2, ds->stb2.st_size, flags)) {
- err = got_error_prefix_errno("prepare");
+ err = got_error_from_errno("prepare");
goto closem;
}
equiv(ds->sfile[0], ds->slen[0], ds->sfile[1], ds->slen[1], ds->member);
p = reallocarray(ds->member, ds->slen[1] + 2, sizeof(*ds->member));
if (p == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto closem;
}
ds->member = p;
ds->class = (int *)ds->file[0];
if (unsort(ds->sfile[0], ds->slen[0], ds->class)) {
- err = got_error_prefix_errno("unsort");
+ err = got_error_from_errno("unsort");
goto closem;
}
p = reallocarray(ds->class, ds->slen[0] + 2, sizeof(*ds->class));
if (p == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto closem;
}
ds->class = p;
ds->klist = calloc(ds->slen[0] + 2, sizeof(*ds->klist));
if (ds->klist == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto closem;
}
ds->clen = 0;
ds->clistlen = 100;
ds->clist = calloc(ds->clistlen, sizeof(*ds->clist));
if (ds->clist == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto closem;
}
i = stone(ds, ds->class, ds->slen[0], ds->member, ds->klist, flags);
if (i < 0) {
- err = got_error_prefix_errno("stone");
+ err = got_error_from_errno("stone");
goto closem;
}
p = reallocarray(ds->J, ds->len[0] + 2, sizeof(*ds->J));
if (p == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto closem;
}
ds->J = p;
lp = reallocarray(ds->ixold, ds->len[0] + 2, sizeof(*ds->ixold));
if (lp == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto closem;
}
ds->ixold = lp;
lp = reallocarray(ds->ixnew, ds->len[1] + 2, sizeof(*ds->ixnew));
if (lp == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto closem;
}
ds->ixnew = lp;
check(ds, f1, f2, flags);
if (output(outfile, changes, ds, args, args->label[0], f1,
args->label[1], f2, flags))
- err = got_error_prefix_errno("output");
+ err = got_error_from_errno("output");
closem:
free(ds->J);
free(ds->member);
blob - 1fd38ce6fb96c6f9744cad5dbd47178a40e6b420
blob + c3af78d19c9dcfb46c349c76e439e211bbcbe37f
--- lib/error.c
+++ lib/error.c
}
const struct got_error *
-got_error_prefix_errno(const char *prefix)
+got_error_from_errno(const char *prefix)
{
static struct got_error err;
static char err_msg[MAXPATHLEN + 20];
}
const struct got_error *
-got_error_prefix_errno2(const char *prefix, const char *prefix2)
+got_error_from_errno2(const char *prefix, const char *prefix2)
{
static struct got_error err;
static char err_msg[(MAXPATHLEN * 2) + 20];
}
const struct got_error *
-got_error_prefix_errno3(const char *prefix, const char *prefix2,
+got_error_from_errno3(const char *prefix, const char *prefix2,
const char *prefix3)
{
static struct got_error err;
got_error_set_errno(int code, const char *prefix)
{
errno = code;
- return got_error_prefix_errno(prefix);
+ return got_error_from_errno(prefix);
}
const struct got_error *
got_ferror(FILE *f, int code)
{
if (ferror(f))
- return got_error_prefix_errno("");
+ return got_error_from_errno("");
return got_error(code);
}
blob - 61562ca737ba48acc9ec864ecdc25796636c48e3
blob + 8ff467458d80b3a0f400b0b4b668affadbc2a12a
--- lib/fileindex.c
+++ lib/fileindex.c
if (lstat(ondisk_path, &sb) != 0) {
if ((entry->flags & GOT_FILEIDX_F_NO_FILE_ON_DISK) == 0)
- return got_error_prefix_errno2("lstat", ondisk_path);
+ return got_error_from_errno2("lstat", ondisk_path);
} else {
if (sb.st_mode & S_IFDIR)
return got_error_set_errno(EISDIR, ondisk_path);
*entry = calloc(1, sizeof(**entry));
if (*entry == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*entry)->path = strdup(relpath);
if ((*entry)->path == NULL) {
- const struct got_error *err = got_error_prefix_errno("strdup");
+ const struct got_error *err = got_error_from_errno("strdup");
free(*entry);
*entry = NULL;
return err;
return got_ferror(outfile, GOT_ERR_IO);
if (fflush(outfile) != 0)
- return got_error_prefix_errno("fflush");
+ return got_error_from_errno("fflush");
return NULL;
}
*path = malloc(totlen);
if (*path == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
do {
n = fread(buf, 1, sizeof(buf), infile);
if (len + sizeof(buf) > totlen) {
char *p = reallocarray(*path, totlen + sizeof(buf), 1);
if (p == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
break;
}
totlen += sizeof(buf);
entry = calloc(1, sizeof(*entry));
if (entry == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
err = read_fileindex_val64(&entry->ctime_sec, ctx, infile);
if (err)
if (asprintf(&subpath, "%s%s%s", path,
path[0] == '\0' ? "" : "/", te->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = got_object_open_as_tree(&subtree, repo, te->id);
if (err) {
char *te_path;
int cmp;
if (asprintf(&te_path, "%s/%s", path, te->name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
break;
}
cmp = got_path_cmp((*ie)->path, te_path);
if (asprintf(&subpath, "%s%s%s", path,
path[0] == '\0' ? "" : "/", de->d_name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (asprintf(&subdirpath, "%s/%s", rootpath, subpath) == -1) {
free(subpath);
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
subdir = opendir(subdirpath);
if (subdir == NULL) {
free(subpath);
free(subdirpath);
- return got_error_prefix_errno2("opendir", subdirpath);
+ return got_error_from_errno2("opendir", subdirpath);
}
err = diff_fileindex_dir(fileindex, ie, subdir, rootpath,
de = malloc(sizeof(struct dirent) + NAME_MAX + 1);
if (de == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
if (readdir_r(dir, de, &dep) != 0) {
- err = got_error_prefix_errno("readdir_r");
+ err = got_error_from_errno("readdir_r");
free(de);
goto done;
}
de = dle->data;
if (asprintf(&de_path, "%s/%s", path,
de->d_name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
break;
}
cmp = got_path_cmp((*ie)->path, de_path);
blob - a23e868b2e9cfcfec8cd0909dd3a4d76eb28ab23
blob + cf569abc9136ea5fefdadf1a9a9fde8eaf66ab66
--- lib/inflate.c
+++ lib/inflate.c
zerr = inflateInit(&zb->z);
if (zerr != Z_OK) {
if (zerr == Z_ERRNO)
- return got_error_prefix_errno("inflateInit");
+ return got_error_from_errno("inflateInit");
if (zerr == Z_MEM_ERROR) {
errno = ENOMEM;
- return got_error_prefix_errno("inflateInit");
+ return got_error_from_errno("inflateInit");
}
return got_error(GOT_ERR_DECOMPRESSION);
}
zb->inbuf = calloc(1, zb->inlen);
if (zb->inbuf == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
if (outbuf == NULL) {
zb->outbuf = calloc(1, zb->outlen);
if (zb->outbuf == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
zb->flags |= GOT_INFLATE_F_OWN_OUTBUF;
if (z->avail_in == 0) {
ssize_t n = read(fd, zb->inbuf, zb->inlen);
if (n < 0)
- return got_error_prefix_errno("read");
+ return got_error_from_errno("read");
else if (n == 0) {
/* EOF */
ret = Z_STREAM_END;
*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
if (*outbuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
if (err)
return err;
newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
GOT_INFLATE_BUFSIZE);
if (newbuf == NULL) {
- err = got_error_prefix_errno("recallocarray");
+ err = got_error_from_errno("recallocarray");
free(*outbuf);
*outbuf = NULL;
*outlen = 0;
*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
if (*outbuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
if (err)
goto done;
newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
GOT_INFLATE_BUFSIZE);
if (newbuf == NULL) {
- err = got_error_prefix_errno("recallocarray");
+ err = got_error_from_errno("recallocarray");
free(*outbuf);
*outbuf = NULL;
*outlen = 0;
*outbuf = calloc(1, GOT_INFLATE_BUFSIZE);
if (*outbuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE);
if (err) {
free(*outbuf);
newbuf = recallocarray(*outbuf, nbuf - 1, nbuf,
GOT_INFLATE_BUFSIZE);
if (newbuf == NULL) {
- err = got_error_prefix_errno("recallocarray");
+ err = got_error_from_errno("recallocarray");
free(*outbuf);
*outbuf = NULL;
*outlen = 0;
ssize_t n;
n = write(outfd, zb.outbuf, avail);
if (n != avail) {
- err = got_error_prefix_errno("write");
+ err = got_error_from_errno("write");
goto done;
}
*outlen += avail;
done:
if (err == NULL) {
if (lseek(outfd, SEEK_SET, 0) == -1)
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
}
got_inflate_end(&zb);
return err;
blob - 9c2a16b3b0c849368cfbbf4060db8bf432199e77
blob + bc4cf864a87ae6ca01a4fa56e150cef5110d17aa
--- lib/lockfile.c
+++ lib/lockfile.c
*lf = calloc(1, sizeof(**lf));
if (*lf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*lf)->fd = -1;
(*lf)->locked_path = strdup(path);
if ((*lf)->locked_path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
if (asprintf(&(*lf)->path, "%s%s", path, GOT_LOCKFILE_SUFFIX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if ((*lf)->fd != -1)
break;
if (errno != EEXIST) {
- err = got_error_prefix_errno2("open", (*lf)->path);
+ err = got_error_from_errno2("open", (*lf)->path);
goto done;
}
sleep(1);
const struct got_error *err = NULL;
if (lf->path && lf->fd != -1 && unlink(lf->path) != 0)
- err = got_error_prefix_errno("unlink");
+ err = got_error_from_errno("unlink");
if (lf->fd != -1 && close(lf->fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
free(lf->path);
free(lf->locked_path);
free(lf);
blob - 0c9e8d05afb85118159e6aee19002ca969c23612
blob + d781faafd2c372bd139bef6f3b37d18ffca12f5b
--- lib/object.c
+++ lib/object.c
*path = NULL;
if (path_objects == NULL)
- return got_error_prefix_errno("got_repo_get_path_objects");
+ return got_error_from_errno("got_repo_get_path_objects");
err = got_object_id_str(&hex, id);
if (err)
if (asprintf(path, "%s/%.2x/%s", path_objects,
id->sha1[0], hex + 2) == -1)
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
done:
free(hex);
return err;
*fd = open(path, O_RDONLY | O_NOFOLLOW);
if (*fd == -1) {
- err = got_error_prefix_errno2("open", path);
+ err = got_error_from_errno2("open", path);
goto done;
}
done:
*path_packfile = malloc(size);
if (*path_packfile == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
/* Copy up to and excluding ".idx". */
if (strlcpy(*path_packfile, packidx->path_packidx,
(*obj)->path_packfile = strdup(pack->path_packfile);
if ((*obj)->path_packfile == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
return err;
}
memcpy(&(*obj)->id, id, sizeof((*obj)->id));
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
pack->privsep_child = calloc(1, sizeof(*pack->privsep_child));
if (pack->privsep_child == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
free(ibuf);
return err;
}
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
- err = got_error_prefix_errno("socketpair");
+ err = got_error_from_errno("socketpair");
goto done;
}
pid = fork();
if (pid == -1) {
- err = got_error_prefix_errno("fork");
+ err = got_error_from_errno("fork");
goto done;
} else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_PACK,
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
pack->privsep_child->imsg_fd = imsg_fds[0];
pack->privsep_child->pid = pid;
imsg_init(ibuf, imsg_fds[0]);
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_prefix_errno("socketpair");
+ return got_error_from_errno("socketpair");
pid = fork();
if (pid == -1)
- return got_error_prefix_errno("fork");
+ return got_error_from_errno("fork");
else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_OBJECT,
repo->path);
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd =
imsg_fds[0];
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].pid = pid;
if (errno == ENOENT)
err = got_error_no_obj(id);
else
- err = got_error_prefix_errno2("open", path);
+ err = got_error_from_errno2("open", path);
goto done;
} else {
err = read_object_header_privsep(obj, repo, fd);
*id = got_object_id_dup(got_object_get_id(obj));
got_object_close(obj);
if (*id == NULL)
- return got_error_prefix_errno("got_object_id_dup");
+ return got_error_from_errno("got_object_id_dup");
return NULL;
}
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_prefix_errno("socketpair");
+ return got_error_from_errno("socketpair");
pid = fork();
if (pid == -1)
- return got_error_prefix_errno("fork");
+ return got_error_from_errno("fork");
else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_COMMIT,
repo->path);
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd =
imsg_fds[0];
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].pid = pid;
*qid = calloc(1, sizeof(**qid));
if (*qid == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*qid)->id = got_object_id_dup(id);
if ((*qid)->id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
got_object_qid_free(*qid);
*qid = NULL;
return err;
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_prefix_errno("socketpair");
+ return got_error_from_errno("socketpair");
pid = fork();
if (pid == -1)
- return got_error_prefix_errno("fork");
+ return got_error_from_errno("fork");
else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_TREE,
repo->path);
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].imsg_fd =
imsg_fds[0];
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].pid = pid;
basefd = got_opentempfd();
if (basefd == -1)
- return got_error_prefix_errno("got_opentempfd");
+ return got_error_from_errno("got_opentempfd");
accumfd = got_opentempfd();
if (accumfd == -1)
- return got_error_prefix_errno("got_opentempfd");
+ return got_error_from_errno("got_opentempfd");
outfd_child = dup(outfd);
if (outfd_child == -1)
- return got_error_prefix_errno("dup");
+ return got_error_from_errno("dup");
err = got_privsep_send_blob_req(pack->privsep_child->ibuf, -1, id, idx);
if (err)
return err;
if (lseek(outfd, SEEK_SET, 0) == -1)
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
return err;
}
outfd_child = dup(outfd);
if (outfd_child == -1)
- return got_error_prefix_errno("dup");
+ return got_error_from_errno("dup");
err = got_privsep_send_blob_req(ibuf, infd, NULL, -1);
if (err)
return err;
if (lseek(outfd, SEEK_SET, 0) == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
return err;
}
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_prefix_errno("socketpair");
+ return got_error_from_errno("socketpair");
pid = fork();
if (pid == -1)
- return got_error_prefix_errno("fork");
+ return got_error_from_errno("fork");
else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_BLOB,
repo->path);
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].imsg_fd =
imsg_fds[0];
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].pid = pid;
*blob = calloc(1, sizeof(**blob));
if (*blob == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
outfd = got_opentempfd();
if (outfd == -1)
- return got_error_prefix_errno("got_opentempfd");
+ return got_error_from_errno("got_opentempfd");
(*blob)->read_buf = malloc(blocksize);
if ((*blob)->read_buf == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
if (outbuf) {
if (close(outfd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
outfd = -1;
(*blob)->f = fmemopen(outbuf, size, "rb");
if ((*blob)->f == NULL) {
- err = got_error_prefix_errno("fmemopen");
+ err = got_error_from_errno("fmemopen");
free(outbuf);
goto done;
}
(*blob)->data = outbuf;
} else {
if (fstat(outfd, &sb) == -1) {
- err = got_error_prefix_errno("fstat");
+ err = got_error_from_errno("fstat");
goto done;
}
(*blob)->f = fdopen(outfd, "rb");
if ((*blob)->f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
close(outfd);
outfd = -1;
goto done;
const struct got_error *err = NULL;
free(blob->read_buf);
if (blob->f && fclose(blob->f) != 0)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
free(blob->data);
free(blob);
return err;
} while (len != 0);
if (fflush(outfile) != 0)
- return got_error_prefix_errno("fflush");
+ return got_error_from_errno("fflush");
rewind(outfile);
return NULL;
ibuf = calloc(1, sizeof(*ibuf));
if (ibuf == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_prefix_errno("socketpair");
+ return got_error_from_errno("socketpair");
pid = fork();
if (pid == -1)
- return got_error_prefix_errno("fork");
+ return got_error_from_errno("fork");
else if (pid == 0) {
exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_TAG,
repo->path);
}
if (close(imsg_fds[1]) != 0)
- return got_error_prefix_errno("close");
+ return got_error_from_errno("close");
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].imsg_fd =
imsg_fds[0];
repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].pid = pid;
if (path[1] == '\0') {
*id = got_object_id_dup(commit->tree_id);
if (*id == NULL)
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
if (te) {
*id = got_object_id_dup(te->id);
if (*id == NULL)
- return got_error_prefix_errno("got_object_id_dup");
+ return got_error_from_errno("got_object_id_dup");
} else
err = got_error(GOT_ERR_NO_TREE_ENTRY);
done:
*new_te = calloc(1, sizeof(**new_te));
if (*new_te == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*new_te)->mode = te->mode;
(*new_te)->name = strdup(te->name);
if ((*new_te)->name == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
(*new_te)->id = got_object_id_dup(te->id);
if ((*new_te)->id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
done:
blob - 17731e448a0b3bfaf078194ce96ece804815b588
blob + d2e350b5272e2d79eb6f86e0568a4fcbcc2d3f5b
--- lib/object_cache.c
+++ lib/object_cache.c
cache->idset = got_object_idset_alloc();
if (cache->idset == NULL)
- return got_error_prefix_errno("got_object_idset_alloc");
+ return got_error_from_errno("got_object_idset_alloc");
cache->type = type;
switch (type) {
ce = malloc(sizeof(*ce));
if (ce == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
memcpy(&ce->id, id, sizeof(ce->id));
switch (cache->type) {
case GOT_OBJECT_CACHE_TYPE_OBJ:
blob - 0a94c6561d897225828b8b9de80c968839fb55ae
blob + 5560dd333aedc9926925e144ccd43130927d1a07
--- lib/object_create.c
+++ lib/object_create.c
goto done;
if (rename(tmppath, objpath) != 0) {
- err = got_error_prefix_errno3("rename", tmppath, objpath);
+ err = got_error_from_errno3("rename", tmppath, objpath);
goto done;
}
free(tmppath);
tmppath = NULL;
if (chmod(objpath, GOT_DEFAULT_FILE_MODE) != 0) {
- err = got_error_prefix_errno2("chmod", objpath);
+ err = got_error_from_errno2("chmod", objpath);
goto done;
}
done:
free(objpath);
if (tmppath) {
if (unlink(tmppath) != 0 && err == NULL)
- err = got_error_prefix_errno2("unlink", tmppath);
+ err = got_error_from_errno2("unlink", tmppath);
free(tmppath);
}
if (tmpfile && fclose(tmpfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (lf)
unlock_err = got_lockfile_unlock(lf);
return err ? err : unlock_err;
fd = open(ondisk_path, O_RDONLY | O_NOFOLLOW);
if (fd == -1)
- return got_error_prefix_errno2("open", ondisk_path);
+ return got_error_from_errno2("open", ondisk_path);
if (fstat(fd, &sb) == -1) {
- err = got_error_prefix_errno2("fstat", ondisk_path);
+ err = got_error_from_errno2("fstat", ondisk_path);
goto done;
}
if (asprintf(&header, "%s %lld", GOT_OBJ_LABEL_BLOB,
sb.st_size) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
headerlen = strlen(header) + 1;
blobfile = got_opentemp();
if (blobfile == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
inlen = read(fd, buf, sizeof(buf));
if (inlen == -1) {
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
goto done;
}
if (inlen == 0)
*id = malloc(sizeof(**id));
if (*id == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
SHA1Final((*id)->sha1, &sha1_ctx);
if (fflush(blobfile) != 0) {
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
goto done;
}
rewind(blobfile);
done:
free(header);
if (fd != -1 && close(fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
if (blobfile && fclose(blobfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (err) {
free(*id);
*id = NULL;
}
if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_TREE, len) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
headerlen = strlen(header) + 1;
treefile = got_opentemp();
if (treefile == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
*id = malloc(sizeof(**id));
if (*id == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
SHA1Final((*id)->sha1, &sha1_ctx);
if (fflush(treefile) != 0) {
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
goto done;
}
rewind(treefile);
done:
free(header);
if (treefile && fclose(treefile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (err) {
free(*id);
*id = NULL;
if (asprintf(&author_str, "%s%s %lld +0000\n",
GOT_COMMIT_LABEL_AUTHOR, author, author_time) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (asprintf(&committer_str, "%s%s %lld +0000\n",
GOT_COMMIT_LABEL_COMMITTER, committer ? committer : author,
committer ? committer_time : author_time)
== -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
+ strlen(author_str) + strlen(committer_str) + 2 + strlen(logmsg);
if (asprintf(&header, "%s %zd", GOT_OBJ_LABEL_COMMIT, len) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
headerlen = strlen(header) + 1;
commitfile = got_opentemp();
if (commitfile == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
goto done;
if (asprintf(&tree_str, "%s%s\n", GOT_COMMIT_LABEL_TREE, id_str)
== -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
len = strlen(tree_str);
goto done;
if (asprintf(&parent_str, "%s%s\n", GOT_COMMIT_LABEL_PARENT,
id_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
len = strlen(parent_str);
*id = malloc(sizeof(**id));
if (*id == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
SHA1Final((*id)->sha1, &sha1_ctx);
if (fflush(commitfile) != 0) {
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
goto done;
}
rewind(commitfile);
free(author_str);
free(committer_str);
if (commitfile && fclose(commitfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (err) {
free(*id);
*id = NULL;
blob - 70eab62f6e930e3ef292944cbc8c3dc8cb09f48f
blob + 527383c259fb8d8e90ecf8f6b8efd21fd94a4327
--- lib/object_idset.c
+++ lib/object_idset.c
new = malloc(sizeof(*new));
if (new == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
memcpy(&new->id, id, sizeof(new->id));
new->data = data;
blob - 33ea7acf54a5d270b0227cb62feb35f838a4f8be
blob + 9559b3499f03914992d9378fd06de60541916cdd
--- lib/object_parse.c
+++ lib/object_parse.c
*qid = malloc(sizeof(**qid));
if (*qid == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
(*qid)->id = malloc(sizeof(*((*qid)->id)));
if ((*qid)->id == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
got_object_qid_free(*qid);
*qid = NULL;
return err;
*outbuf = malloc(len);
if (*outbuf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
free(*outbuf);
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*obj)->type = type;
(*obj)->hdrlen = hdrlen;
(*obj)->size = size;
buf = malloc(zbsize);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
err = got_inflate_init(&zb, buf, zbsize);
if (err)
nbuf++;
newbuf = recallocarray(buf, nbuf - 1, nbuf, zbsize);
if (newbuf == NULL) {
- err = got_error_prefix_errno("recallocarray");
+ err = got_error_from_errno("recallocarray");
goto done;
}
buf = newbuf;
return got_error(GOT_ERR_BAD_OBJ_DATA);
tzstr = strdup(space + 1);
if (tzstr == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
err = parse_gmtoff(gmtoff, tzstr);
free(tzstr);
if (err)
*commit = got_object_commit_alloc_partial();
if (*commit == NULL)
- return got_error_prefix_errno("got_object_commit_alloc_partial");
+ return got_error_from_errno("got_object_commit_alloc_partial");
label_len = strlen(GOT_COMMIT_LABEL_TREE);
if (strncmp(s, GOT_COMMIT_LABEL_TREE, label_len) == 0) {
goto done;
(*commit)->author = strdup(s);
if ((*commit)->author == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
s += slen + 1;
goto done;
(*commit)->committer = strdup(s);
if ((*commit)->committer == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
s += slen + 1;
(*commit)->logmsg = strndup(s, remain);
if ((*commit)->logmsg == NULL) {
- err = got_error_prefix_errno("strndup");
+ err = got_error_from_errno("strndup");
goto done;
}
done:
*te = got_alloc_tree_entry_partial();
if (*te == NULL)
- return got_error_prefix_errno("got_alloc_tree_entry_partial");
+ return got_error_from_errno("got_alloc_tree_entry_partial");
*elen = strnlen(buf, maxlen) + 1;
if (*elen > maxlen) {
*tree = calloc(1, sizeof(**tree));
if (*tree == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
SIMPLEQ_INIT(&(*tree)->entries.head);
*tag = calloc(1, sizeof(**tag));
if (*tag == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
label_len = strlen(GOT_TAG_LABEL_OBJECT);
if (strncmp(s, GOT_TAG_LABEL_OBJECT, label_len) == 0) {
slen = strlen(s);
(*tag)->tag = strndup(s, slen);
if ((*tag)->tag == NULL) {
- err = got_error_prefix_errno("strndup");
+ err = got_error_from_errno("strndup");
goto done;
}
s += slen + 1;
goto done;
(*tag)->tagger = strdup(s);
if ((*tag)->tagger == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
s += slen + 1;
/* Some old tags in the Linux git repo have no tagger. */
(*tag)->tagger = strdup("");
if ((*tag)->tagger == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
}
(*tag)->tagmsg = strndup(s, remain);
if ((*tag)->tagmsg == NULL) {
- err = got_error_prefix_errno("strndup");
+ err = got_error_from_errno("strndup");
goto done;
}
done:
buf = malloc(blocksize);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
remain = blocksize;
total = 0;
uint8_t *newbuf;
newbuf = reallocarray(buf, 1, total + blocksize);
if (newbuf == NULL) {
- err = got_error_prefix_errno("reallocarray");
+ err = got_error_from_errno("reallocarray");
goto done;
}
buf = newbuf;
blob - a57145d2b038aab6670b164672f242bdd3fc598e
blob + 212a9365a8970d664fb888047b028d3bb46a7391
--- lib/opentemp.c
+++ lib/opentemp.c
if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
*path = NULL;
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
fd = mkstemp(*path);
if (fd == -1) {
- err = got_error_prefix_errno("mkstemp");
+ err = got_error_from_errno("mkstemp");
free(*path);
*path = NULL;
return err;
*outfile = fdopen(fd, "w+");
if (*outfile == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
free(*path);
*path = NULL;
}
if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
*path = NULL;
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
fd = mkstemp(*path);
if (fd == -1) {
- err = got_error_prefix_errno("mkstemp");
+ err = got_error_from_errno("mkstemp");
free(*path);
*path = NULL;
return err;
blob - 8e7bca71c1527510b415e58c7e90e5c655811ca6
blob + 9bf9884ba4fea911efb366206d1c811d1b35829e
--- lib/pack.c
+++ lib/pack.c
return got_error(GOT_ERR_BAD_PATH);
*dot = '\0';
if (asprintf(&path_pack, "%s.pack", base_path) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (stat(path_pack, &sb) != 0)
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(path_pack);
if (err)
return err;
} else if (strcmp(dot, GOT_PACKFILE_SUFFIX) == 0) {
if (stat(path, &sb) != 0)
- return got_error_prefix_errno2("stat", path);
+ return got_error_from_errno2("stat", path);
} else
return got_error(GOT_ERR_BAD_PATH);
else {
h->magic = malloc(sizeof(*h->magic));
if (h->magic == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->magic, sizeof(*h->magic));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != sizeof(*h->magic)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->version = malloc(sizeof(*h->version));
if (h->version == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->version, sizeof(*h->version));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != sizeof(*h->version)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->fanout_table = malloc(len_fanout);
if (h->fanout_table == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->fanout_table, len_fanout);
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != len_fanout) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
}
n = read(p->fd, h->sorted_ids, len_ids);
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != len_ids) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->crc32 = malloc(nobj * sizeof(*h->crc32));
if (h->crc32 == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->crc32, nobj * sizeof(*h->crc32));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != nobj * sizeof(*h->crc32)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->offsets = malloc(nobj * sizeof(*h->offsets));
if (h->offsets == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->offsets, nobj * sizeof(*h->offsets));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != nobj * sizeof(*h->offsets)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->offsets = malloc(nobj * sizeof(*h->large_offsets));
if (h->offsets == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->large_offsets,
nobj * sizeof(*h->large_offsets));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != nobj * sizeof(*h->large_offsets)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
else {
h->trailer = malloc(sizeof(*h->trailer));
if (h->trailer == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
goto done;
}
n = read(p->fd, h->trailer, sizeof(*h->trailer));
if (n < 0)
- err = got_error_prefix_errno("read");
+ err = got_error_from_errno("read");
else if (n != sizeof(*h->trailer)) {
err = got_error(GOT_ERR_BAD_PACKIDX);
goto done;
p = calloc(1, sizeof(*p));
if (p == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
p->fd = open(path, O_RDONLY | O_NOFOLLOW);
if (p->fd == -1)
- return got_error_prefix_errno2("open", path);
+ return got_error_from_errno2("open", path);
err = got_pack_get_packfile_size(&p->len, path);
if (err) {
p->path_packidx = strdup(path);
if (p->path_packidx == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
p->map = mmap(NULL, p->len, PROT_READ, MAP_PRIVATE, p->fd, 0);
if (p->map == MAP_FAILED) {
if (errno != ENOMEM) {
- err = got_error_prefix_errno("mmap");
+ err = got_error_from_errno("mmap");
goto done;
}
p->map = NULL; /* fall back to read(2) */
free(packidx->path_packidx);
if (packidx->map) {
if (munmap(packidx->map, packidx->len) == -1)
- err = got_error_prefix_errno("munmap");
+ err = got_error_from_errno("munmap");
} else {
free(packidx->hdr.magic);
free(packidx->hdr.version);
free(packidx->hdr.trailer);
}
if (close(packidx->fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
free(packidx);
return err;
return err;
err = got_privsep_wait_for_child(pack->privsep_child->pid);
if (close(pack->privsep_child->imsg_fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
free(pack->privsep_child);
pack->privsep_child = NULL;
return err;
err = got_pack_stop_privsep_child(pack);
if (pack->map && munmap(pack->map, pack->filesize) == -1 && !err)
- err = got_error_prefix_errno("munmap");
+ err = got_error_from_errno("munmap");
if (pack->fd != -1 && close(pack->fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
pack->fd = -1;
free(pack->path_packfile);
pack->path_packfile = NULL;
mapoff = (size_t)offset;
} else {
if (lseek(pack->fd, offset, SEEK_SET) == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
}
do {
} else {
ssize_t n = read(pack->fd, &sizeN, sizeof(sizeN));
if (n < 0)
- return got_error_prefix_errno("read");
+ return got_error_from_errno("read");
if (n != sizeof(sizeN))
return got_error(GOT_ERR_BAD_PACKFILE);
}
{
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*obj)->path_packfile = strdup(path_packfile);
if ((*obj)->path_packfile == NULL) {
- const struct got_error *err = got_error_prefix_errno("strdup");
+ const struct got_error *err = got_error_from_errno("strdup");
free(*obj);
*obj = NULL;
return err;
ssize_t n;
n = read(pack->fd, &offN, sizeof(offN));
if (n < 0)
- return got_error_prefix_errno("read");
+ return got_error_from_errno("read");
if (n != sizeof(offN))
return got_error(GOT_ERR_BAD_PACKFILE);
}
delta_data_offset, delta_buf,
delta_len);
if (delta == NULL)
- return got_error_prefix_errno("got_delta_open");
+ return got_error_from_errno("got_delta_open");
/* delta is freed in got_object_close() */
deltas->nentries++;
SIMPLEQ_INSERT_HEAD(&deltas->entries, delta, entry);
if (pack->map == NULL) {
delta_data_offset = lseek(pack->fd, 0, SEEK_CUR);
if (delta_data_offset == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
}
if (pack->map) {
if (pack->map == NULL) {
delta_data_offset = lseek(pack->fd, 0, SEEK_CUR);
if (delta_data_offset == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
}
if (pack->map) {
} else {
ssize_t n = read(pack->fd, &id, sizeof(id));
if (n < 0)
- return got_error_prefix_errno("read");
+ return got_error_from_errno("read");
if (n != sizeof(id))
return got_error(GOT_ERR_BAD_PACKFILE);
err = got_inflate_to_mem_fd(&delta_buf, &delta_len, pack->fd);
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*obj)->flags = 0;
(*obj)->hdrlen = 0;
(*obj)->path_packfile = strdup(pack->path_packfile);
if ((*obj)->path_packfile == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
(*obj)->flags |= GOT_OBJ_FLAG_PACKED;
if (max_size < GOT_DELTA_RESULT_SIZE_CACHED_MAX) {
accum_buf = malloc(max_size);
if (accum_buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
base_file = NULL;
accum_file = NULL;
}
if (pack->map == NULL) {
if (lseek(pack->fd, delta_data_offset, SEEK_SET)
== -1) {
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
goto done;
}
}
uint8_t *p;
p = reallocarray(base_buf, 1, max_size);
if (p == NULL) {
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"reallocarray");
goto done;
}
return err;
accum_buf = malloc(max_size);
if (accum_buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
/* Deltas are ordered in ascending order. */
SIMPLEQ_FOREACH(delta, &deltas->entries, entry) {
} else {
if (lseek(pack->fd, delta_data_offset, SEEK_SET)
== -1) {
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
goto done;
}
err = got_inflate_to_mem_fd(&base_buf,
uint8_t *p;
p = reallocarray(base_buf, 1, max_size);
if (p == NULL) {
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"reallocarray");
goto done;
}
mapoff, pack->filesize - mapoff, outfile);
} else {
if (lseek(pack->fd, obj->pack_offset, SEEK_SET) == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
err = got_inflate_to_file_fd(&obj->size, pack->fd,
outfile);
}
mapoff, pack->filesize - mapoff);
} else {
if (lseek(pack->fd, obj->pack_offset, SEEK_SET) == -1)
- return got_error_prefix_errno("lseek");
+ return got_error_from_errno("lseek");
err = got_inflate_to_mem_fd(buf, len, pack->fd);
}
} else
blob - 33840a4b76f90e86e70a5a781d76d2396a2c448b
blob + 90f647ae849b1cdf8f1170cbf329f13755004def
--- lib/path.c
+++ lib/path.c
bufsize = len - len_parent + 1;
*child = malloc(bufsize);
if (*child == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
if (strlcpy(*child, abspath + len_parent, bufsize) >= bufsize) {
- err = got_error_prefix_errno("strlcpy");
+ err = got_error_from_errno("strlcpy");
free(*child);
*child = NULL;
return err;
new = malloc(sizeof(*new));
if (new == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
new->path = path;
new->data = data;
if (err)
goto done;
if (mkdir(parent, GOT_DEFAULT_DIR_MODE) == -1) {
- err = got_error_prefix_errno2("mkdir", parent);
+ err = got_error_from_errno2("mkdir", parent);
goto done;
}
} else
- err = got_error_prefix_errno2("mkdir", parent);
+ err = got_error_from_errno2("mkdir", parent);
}
done:
free(parent);
if (err)
goto done;
if (mkdir(abspath, GOT_DEFAULT_DIR_MODE) == -1)
- err = got_error_prefix_errno2("mkdir", abspath);
+ err = got_error_from_errno2("mkdir", abspath);
} else
- err = got_error_prefix_errno2("mkdir", abspath);
+ err = got_error_from_errno2("mkdir", abspath);
}
done:
p = dirname(path);
if (p == NULL)
- return got_error_prefix_errno2("dirname", path);
+ return got_error_from_errno2("dirname", path);
if (p[0] == '.' && p[1] == '\0')
return got_error(GOT_ERR_BAD_PATH);
*parent = strdup(p);
if (*parent == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
return NULL;
}
blob - 1601edde20cb79ee3d12560e1c0a35b354af7d2c
blob + df3fdff63112138a8d1e5e73ee27f1a8d8d412ac
--- lib/privsep.c
+++ lib/privsep.c
n = poll(pfd, 1, timeout);
if (n == -1)
- return got_error_prefix_errno("poll");
+ return got_error_from_errno("poll");
if (n == 0)
return got_error(GOT_ERR_TIMEOUT);
if (pfd[0].revents & (POLLERR | POLLNVAL))
- return got_error_prefix_errno("poll error");
+ return got_error_from_errno("poll error");
if (pfd[0].revents & (events | POLLHUP))
return NULL;
int child_status;
if (waitpid(pid, &child_status, 0) == -1)
- return got_error_prefix_errno("waitpid");
+ return got_error_from_errno("waitpid");
if (!WIFEXITED(child_status))
return got_error(GOT_ERR_PRIVSEP_DIED);
n = imsg_get(ibuf, imsg);
if (n == -1)
- return got_error_prefix_errno("imsg_get");
+ return got_error_from_errno("imsg_get");
while (n == 0) {
err = read_imsg(ibuf);
return err;
if (imsg_flush(ibuf) == -1)
- return got_error_prefix_errno("imsg_flush");
+ return got_error_from_errno("imsg_flush");
return NULL;
}
imsg_init(&ibuf, fd);
if (imsg_compose(&ibuf, GOT_IMSG_STOP, 0, 0, -1, NULL, 0) == -1)
- return got_error_prefix_errno("imsg_compose STOP");
+ return got_error_from_errno("imsg_compose STOP");
err = flush_imsg(&ibuf);
imsg_clear(&ibuf);
{
if (imsg_compose(ibuf, GOT_IMSG_OBJECT_REQUEST, 0, 0, fd, NULL, 0)
== -1)
- return got_error_prefix_errno("imsg_compose OBJECT_REQUEST");
+ return got_error_from_errno("imsg_compose OBJECT_REQUEST");
return flush_imsg(ibuf);
}
if (imsg_compose(ibuf, GOT_IMSG_COMMIT_REQUEST, 0, 0, fd, iobjp, len)
== -1) {
- err = got_error_prefix_errno("imsg_compose COMMIT_REQUEST");
+ err = got_error_from_errno("imsg_compose COMMIT_REQUEST");
close(fd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_TREE_REQUEST, 0, 0, fd, iobjp, len)
== -1) {
- err = got_error_prefix_errno("imsg_compose TREE_REQUEST");
+ err = got_error_from_errno("imsg_compose TREE_REQUEST");
close(fd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_TAG_REQUEST, 0, 0, fd, iobjp, len)
== -1)
- return got_error_prefix_errno("imsg_compose TAG_REQUEST");
+ return got_error_from_errno("imsg_compose TAG_REQUEST");
return flush_imsg(ibuf);
}
if (imsg_compose(ibuf, GOT_IMSG_BLOB_REQUEST, 0, 0, infd, iobjp, len)
== -1) {
- err = got_error_prefix_errno("imsg_compose BLOB_REQUEST");
+ err = got_error_from_errno("imsg_compose BLOB_REQUEST");
close(infd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_BLOB_OUTFD, 0, 0, outfd, NULL, 0)
== -1) {
- err = got_error_prefix_errno("imsg_compose BLOB_OUTFD");
+ err = got_error_from_errno("imsg_compose BLOB_OUTFD");
close(outfd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_TMPFD, 0, 0, fd, NULL, 0)
== -1) {
- err = got_error_prefix_errno("imsg_compose TMPFD");
+ err = got_error_from_errno("imsg_compose TMPFD");
close(fd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_OBJECT, 0, 0, -1, &iobj, sizeof(iobj))
== -1)
- return got_error_prefix_errno("imsg_compose OBJECT");
+ return got_error_from_errno("imsg_compose OBJECT");
return flush_imsg(ibuf);
}
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
memcpy((*obj)->id.sha1, iobj->id, SHA1_DIGEST_LENGTH);
(*obj)->type = iobj->type;
if (imsg_compose(ibuf, GOT_IMSG_COMMIT_LOGMSG, 0, 0, -1,
commit->logmsg + offset, n) == -1) {
- err = got_error_prefix_errno("imsg_compose "
+ err = got_error_from_errno("imsg_compose "
"COMMIT_LOGMSG");
break;
}
buf = malloc(total);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
icommit = (struct got_imsg_commit_object *)buf;
memcpy(icommit->tree_id, commit->tree_id->sha1,
}
if (imsg_compose(ibuf, GOT_IMSG_COMMIT, 0, 0, -1, buf, len) == -1) {
- err = got_error_prefix_errno("imsg_compose COMMIT");
+ err = got_error_from_errno("imsg_compose COMMIT");
goto done;
}
*commit = got_object_commit_alloc_partial();
if (*commit == NULL) {
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"got_object_commit_alloc_partial");
break;
}
if (icommit->author_len == 0) {
(*commit)->author = strdup("");
if ((*commit)->author == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*commit)->author = malloc(icommit->author_len + 1);
if ((*commit)->author == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy((*commit)->author, imsg.data + len,
if (icommit->committer_len == 0) {
(*commit)->committer = strdup("");
if ((*commit)->committer == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*commit)->committer =
malloc(icommit->committer_len + 1);
if ((*commit)->committer == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy((*commit)->committer, imsg.data + len,
if (icommit->logmsg_len == 0) {
(*commit)->logmsg = strdup("");
if ((*commit)->logmsg == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*commit)->logmsg = malloc(icommit->logmsg_len + 1);
if ((*commit)->logmsg == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
while (remain > 0) {
itree.nentries = tree->entries.nentries;
if (imsg_compose(ibuf, GOT_IMSG_TREE, 0, 0, -1, &itree, sizeof(itree))
== -1)
- return got_error_prefix_errno("imsg_compose TREE");
+ return got_error_from_errno("imsg_compose TREE");
totlen = sizeof(itree);
nimsg = 1;
buf = malloc(len);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
ite = (struct got_imsg_tree_entry *)buf;
memcpy(ite->id, te->id->sha1, sizeof(ite->id));
if (imsg_compose(ibuf, GOT_IMSG_TREE_ENTRY, 0, 0, -1,
buf, len) == -1)
- err = got_error_prefix_errno("imsg_compose TREE_ENTRY");
+ err = got_error_from_errno("imsg_compose TREE_ENTRY");
free(buf);
if (err)
return err;
itree = imsg.data;
*tree = malloc(sizeof(**tree));
if (*tree == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
(*tree)->entries.nentries = itree->nentries;
te = got_alloc_tree_entry_partial();
if (te == NULL) {
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"got_alloc_tree_entry_partial");
break;
}
te->name = malloc(datalen + 1);
if (te->name == NULL) {
free(te);
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy(te->name, imsg.data + sizeof(*ite), datalen);
buf = malloc(sizeof(iblob) + size);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
memcpy(buf, &iblob, sizeof(iblob));
memcpy(buf + sizeof(iblob), data, size);
if (imsg_compose(ibuf, GOT_IMSG_BLOB, 0, 0, -1, buf,
sizeof(iblob) + size) == -1) {
free(buf);
- return got_error_prefix_errno("imsg_compose BLOB");
+ return got_error_from_errno("imsg_compose BLOB");
}
free(buf);
} else {
/* Data has already been written to file descriptor. */
if (imsg_compose(ibuf, GOT_IMSG_BLOB, 0, 0, -1, &iblob,
sizeof(iblob)) == -1)
- return got_error_prefix_errno("imsg_compose BLOB");
+ return got_error_from_errno("imsg_compose BLOB");
}
*outbuf = malloc(*size);
if (*outbuf == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy(*outbuf, imsg.data + sizeof(*iblob), *size);
if (imsg_compose(ibuf, GOT_IMSG_TAG_TAGMSG, 0, 0, -1,
tag->tagmsg + offset, n) == -1) {
- err = got_error_prefix_errno("imsg_compose TAG_TAGMSG");
+ err = got_error_from_errno("imsg_compose TAG_TAGMSG");
break;
}
buf = malloc(total);
if (buf == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
itag = (struct got_imsg_tag_object *)buf;
memcpy(itag->id, tag->id.sha1, sizeof(itag->id));
len += tagger_len;
if (imsg_compose(ibuf, GOT_IMSG_TAG, 0, 0, -1, buf, len) == -1) {
- err = got_error_prefix_errno("imsg_compose TAG");
+ err = got_error_from_errno("imsg_compose TAG");
goto done;
}
*tag = calloc(1, sizeof(**tag));
if (*tag == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
break;
}
if (itag->tag_len == 0) {
(*tag)->tag = strdup("");
if ((*tag)->tag == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*tag)->tag = malloc(itag->tag_len + 1);
if ((*tag)->tag == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy((*tag)->tag, imsg.data + len,
if (itag->tagger_len == 0) {
(*tag)->tagger = strdup("");
if ((*tag)->tagger == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*tag)->tagger = malloc(itag->tagger_len + 1);
if ((*tag)->tagger == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
memcpy((*tag)->tagger, imsg.data + len,
if (itag->tagmsg_len == 0) {
(*tag)->tagmsg = strdup("");
if ((*tag)->tagmsg == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
break;
}
} else {
(*tag)->tagmsg = malloc(itag->tagmsg_len + 1);
if ((*tag)->tagmsg == NULL) {
- err = got_error_prefix_errno("malloc");
+ err = got_error_from_errno("malloc");
break;
}
while (remain > 0) {
ipackidx.len = packidx->len;
fd = dup(packidx->fd);
if (fd == -1)
- return got_error_prefix_errno("dup");
+ return got_error_from_errno("dup");
if (imsg_compose(ibuf, GOT_IMSG_PACKIDX, 0, 0, fd, &ipackidx,
sizeof(ipackidx)) == -1) {
- err = got_error_prefix_errno("imsg_compose PACKIDX");
+ err = got_error_from_errno("imsg_compose PACKIDX");
close(fd);
return err;
}
fd = dup(pack->fd);
if (fd == -1)
- return got_error_prefix_errno("dup");
+ return got_error_from_errno("dup");
if (imsg_compose(ibuf, GOT_IMSG_PACK, 0, 0, fd, &ipack, sizeof(ipack))
== -1) {
- err = got_error_prefix_errno("imsg_compose PACK");
+ err = got_error_from_errno("imsg_compose PACK");
close(fd);
return err;
}
if (imsg_compose(ibuf, GOT_IMSG_PACKED_OBJECT_REQUEST, 0, 0, -1,
&iobj, sizeof(iobj)) == -1)
- return got_error_prefix_errno("imsg_compose "
+ return got_error_from_errno("imsg_compose "
"PACKED_OBJECT_REQUEST");
return flush_imsg(ibuf);
unveil(GOT_PATH_PROG_READ_TREE, "x") != 0 ||
unveil(GOT_PATH_PROG_READ_BLOB, "x") != 0 ||
unveil(GOT_PATH_PROG_READ_TAG, "x") != 0)
- return got_error_prefix_errno("unveil");
+ return got_error_from_errno("unveil");
return NULL;
}
blob - ff09bbce69de69bf78d62bc157725924fc2ff292
blob + c2d7153928e0760cd9d259ef3aa6621137d0d05f
--- lib/reference.c
+++ lib/reference.c
*ref = calloc(1, sizeof(**ref));
if (*ref == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
memcpy((*ref)->ref.ref.sha1, id->sha1, sizeof((*ref)->ref.ref.sha1));
(*ref)->flags = flags;
(*ref)->ref.ref.name = strdup(name);
if ((*ref)->ref.ref.name == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
got_ref_close(*ref);
*ref = NULL;
}
*ref = calloc(1, sizeof(**ref));
if (*ref == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*ref)->flags = GOT_REF_IS_SYMBOLIC | flags;
(*ref)->ref.symref.name = strdup(name);
if ((*ref)->ref.symref.name == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
got_ref_close(*ref);
*ref = NULL;
}
(*ref)->ref.symref.ref = strdup(target_ref);
if ((*ref)->ref.symref.ref == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
got_ref_close(*ref);
*ref = NULL;
}
done:
free(line);
if (fclose(f) != 0 && err == NULL) {
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (*ref) {
if (lock)
got_ref_unlock(*ref);
if (!ref_is_absolute &&
asprintf(&abs_refname, "refs/%s/%s", subdirs[i],
refname) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = parse_packed_ref_line(ref, abs_refname, line);
if (!ref_is_absolute)
free(abs_refname);
if (ref_is_absolute || ref_is_well_known) {
if (asprintf(&path, "%s/%s", path_refs, name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
absname = (char *)name;
} else {
if (asprintf(&path, "%s/%s%s%s", path_refs, subdir,
subdir[0] ? "/" : "", name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (asprintf(&absname, "refs/%s%s%s",
subdir, subdir[0] ? "/" : "", name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
}
normpath = got_path_normalize(path);
if (normpath == NULL) {
- err = got_error_prefix_errno2("got_path_normalize", path);
+ err = got_error_from_errno2("got_path_normalize", path);
goto done;
}
path_refs = get_refs_dir_path(repo, refname);
if (path_refs == NULL) {
- err = got_error_prefix_errno2("get_refs_dir_path", refname);
+ err = got_error_from_errno2("get_refs_dir_path", refname);
goto done;
}
packed_refs_path = got_repo_get_path_packed_refs(repo);
if (packed_refs_path == NULL) {
- err = got_error_prefix_errno(
+ err = got_error_from_errno(
"got_repo_get_path_packed_refs");
goto done;
}
refname);
if (!err) {
if (fclose(f) != 0) {
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
got_ref_close(*ref);
*ref = NULL;
} else
*id = calloc(1, sizeof(**id));
if (*id == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
memcpy((*id)->sha1, ref->ref.ref.sha1, sizeof((*id)->sha1));
return NULL;
}
new = malloc(sizeof(*new));
if (new == NULL) {
free(id);
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
}
new->ref = ref;
new->id = id;
char *path_subdir;
if (asprintf(&path_subdir, "%s/%s", path_refs, subdir) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
d = opendir(path_subdir);
if (d == NULL)
case DT_DIR:
if (asprintf(&child, "%s%s%s", subdir,
subdir[0] == '\0' ? "" : "/", dent->d_name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
break;
}
err = gather_on_disk_refs(refs, path_refs, child, repo);
/* HEAD ref should always exist. */
path_refs = get_refs_dir_path(repo, GOT_REF_HEAD);
if (path_refs == NULL) {
- err = got_error_prefix_errno("get_refs_dir_path");
+ err = got_error_from_errno("get_refs_dir_path");
goto done;
}
err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0);
free(path_refs);
path_refs = get_refs_dir_path(repo, "");
if (path_refs == NULL) {
- err = got_error_prefix_errno("get_refs_dir_path");
+ err = got_error_from_errno("get_refs_dir_path");
goto done;
}
err = gather_on_disk_refs(refs, path_refs, "", repo);
*/
packed_refs_path = got_repo_get_path_packed_refs(repo);
if (packed_refs_path == NULL) {
- err = got_error_prefix_errno("got_repo_get_path_packed_refs");
+ err = got_error_from_errno("got_repo_get_path_packed_refs");
goto done;
}
done:
free(path_refs);
if (f && fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
new_name = strdup(refname);
if (new_name == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
free(ref->ref.symref.name);
ref->ref.symref.name = new_name;
path_refs = get_refs_dir_path(repo, name);
if (path_refs == NULL) {
- err = got_error_prefix_errno2("get_refs_dir_path", name);
+ err = got_error_from_errno2("get_refs_dir_path", name);
goto done;
}
if (asprintf(&path, "%s/%s", path_refs, name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (stat(path, &sb) != 0) {
if (errno != ENOENT) {
- err = got_error_prefix_errno2("stat", path);
+ err = got_error_from_errno2("stat", path);
goto done;
}
sb.st_mode = GOT_DEFAULT_FILE_MODE;
}
if (rename(tmppath, path) != 0) {
- err = got_error_prefix_errno3("rename", tmppath, path);
+ err = got_error_from_errno3("rename", tmppath, path);
goto done;
}
free(tmppath);
tmppath = NULL;
if (chmod(path, sb.st_mode) != 0) {
- err = got_error_prefix_errno2("chmod", path);
+ err = got_error_from_errno2("chmod", path);
goto done;
}
done:
unlock_err = got_lockfile_unlock(lf);
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
free(path_refs);
free(path);
if (tmppath) {
if (unlink(tmppath) != 0 && err == NULL)
- err = got_error_prefix_errno2("unlink", tmppath);
+ err = got_error_from_errno2("unlink", tmppath);
free(tmppath);
}
return err ? err : unlock_err;
packed_refs_path = got_repo_get_path_packed_refs(repo);
if (packed_refs_path == NULL)
- return got_error_prefix_errno("got_repo_get_path_packed_refs");
+ return got_error_from_errno("got_repo_get_path_packed_refs");
err = got_opentemp_named(&tmppath, &tmpf, packed_refs_path);
if (err)
f = fopen(packed_refs_path, "r");
if (f == NULL) {
- err = got_error_prefix_errno2("fopen", packed_refs_path);
+ err = got_error_from_errno2("fopen", packed_refs_path);
goto done;
}
for (;;) {
}
if (fflush(tmpf) != 0) {
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
goto done;
}
if (stat(packed_refs_path, &sb) != 0) {
if (errno != ENOENT) {
- err = got_error_prefix_errno2("stat",
+ err = got_error_from_errno2("stat",
packed_refs_path);
goto done;
}
}
if (rename(tmppath, packed_refs_path) != 0) {
- err = got_error_prefix_errno3("rename", tmppath,
+ err = got_error_from_errno3("rename", tmppath,
packed_refs_path);
goto done;
}
if (chmod(packed_refs_path, sb.st_mode) != 0) {
- err = got_error_prefix_errno2("chmod",
+ err = got_error_from_errno2("chmod",
packed_refs_path);
goto done;
}
unlock_err = got_lockfile_unlock(lf);
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
if (tmpf) {
unlink(tmppath);
if (fclose(tmpf) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
free(tmppath);
free(packed_refs_path);
path_refs = get_refs_dir_path(repo, name);
if (path_refs == NULL) {
- err = got_error_prefix_errno2("get_refs_dir_path", name);
+ err = got_error_from_errno2("get_refs_dir_path", name);
goto done;
}
if (asprintf(&path, "%s/%s", path_refs, name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
/* XXX: check if old content matches our expectations? */
if (unlink(path) != 0)
- err = got_error_prefix_errno2("unlink", path);
+ err = got_error_from_errno2("unlink", path);
done:
if (ref->lf == NULL && lf)
unlock_err = got_lockfile_unlock(lf);
blob - ef82dcbdfbbb231f2e5911319eb6ff7952e6276d
blob + 4a2efe86fcf1cf4a1e8a7b1cac198509adfa3a8c
--- lib/repository.c
+++ lib/repository.c
/* bare git repository? */
repo->path_git_dir = strdup(path);
if (repo->path_git_dir == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
if (is_git_repo(repo)) {
repo->path = strdup(repo->path_git_dir);
if (repo->path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
return NULL;
/* git repository with working tree? */
free(repo->path_git_dir);
if (asprintf(&repo->path_git_dir, "%s/%s", path, GOT_GIT_DIR) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (is_git_repo(repo)) {
repo->path = strdup(path);
if (repo->path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
return NULL;
repo = calloc(1, sizeof(*repo));
if (repo == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
}
path = dirname(path);
if (path == NULL)
- err = got_error_prefix_errno2("dirname", path);
+ err = got_error_from_errno2("dirname", path);
} while (path);
done:
if (err)
err = child_err;
if (close(repo->privsep_children[i].imsg_fd) != 0 &&
err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
free(repo);
cwd = getcwd(NULL, 0);
if (cwd == NULL)
- return got_error_prefix_errno("getcwd");
+ return got_error_from_errno("getcwd");
canonpath = strdup(input_path);
if (canonpath == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = got_canonpath(input_path, canonpath, strlen(canonpath) + 1);
if (!check_disk) {
path = strdup(canonpath);
if (path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
} else {
path = realpath(canonpath, NULL);
if (path == NULL) {
if (errno != ENOENT) {
- err = got_error_prefix_errno2("realpath",
+ err = got_error_from_errno2("realpath",
canonpath);
goto done;
}
*/
path = strdup(canonpath);
if (path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
}
free(path);
path = strdup("");
if (path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
} else if (is_repo_child && is_cwd_child) {
if (path[0] != '/') {
char *abspath;
if (asprintf(&abspath, "/%s", path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
free(path);
path_packdir = got_repo_get_path_objects_pack(repo);
if (path_packdir == NULL)
- return got_error_prefix_errno("got_repo_get_path_objects_pack");
+ return got_error_from_errno("got_repo_get_path_objects_pack");
packdir = opendir(path_packdir);
if (packdir == NULL) {
- err = got_error_prefix_errno2("opendir", path_packdir);
+ err = got_error_from_errno2("opendir", path_packdir);
goto done;
}
if (asprintf(&path_packidx, "%s/%s", path_packdir,
dent->d_name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
done:
free(path_packdir);
if (packdir && closedir(packdir) != 0 && err == 0)
- err = got_error_prefix_errno("closedir");
+ err = got_error_from_errno("closedir");
return err;
}
n = read(fd, &hdr, sizeof(hdr));
if (n < 0)
- return got_error_prefix_errno("read");
+ return got_error_from_errno("read");
if (n != sizeof(hdr))
return got_error(GOT_ERR_BAD_PACKFILE);
*fd = open(path_packfile, O_RDONLY | O_NOFOLLOW);
if (*fd == -1)
- return got_error_prefix_errno2("open", path_packfile);
+ return got_error_from_errno2("open", path_packfile);
if (packidx) {
err = read_packfile_hdr(*fd, packidx);
pack->path_packfile = strdup(path_packfile);
if (pack->path_packfile == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
pack->fd, 0);
if (pack->map == MAP_FAILED) {
if (errno != ENOMEM) {
- err = got_error_prefix_errno("mmap");
+ err = got_error_from_errno("mmap");
goto done;
}
pack->map = NULL; /* fall back to read(2) */
blob - 53fc4a5db64d58550cdf558c5f45e93be6eaf848
blob + 41c3f2e47158bafbf6229ab2c3b32dbb106c2e93
--- lib/utf8.c
+++ lib/utf8.c
len = strlen(mbs);
if ((*outp = malloc(len + 1)) == NULL)
- return got_error_prefix_errno("malloc");
+ return got_error_from_errno("malloc");
if (MB_CUR_MAX == 1) {
memcpy(*outp, mbs, len + 1);
blob - 9186607062c7b5c859c727a75daad76225a91a48
blob + f765f02f02a5448996609a862e8e4cbf2aa56f55
--- lib/worklist.c
+++ lib/worklist.c
wkl = calloc(1, sizeof(*wkl));
if (wkl == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
len = strlcpy(wkl->wkl_path, path, sizeof(wkl->wkl_path));
if (len >= sizeof(wkl->wkl_path))
blob - b6a44c48e939a16889c4bde6c791760cf4b4faf5
blob + d2ab48df22bc1599be297b1d41e5f7d98447d094
--- lib/worktree.c
+++ lib/worktree.c
int fd = -1;
if (asprintf(&path, "%s/%s", path_got, name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path = NULL;
goto done;
}
fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
GOT_DEFAULT_FILE_MODE);
if (fd == -1) {
- err = got_error_prefix_errno2("open", path);
+ err = got_error_from_errno2("open", path);
goto done;
}
if (content) {
int len = dprintf(fd, "%s\n", content);
if (len != strlen(content) + 1) {
- err = got_error_prefix_errno("dprintf");
+ err = got_error_from_errno("dprintf");
goto done;
}
}
done:
if (fd != -1 && close(fd) == -1 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
free(path);
return err;
}
char *path = NULL;
if (asprintf(&path, "%s/%s", path_got, name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path = NULL;
goto done;
}
if (content) {
int len = fprintf(tmpfile, "%s\n", content);
if (len != strlen(content) + 1) {
- err = got_error_prefix_errno2("fprintf", tmppath);
+ err = got_error_from_errno2("fprintf", tmppath);
goto done;
}
}
if (rename(tmppath, path) != 0) {
- err = got_error_prefix_errno3("rename", tmppath, path);
+ err = got_error_from_errno3("rename", tmppath, path);
unlink(tmppath);
goto done;
}
done:
if (fclose(tmpfile) != 0 && err == NULL)
- err = got_error_prefix_errno2("fclose", tmppath);
+ err = got_error_from_errno2("fclose", tmppath);
free(tmppath);
return err;
}
*content = NULL;
if (asprintf(&path, "%s/%s", path_got, name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path = NULL;
goto done;
}
if (errno == ENOENT)
err = got_error(GOT_ERR_WORKTREE_META);
else
- err = got_error_prefix_errno2("open", path);
+ err = got_error_from_errno2("open", path);
goto done;
}
if (flock(fd, LOCK_SH | LOCK_NB) == -1) {
err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
- : got_error_prefix_errno2("flock", path));
+ : got_error_from_errno2("flock", path));
goto done;
}
if (lstat(path, &sb) != 0) {
- err = got_error_prefix_errno2("lstat", path);
+ err = got_error_from_errno2("lstat", path);
goto done;
}
*content = calloc(1, sb.st_size);
if (*content == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
n = read(fd, *content, sb.st_size);
if (n != sb.st_size) {
- err = (n == -1 ? got_error_prefix_errno2("read", path) :
+ err = (n == -1 ? got_error_from_errno2("read", path) :
got_error(GOT_ERR_WORKTREE_META));
goto done;
}
done:
if (fd != -1 && close(fd) == -1 && err == NULL)
- err = got_error_prefix_errno2("close", path_got);
+ err = got_error_from_errno2("close", path_got);
free(path);
if (err) {
free(*content);
if (!got_path_is_absolute(prefix)) {
if (asprintf(&absprefix, "/%s", prefix) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
/* Create top-level directory (may already exist). */
if (mkdir(path, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
- err = got_error_prefix_errno2("mkdir", path);
+ err = got_error_from_errno2("mkdir", path);
goto done;
}
/* Create .got directory (may already exist). */
if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (mkdir(path_got, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
- err = got_error_prefix_errno2("mkdir", path_got);
+ err = got_error_from_errno2("mkdir", path_got);
goto done;
}
/* Write the HEAD reference. */
refstr = got_ref_to_str(head_ref);
if (refstr == NULL) {
- err = got_error_prefix_errno("got_ref_to_str");
+ err = got_error_from_errno("got_ref_to_str");
goto done;
}
err = create_meta_file(path_got, GOT_WORKTREE_HEAD_REF, refstr);
/* Stamp work tree with format file. */
if (asprintf(&formatstr, "%d", GOT_WORKTREE_FORMAT_VERSION) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
err = create_meta_file(path_got, GOT_WORKTREE_FORMAT, formatstr);
*worktree = NULL;
if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path_got = NULL;
goto done;
}
if (asprintf(&path_lock, "%s/%s", path_got, GOT_WORKTREE_LOCK) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path_lock = NULL;
goto done;
}
fd = open(path_lock, O_RDWR | O_EXLOCK | O_NONBLOCK);
if (fd == -1) {
err = (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
- : got_error_prefix_errno2("open", path_lock));
+ : got_error_from_errno2("open", path_lock));
goto done;
}
*worktree = calloc(1, sizeof(**worktree));
if (*worktree == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
(*worktree)->lockfd = -1;
(*worktree)->root_path = strdup(path);
if ((*worktree)->root_path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = read_meta_file(&(*worktree)->repo_path, path_got,
return NULL;
path = dirname(path);
if (path == NULL)
- return got_error_prefix_errno2("dirname", path);
+ return got_error_from_errno2("dirname", path);
} while (!((path[0] == '.' || path[0] == '/') && path[1] == '\0'));
return got_error(GOT_ERR_NOT_WORKTREE);
free(worktree->head_ref_name);
if (worktree->lockfd != -1)
if (close(worktree->lockfd) != 0)
- err = got_error_prefix_errno2("close",
+ err = got_error_from_errno2("close",
got_worktree_get_root_path(worktree));
free(worktree);
return err;
if (!got_path_is_absolute(path_prefix)) {
if (asprintf(&absprefix, "/%s", path_prefix) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
*match = (strcmp(absprefix ? absprefix : path_prefix,
worktree->path_prefix) == 0);
if (asprintf(&path_got, "%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
path_got = NULL;
goto done;
}
free(worktree->base_commit_id);
worktree->base_commit_id = got_object_id_dup(commit_id);
if (worktree->base_commit_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
done:
{
if (flock(worktree->lockfd, operation | LOCK_NB) == -1)
return (errno == EWOULDBLOCK ? got_error(GOT_ERR_WORKTREE_BUSY)
- : got_error_prefix_errno2("flock",
+ : got_error_from_errno2("flock",
got_worktree_get_root_path(worktree)));
return NULL;
}
char *abspath;
if (asprintf(&abspath, "%s/%s", worktree->root_path, path) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = got_path_mkdir(abspath);
if (err && err->code == GOT_ERR_ERRNO && errno == EEXIST) {
struct stat sb;
err = NULL;
if (lstat(abspath, &sb) == -1) {
- err = got_error_prefix_errno2("lstat", abspath);
+ err = got_error_from_errno2("lstat", abspath);
} else if (!S_ISDIR(sb.st_mode)) {
/* TODO directory is obstructed; do something */
err = got_error(GOT_ERR_FILE_OBSTRUCTED);
for (;;) {
flen1 = fread(fbuf1, 1, sizeof(fbuf1), f1);
if (flen1 == 0 && ferror(f1)) {
- err = got_error_prefix_errno("fread");
+ err = got_error_from_errno("fread");
break;
}
flen2 = fread(fbuf2, 1, sizeof(fbuf2), f2);
if (flen2 == 0 && ferror(f2)) {
- err = got_error_prefix_errno("fread");
+ err = got_error_from_errno("fread");
break;
}
if (flen1 == 0) {
*same = 1;
if (lstat(f1_path, &sb) != 0) {
- err = got_error_prefix_errno2("lstat", f1_path);
+ err = got_error_from_errno2("lstat", f1_path);
goto done;
}
size1 = sb.st_size;
if (lstat(f2_path, &sb) != 0) {
- err = got_error_prefix_errno2("lstat", f2_path);
+ err = got_error_from_errno2("lstat", f2_path);
goto done;
}
size2 = sb.st_size;
f1 = fopen(f1_path, "r");
if (f1 == NULL)
- return got_error_prefix_errno2("open", f1_path);
+ return got_error_from_errno2("open", f1_path);
f2 = fopen(f2_path, "r");
if (f2 == NULL) {
- err = got_error_prefix_errno2("open", f2_path);
+ err = got_error_from_errno2("open", f2_path);
goto done;
}
err = check_file_contents_equal(same, f1, f2);
done:
if (f1 && fclose(f1) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (f2 && fclose(f2) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
parent = dirname(ondisk_path);
if (parent == NULL)
- return got_error_prefix_errno2("dirname", ondisk_path);
+ return got_error_from_errno2("dirname", ondisk_path);
if (asprintf(&base_path, "%s/got-merged", parent) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = got_opentemp_named_fd(&merged_path, &merged_fd, base_path);
if (err)
free(base_path);
if (asprintf(&base_path, "%s/got-merge-blob1", parent) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
base_path = NULL;
goto done;
}
free(base_path);
if (asprintf(&base_path, "%s/got-merge-blob2", parent) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
base_path = NULL;
goto done;
}
if (err)
goto done;
if (asprintf(&label1, "commit %s", id_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
overlapcnt > 0 ? GOT_STATUS_CONFLICT : GOT_STATUS_MERGE, path);
if (fsync(merged_fd) != 0) {
- err = got_error_prefix_errno("fsync");
+ err = got_error_from_errno("fsync");
goto done;
}
}
if (chmod(merged_path, st_mode) != 0) {
- err = got_error_prefix_errno2("chmod", merged_path);
+ err = got_error_from_errno2("chmod", merged_path);
goto done;
}
if (rename(merged_path, ondisk_path) != 0) {
- err = got_error_prefix_errno3("rename", merged_path,
+ err = got_error_from_errno3("rename", merged_path,
ondisk_path);
unlink(merged_path);
goto done;
blob1->id.sha1, worktree->base_commit_id->sha1, update_timestamps);
done:
if (merged_fd != -1 && close(merged_fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
if (f1 && fclose(f1) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (f2 && fclose(f2) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (blob2)
got_object_blob_close(blob2);
free(merged_path);
if (errno == ENOENT) {
char *parent = dirname(path);
if (parent == NULL)
- return got_error_prefix_errno2("dirname", path);
+ return got_error_from_errno2("dirname", path);
err = add_dir_on_disk(worktree, parent);
if (err)
return err;
O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
GOT_DEFAULT_FILE_MODE);
if (fd == -1)
- return got_error_prefix_errno2("open",
+ return got_error_from_errno2("open",
ondisk_path);
} else if (errno == EEXIST) {
if (!S_ISREG(st_mode)) {
update = 1;
}
} else
- return got_error_prefix_errno2("open", ondisk_path);
+ return got_error_from_errno2("open", ondisk_path);
}
if (restoring_missing_file)
/* Skip blob object header first time around. */
ssize_t outlen = write(fd, buf + hdrlen, len - hdrlen);
if (outlen == -1) {
- err = got_error_prefix_errno("write");
+ err = got_error_from_errno("write");
goto done;
} else if (outlen != len - hdrlen) {
err = got_error(GOT_ERR_IO);
} while (len != 0);
if (fsync(fd) != 0) {
- err = got_error_prefix_errno("fsync");
+ err = got_error_from_errno("fsync");
goto done;
}
if (update) {
if (rename(tmppath, ondisk_path) != 0) {
- err = got_error_prefix_errno3("rename", tmppath,
+ err = got_error_from_errno3("rename", tmppath,
ondisk_path);
unlink(tmppath);
goto done;
if (te_mode & S_IXUSR) {
if (chmod(ondisk_path, st_mode | S_IXUSR) == -1) {
- err = got_error_prefix_errno2("chmod", ondisk_path);
+ err = got_error_from_errno2("chmod", ondisk_path);
goto done;
}
} else {
if (chmod(ondisk_path, st_mode & ~S_IXUSR) == -1) {
- err = got_error_prefix_errno2("chmod", ondisk_path);
+ err = got_error_from_errno2("chmod", ondisk_path);
goto done;
}
}
done:
if (fd != -1 && close(fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
free(tmppath);
return err;
}
sb->st_mode = GOT_DEFAULT_FILE_MODE;
return NULL;
}
- return got_error_prefix_errno2("lstat", abspath);
+ return got_error_from_errno2("lstat", abspath);
}
if (!S_ISREG(sb->st_mode)) {
f = fopen(abspath, "r");
if (f == NULL) {
- err = got_error_prefix_errno2("fopen", abspath);
+ err = got_error_from_errno2("fopen", abspath);
goto done;
}
hdrlen = got_object_blob_get_hdrlen(blob);
/* Skip length of blob object header first time around. */
flen = fread(fbuf, 1, sizeof(fbuf) - hdrlen, f);
if (flen == 0 && ferror(f)) {
- err = got_error_prefix_errno("fread");
+ err = got_error_from_errno("fread");
goto done;
}
if (blen == 0) {
struct stat sb;
if (asprintf(&ondisk_path, "%s/%s", worktree->root_path, path) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = get_file_status(&status, &sb, ie, ondisk_path, repo);
if (err)
char *ondisk_path = NULL;
if (asprintf(&ondisk_path, "%s/%s", root_path, path) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (unlink(ondisk_path) == -1) {
if (errno != ENOENT)
- err = got_error_prefix_errno2("unlink", ondisk_path);
+ err = got_error_from_errno2("unlink", ondisk_path);
} else {
char *parent = dirname(ondisk_path);
while (parent && strcmp(parent, root_path) != 0) {
if (rmdir(parent) == -1) {
if (errno != ENOTEMPTY)
- err = got_error_prefix_errno2("rmdir",
+ err = got_error_from_errno2("rmdir",
parent);
break;
}
if (asprintf(&ondisk_path, "%s/%s", worktree->root_path, ie->path)
== -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = get_file_status(&status, &sb, ie, ondisk_path, repo);
if (err)
if (asprintf(&path, "%s%s%s", parent_path,
parent_path[0] ? "/" : "", te->name)
== -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
if (S_ISDIR(te->mode))
err = add_dir_on_disk(a->worktree, path);
if (asprintf(refname, "%s-%s", GOT_WORKTREE_BASE_REF_PREFIX, uuidstr)
== -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
*refname = NULL;
}
free(uuidstr);
*fileindex_path = NULL;
*fileindex = got_fileindex_alloc();
if (*fileindex == NULL)
- return got_error_prefix_errno("got_fileindex_alloc");
+ return got_error_from_errno("got_fileindex_alloc");
if (asprintf(fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
*fileindex_path = NULL;
goto done;
}
index = fopen(*fileindex_path, "rb");
if (index == NULL) {
if (errno != ENOENT)
- err = got_error_prefix_errno2("fopen", *fileindex_path);
+ err = got_error_from_errno2("fopen", *fileindex_path);
} else {
err = got_fileindex_read(*fileindex, index);
if (fclose(index) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
done:
if (err) {
int obj_type;
relpath = strdup(path);
if (relpath == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
if (asprintf(&tree_path, "%s%s%s", worktree->path_prefix,
got_path_is_root_dir(worktree->path_prefix) ? "" : "/",
path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
err = got_object_id_by_path(&tree_id, repo,
if (strchr(path, '/') == NULL) {
relpath = strdup("");
if (relpath == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
tree_path = strdup(worktree->path_prefix);
if (tree_path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
} else {
got_path_is_root_dir(
worktree->path_prefix) ? "" : "/",
relpath) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
}
goto done;
entry_name = basename(path);
if (entry_name == NULL) {
- err = got_error_prefix_errno2("basename", path);
+ err = got_error_from_errno2("basename", path);
goto done;
}
}
} else {
relpath = strdup("");
if (relpath == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = got_object_id_by_path(&tree_id, repo,
goto done;
if (rename(new_fileindex_path, fileindex_path) != 0) {
- err = got_error_prefix_errno3("rename", new_fileindex_path,
+ err = got_error_from_errno3("rename", new_fileindex_path,
fileindex_path);
unlink(new_fileindex_path);
goto done;
if (parent_path[0]) {
if (asprintf(&abspath, "%s/%s/%s", a->worktree->root_path,
parent_path, de->d_name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
} else {
if (asprintf(&abspath, "%s/%s", a->worktree->root_path,
de->d_name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
err = report_file_status(ie, abspath, a->status_cb, a->status_arg,
if (parent_path[0]) {
if (asprintf(&path, "%s/%s", parent_path, de->d_name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
} else {
path = de->d_name;
}
fileindex = got_fileindex_alloc();
if (fileindex == NULL) {
- err = got_error_prefix_errno("got_fileindex_alloc");
+ err = got_error_from_errno("got_fileindex_alloc");
goto done;
}
if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
fileindex_path = NULL;
goto done;
}
index = fopen(fileindex_path, "rb");
if (index == NULL) {
if (errno != ENOENT) {
- err = got_error_prefix_errno2("fopen", fileindex_path);
+ err = got_error_from_errno2("fopen", fileindex_path);
goto done;
}
} else {
if (asprintf(&ondisk_path, "%s%s%s",
worktree->root_path, path[0] ? "/" : "", path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
workdir = opendir(ondisk_path);
status_cb, status_arg, repo);
goto done;
} else {
- err = got_error_prefix_errno2("opendir", ondisk_path);
+ err = got_error_from_errno2("opendir", ondisk_path);
goto done;
}
}
resolved = realpath(arg, NULL);
if (resolved == NULL)
- return got_error_prefix_errno2("realpath", arg);
+ return got_error_from_errno2("realpath", arg);
if (strncmp(got_worktree_get_root_path(worktree), resolved,
strlen(got_worktree_get_root_path(worktree)))) {
path = strdup(resolved +
strlen(got_worktree_get_root_path(worktree)) + 1 /* skip '/' */);
if (path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
fileindex = got_fileindex_alloc();
if (fileindex == NULL) {
- err = got_error_prefix_errno("got_fileindex_alloc");
+ err = got_error_from_errno("got_fileindex_alloc");
goto done;
}
if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
fileindex_path = NULL;
goto done;
}
index = fopen(fileindex_path, "rb");
if (index == NULL) {
- err = got_error_prefix_errno2("fopen", fileindex_path);
+ err = got_error_from_errno2("fopen", fileindex_path);
goto done;
}
goto done;
if (rename(new_fileindex_path, fileindex_path) != 0) {
- err = got_error_prefix_errno3("rename", new_fileindex_path,
+ err = got_error_from_errno3("rename", new_fileindex_path,
fileindex_path);
goto done;
}
done:
if (index) {
if (fclose(index) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
if (new_fileindex_path) {
if (unlink(new_fileindex_path) != 0 && err == NULL)
- err = got_error_prefix_errno2("unlink",
+ err = got_error_from_errno2("unlink",
new_fileindex_path);
free(new_fileindex_path);
}
fileindex = got_fileindex_alloc();
if (fileindex == NULL) {
- err = got_error_prefix_errno("got_fileindex_alloc");
+ err = got_error_from_errno("got_fileindex_alloc");
goto done;
}
if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
fileindex_path = NULL;
goto done;
}
index = fopen(fileindex_path, "rb");
if (index == NULL) {
- err = got_error_prefix_errno2("fopen", fileindex_path);
+ err = got_error_from_errno2("fopen", fileindex_path);
goto done;
}
}
if (unlink(ondisk_path) != 0) {
- err = got_error_prefix_errno2("unlink", ondisk_path);
+ err = got_error_from_errno2("unlink", ondisk_path);
goto done;
}
goto done;
if (rename(new_fileindex_path, fileindex_path) != 0) {
- err = got_error_prefix_errno3("rename", new_fileindex_path,
+ err = got_error_from_errno3("rename", new_fileindex_path,
fileindex_path);
goto done;
}
free(relpath);
if (index) {
if (fclose(index) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
if (new_fileindex_path) {
if (unlink(new_fileindex_path) != 0 && err == NULL)
- err = got_error_prefix_errno2("unlink",
+ err = got_error_from_errno2("unlink",
new_fileindex_path);
free(new_fileindex_path);
}
fileindex = got_fileindex_alloc();
if (fileindex == NULL) {
- err = got_error_prefix_errno("got_fileindex_alloc");
+ err = got_error_from_errno("got_fileindex_alloc");
goto done;
}
if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
fileindex_path = NULL;
goto done;
}
index = fopen(fileindex_path, "rb");
if (index == NULL) {
- err = got_error_prefix_errno2("fopen", fileindex_path);
+ err = got_error_from_errno2("fopen", fileindex_path);
goto done;
}
if (got_path_is_root_dir(worktree->path_prefix)) {
tree_path = strdup(parent_path);
if (tree_path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
} else {
if (got_path_is_root_dir(parent_path)) {
tree_path = strdup(worktree->path_prefix);
if (tree_path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
} else {
if (asprintf(&tree_path, "%s/%s",
worktree->path_prefix, parent_path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
}
te_name = basename(ie->path);
if (te_name == NULL) {
- err = got_error_prefix_errno2("basename", ie->path);
+ err = got_error_from_errno2("basename", ie->path);
goto done;
}
goto done;
if (rename(new_fileindex_path, fileindex_path) != 0) {
- err = got_error_prefix_errno3("rename", new_fileindex_path,
+ err = got_error_from_errno3("rename", new_fileindex_path,
fileindex_path);
goto done;
}
free(tree_id);
if (index) {
if (fclose(index) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
}
if (new_fileindex_path) {
if (unlink(new_fileindex_path) != 0 && err == NULL)
- err = got_error_prefix_errno2("unlink",
+ err = got_error_from_errno2("unlink",
new_fileindex_path);
free(new_fileindex_path);
}
return NULL;
if (asprintf(&path, "/%s", relpath) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (strcmp(path, "/") == 0) {
parent_path = strdup("");
if (parent_path == NULL)
- return got_error_prefix_errno("strdup");
+ return got_error_from_errno("strdup");
} else {
err = got_path_dirname(&parent_path, path);
if (err)
ct = calloc(1, sizeof(*ct));
if (ct == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
if (asprintf(&ct->ondisk_path, "%s/%s", a->worktree->root_path,
relpath) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (status == GOT_STATUS_DELETE) {
sb.st_mode = GOT_DEFAULT_FILE_MODE;
} else {
if (lstat(ct->ondisk_path, &sb) != 0) {
- err = got_error_prefix_errno2("lstat", ct->ondisk_path);
+ err = got_error_from_errno2("lstat", ct->ondisk_path);
goto done;
}
ct->mode = sb.st_mode;
if (asprintf(&ct->in_repo_path, "%s%s%s", a->worktree->path_prefix,
got_path_is_root_dir(a->worktree->path_prefix) ? "" : "/",
relpath) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (ct->status != GOT_STATUS_ADD) {
ct->base_id = got_object_id_dup(id);
if (ct->base_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
}
ct->path = strdup(path);
if (ct->path == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = got_pathlist_insert(&new, a->commitable_paths, ct->path, ct);
if (asprintf(&subpath, "%s%s%s", parent_path,
got_path_is_root_dir(parent_path) ? "" : "/", te->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
err = got_object_open_as_tree(&subtree, repo, te->id);
if (err)
free((*new_te)->id);
(*new_te)->id = got_object_id_dup(ct->blob_id);
if ((*new_te)->id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
done:
*new_te = calloc(1, sizeof(**new_te));
if (*new_te == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
ct_name = basename(ct->path);
if (ct_name == NULL) {
- err = got_error_prefix_errno2("basename", ct->path);
+ err = got_error_from_errno2("basename", ct->path);
goto done;
}
(*new_te)->name = strdup(ct_name);
if ((*new_te)->name == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
(*new_te)->id = got_object_id_dup(ct->blob_id);
if ((*new_te)->id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
done:
if (asprintf(&te_path, "%s%s%s", base_tree_path,
got_path_is_root_dir(base_tree_path) ? "" : "/",
te->name) == -1)
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
TAILQ_FOREACH(pe, commitable_paths, entry) {
struct got_commitable *ct = pe->data;
ct_name = basename(pe->path);
if (ct_name == NULL)
- return got_error_prefix_errno2("basename", pe->path);
+ return got_error_from_errno2("basename", pe->path);
if (strcmp(te->name, ct_name) != 0)
continue;
if (asprintf(&subtree_path, "%s%s%s", path_base_tree,
got_path_is_root_dir(path_base_tree) ? "" : "/",
child_path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
TAILQ_FOREACH(pe2, &paths, entry) {
new_te->mode = S_IFDIR;
new_te->name = strdup(child_path);
if (new_te->name == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
got_object_tree_entry_close(new_te);
new_te = NULL;
goto done;
goto done;
if (rename(new_fileindex_path, fileindex_path) != 0) {
- err = got_error_prefix_errno3("rename", new_fileindex_path,
+ err = got_error_from_errno3("rename", new_fileindex_path,
fileindex_path);
unlink(new_fileindex_path);
goto done;
if (asprintf(&ondisk_path, "%s/%s",
worktree->root_path, pe->path) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
err = got_object_blob_create(&ct->blob_id, ondisk_path, repo);
/* Check if a concurrent commit to our branch has occurred. */
head_ref_name = got_worktree_get_head_ref_name(worktree);
if (head_ref_name == NULL) {
- err = got_error_prefix_errno("got_worktree_get_head_ref_name");
+ err = got_error_from_errno("got_worktree_get_head_ref_name");
goto done;
}
/* Lock the reference here to prevent concurrent modification. */
blob - f28286daed294ffb777009a1fddf3d4b82b5d856
blob + 983478ce1555e8fa55323e842c72c6927facc1b9
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
goto done;
if (lseek(imsg.fd, SEEK_SET, 0) == -1) {
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
goto done;
}
f = fdopen(imsg.fd, "rb");
if (f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
goto done;
}
done:
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
} else if (imsg.fd != -1) {
if (close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
if (imsg_outfd.fd != -1) {
if (close(imsg_outfd.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
imsg_free(&imsg);
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - b015c3522f885fade88efdbd587bc655cb57984e
blob + f2dc8530f505f8258e2e20cdc61b83edee6dd969
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
/* Always assume file offset zero. */
f = fdopen(imsg.fd, "rb");
if (f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
goto done;
}
done:
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
} else if (imsg.fd != -1) {
if (close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
imsg_free(&imsg);
if (err)
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - f3b5792c26407f6760130ae763cbbfdb0ad0374a
blob + 0101bb0c03486ff728a5c9e538f96cc5b627bff2
--- libexec/got-read-object/got-read-object.c
+++ libexec/got-read-object/got-read-object.c
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
err = got_privsep_send_obj(&ibuf, obj);
done:
if (close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
imsg_free(&imsg);
if (obj)
got_object_close(obj);
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - 509295efffc3b0c4ab0b72c400398ae7d0b91bcc
blob + 3952d83a577c5510f0af5c58e08788892c81184c
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
*f = fdopen(imsg.fd, "w+");
if (*f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
close(imsg.fd);
goto done;
}
done:
free(buf);
if (outfile && fclose(outfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
- if (basefile && fclose(basefile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
+ if (basefile && fclose(basefile) != 0 && err == NULL)
+ err = got_error_from_errno("fclose");
if (accumfile && fclose(accumfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (obj)
got_object_close(obj);
if (err && err->code != GOT_ERR_PRIVSEP_PIPE)
p = calloc(1, sizeof(*p));
if (p == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
p->len = ipackidx.len;
p->fd = dup(imsg.fd);
if (p->fd == -1) {
- err = got_error_prefix_errno("dup");
+ err = got_error_from_errno("dup");
goto done;
}
if (lseek(p->fd, 0, SEEK_SET) == -1) {
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
goto done;
}
pack = calloc(1, sizeof(*pack));
if (pack == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
pack->filesize = ipack.filesize;
pack->fd = dup(imsg.fd);
if (pack->fd == -1) {
- err = got_error_prefix_errno("dup");
+ err = got_error_from_errno("dup");
goto done;
}
if (lseek(pack->fd, 0, SEEK_SET) == -1) {
- err = got_error_prefix_errno("lseek");
+ err = got_error_from_errno("lseek");
goto done;
}
pack->path_packfile = strdup(ipack.path_packfile);
if (pack->path_packfile == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = got_object_cache_init(&objcache, GOT_OBJECT_CACHE_TYPE_OBJ);
if (err) {
- err = got_error_prefix_errno("got_object_cache_init");
+ err = got_error_from_errno("got_object_cache_init");
got_privsep_send_error(&ibuf, err);
return 1;
}
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
}
if (imsg.fd != -1 && close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
imsg_free(&imsg);
if (err)
break;
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - aff70b3e271c5d54f9f704c9c34232819a7caa28
blob + cff236e8d51c7308f89a0a4787c0db0df97f3bc2
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
/* Always assume file offset zero. */
f = fdopen(imsg.fd, "rb");
if (f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
goto done;
}
done:
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
} else if (imsg.fd != -1) {
if (close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
imsg_free(&imsg);
if (err)
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - c3fc7aaef2ffafb2c1a8ba22f252b2d18482d347
blob + 8d4fb58038502b1440ee93c55d0794ed50eafdc0
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
- err = got_error_prefix_errno("pledge");
+ err = got_error_from_errno("pledge");
got_privsep_send_error(&ibuf, err);
return 1;
}
/* Always assume file offset zero. */
f = fdopen(imsg.fd, "rb");
if (f == NULL) {
- err = got_error_prefix_errno("fdopen");
+ err = got_error_from_errno("fdopen");
goto done;
}
done:
if (f) {
if (fclose(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
} else if (imsg.fd != -1) {
if (close(imsg.fd) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
}
imsg_free(&imsg);
if (err)
}
}
if (close(GOT_IMSG_FD_CHILD) != 0 && err == NULL)
- err = got_error_prefix_errno("close");
+ err = got_error_from_errno("close");
return err ? 1 : 0;
}
blob - 7310a6d1b805676beb32c6da1a10e6d0b2256d46
blob + 5f086a5558ca0997cb705fa354cdcf4e673e29b3
--- regress/delta/delta_test.c
+++ regress/delta/delta_test.c
base_file = got_opentemp();
if (base_file == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
break;
}
err = got_delta_apply(base_file, dt->delta, dt->delta_len,
result_file, &result_len);
if (fclose(base_file) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
if (dt->expected == NULL) {
/* Invalid delta, expect an error. */
if (err == NULL)
blob - a42e23795b0488e27d70d33563f89f50c7b77e47
blob + 9a8671fcef058130186736a3dc39b490362cc7ef
--- regress/idset/idset_test.c
+++ regress/idset/idset_test.c
set = got_object_idset_alloc();
if (set == NULL) {
- err = got_error_prefix_errno("got_object_idset_alloc");
+ err = got_error_from_errno("got_object_idset_alloc");
goto done;
}
if (got_object_idset_num_elements(set) != 0) {
blob - 1c8251f97cb80f83b6ae8a4939b6cee9122d311d
blob + a55620128ddb9624806e98d9ca7ae693ec0db127
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
free(hex);
if (asprintf(&next_parent, "%s/%s", parent, te->name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
break;
}
i++;
}
if (fclose(outfile) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
test_printf("\n");
if (i != nitems(expected_output) + 1) {
test_printf("number of lines expected: %d; actual: %d\n",
if (repo_path) {
normpath = got_path_normalize(repo_path);
if (normpath == NULL)
- return got_error_prefix_errno("got_path_normalize");
+ return got_error_from_errno("got_path_normalize");
if (unveil(normpath, "r") != 0) {
free(normpath);
- return got_error_prefix_errno2("unveil", normpath);
+ return got_error_from_errno2("unveil", normpath);
}
free(normpath);
}
if (unveil("/tmp", "rwc") != 0)
- return got_error_prefix_errno2("unveil", "/tmp");
+ return got_error_from_errno2("unveil", "/tmp");
if (unveil("/dev/null", "rwc") != 0)
- return got_error_prefix_errno2("unveil", "/dev/null");
+ return got_error_from_errno2("unveil", "/dev/null");
error = got_privsep_unveil_exec_helpers();
if (error != NULL)
return error;
if (unveil(NULL, NULL) != 0)
- return got_error_prefix_errno("unveil");
+ return got_error_from_errno("unveil");
return NULL;
}
blob - 316594959a4c54ced16b129f9a2a60abedc9cd5e
blob + 6cfa9eaa9e5fdee1f354906a1eed74177f0f7f6d
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
return err;
if (asprintf(&absrefname, "refs/%s", refname) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
err = got_ref_open(&base_ref, repo, absrefname, 0);
blob - c2a87f69d252f86fabb58aaab28cc97eec77d719
blob + f5d14d2ad18f52e6ac7f6ee94f09ccdbf29f844f
--- tog/tog.c
+++ tog/tog.c
return err;
if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
- return got_error_prefix_errno("mvwin");
+ return got_error_from_errno("mvwin");
return NULL;
}
return err;
if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
- return got_error_prefix_errno("mvwin");
+ return got_error_from_errno("mvwin");
return NULL;
}
ncols = view->ncols + (COLS - view->cols);
if (wresize(view->window, nlines, ncols) == ERR)
- return got_error_prefix_errno("wresize");
+ return got_error_from_errno("wresize");
if (replace_panel(view->panel, view->window) == ERR)
- return got_error_prefix_errno("replace_panel");
+ return got_error_from_errno("replace_panel");
wclear(view->window);
view->nlines = nlines;
if (*wlen == (size_t)-1) {
int vislen;
if (errno != EILSEQ)
- return got_error_prefix_errno("mbstowcs");
+ return got_error_from_errno("mbstowcs");
/* byte string invalid in current encoding; try to "fix" it */
err = got_mbsavis(&vis, &vislen, s);
return err;
*wlen = mbstowcs(NULL, vis, 0);
if (*wlen == (size_t)-1) {
- err = got_error_prefix_errno("mbstowcs"); /* give up */
+ err = got_error_from_errno("mbstowcs"); /* give up */
goto done;
}
}
*ws = calloc(*wlen + 1, sizeof(*ws));
if (*ws == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
if (mbstowcs(*ws, vis ? vis : s, *wlen) != *wlen)
- err = got_error_prefix_errno("mbstowcs");
+ err = got_error_from_errno("mbstowcs");
done:
free(vis);
if (err) {
i++;
break;
default:
- err = got_error_prefix_errno("wcwidth");
+ err = got_error_from_errno("wcwidth");
goto done;
}
}
s = *refs_str;
if (asprintf(refs_str, "%s%s%s", s ? s : "",
s ? ", " : "", name) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(s);
*refs_str = NULL;
break;
committer_time = got_object_commit_get_committer_time(commit);
if (localtime_r(&committer_time, &tm) == NULL)
- return got_error_prefix_errno("localtime_r");
+ return got_error_from_errno("localtime_r");
if (strftime(datebuf, sizeof(datebuf), "%g/%m/%d ", &tm)
>= sizeof(datebuf))
return got_error(GOT_ERR_NO_SPACE);
author = strdup(got_object_commit_get_author(commit));
if (author == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = format_author(&wauthor, &author_width, author, avail - col);
logmsg0 = strdup(got_object_commit_get_logmsg(commit));
if (logmsg0 == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
logmsg = logmsg0;
break;
entry = alloc_commit_queue_entry(commit, id);
if (entry == NULL) {
- err = got_error_prefix_errno("alloc_commit_queue_entry");
+ err = got_error_from_errno("alloc_commit_queue_entry");
break;
}
entry ? entry->idx + 1 : 0, commits->ncommits,
commits_needed > 0 ? "loading... " :
(refs_str ? refs_str : "")) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
if (asprintf(&header, "commit %s %s%s",
id_str ? id_str : "........................................",
path, ncommits_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
header = NULL;
goto done;
}
} else if (asprintf(&header, "commit %s%s",
id_str ? id_str : "........................................",
ncommits_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
header = NULL;
goto done;
}
break;
author = strdup(got_object_commit_get_author(entry->commit));
if (author == NULL) {
- err = got_error_prefix_errno("strdup");
+ err = got_error_from_errno("strdup");
goto done;
}
err = format_author(&wauthor, &width, author, COLS);
diff_view = view_open(0, 0, 0, begin_x, TOG_VIEW_DIFF);
if (diff_view == NULL)
- return got_error_prefix_errno("view_open");
+ return got_error_from_errno("view_open");
parent_id = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
err = open_diff_view(diff_view, parent_id ? parent_id->id : NULL,
tree_view = view_open(0, 0, 0, begin_x, TOG_VIEW_TREE);
if (tree_view == NULL)
- return got_error_prefix_errno("view_open");
+ return got_error_from_errno("view_open");
err = open_tree_view(tree_view, tree, entry->id, refs, repo);
if (err)
s->repo = repo;
s->start_id = got_object_id_dup(start_id);
if (s->start_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
lv = view_open(view->nlines, view->ncols,
view->begin_y, view->begin_x, TOG_VIEW_LOG);
if (lv == NULL)
- return got_error_prefix_errno(
+ return got_error_from_errno(
"view_open");
err = open_log_view(lv, s->start_id, s->refs,
s->repo, parent_path, 0);
const struct got_error *error;
if (repo_path && unveil(repo_path, "r") != 0)
- return got_error_prefix_errno2("unveil", repo_path);
+ return got_error_from_errno2("unveil", repo_path);
if (worktree_path && unveil(worktree_path, "rwc") != 0)
- return got_error_prefix_errno2("unveil", worktree_path);
+ return got_error_from_errno2("unveil", worktree_path);
if (unveil("/tmp", "rwc") != 0)
- return got_error_prefix_errno2("unveil", "/tmp");
+ return got_error_from_errno2("unveil", "/tmp");
error = got_privsep_unveil_exec_helpers();
if (error != NULL)
return error;
if (unveil(NULL, NULL) != 0)
- return got_error_prefix_errno("unveil");
+ return got_error_from_errno("unveil");
return NULL;
}
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
error = got_worktree_open(&worktree, cwd);
if (argc == 0) {
path = strdup("");
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
} else if (argc == 1) {
} else {
path = strdup(argv[0]);
if (path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
repo_path = worktree ?
strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
view = view_open(0, 0, 0, 0, TOG_VIEW_LOG);
if (view == NULL) {
- error = got_error_prefix_errno("view_open");
+ error = got_error_from_errno("view_open");
goto done;
}
error = open_log_view(view, start_id, &refs, repo, path, 1);
err = got_object_id_str(&id_str, commit_id);
if (err) {
- err = got_error_prefix_errno("got_object_id_str");
+ err = got_error_from_errno("got_object_id_str");
goto done;
}
if (fprintf(outfile, "commit %s%s%s%s\n", id_str, refs_str ? " (" : "",
refs_str ? refs_str : "", refs_str ? ")" : "") < 0) {
- err = got_error_prefix_errno("fprintf");
+ err = got_error_from_errno("fprintf");
goto done;
}
if (fprintf(outfile, "from: %s\n",
got_object_commit_get_author(commit)) < 0) {
- err = got_error_prefix_errno("fprintf");
+ err = got_error_from_errno("fprintf");
goto done;
}
committer_time = got_object_commit_get_committer_time(commit);
if (fprintf(outfile, "date: %s UTC\n",
get_datestr(&committer_time, datebuf)) < 0) {
- err = got_error_prefix_errno("fprintf");
+ err = got_error_from_errno("fprintf");
goto done;
}
author = got_object_commit_get_author(commit);
committer = got_object_commit_get_committer(commit);
if (strcmp(author, committer) != 0 &&
fprintf(outfile, "via: %s\n", committer) < 0) {
- err = got_error_prefix_errno("fprintf");
+ err = got_error_from_errno("fprintf");
goto done;
}
if (fprintf(outfile, "%s\n",
got_object_commit_get_logmsg(commit)) < 0) {
- err = got_error_prefix_errno("fprintf");
+ err = got_error_from_errno("fprintf");
goto done;
}
done:
f = got_opentemp();
if (f == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
if (s->f && fclose(s->f) != 0) {
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
goto done;
}
s->f = f;
}
done:
if (f && fflush(f) != 0 && err == NULL)
- err = got_error_prefix_errno("fflush");
+ err = got_error_from_errno("fflush");
return err;
}
if (id1) {
view->state.diff.id1 = got_object_id_dup(id1);
if (view->state.diff.id1 == NULL)
- return got_error_prefix_errno("got_object_id_dup");
+ return got_error_from_errno("got_object_id_dup");
} else
view->state.diff.id1 = NULL;
if (view->state.diff.id2 == NULL) {
free(view->state.diff.id1);
view->state.diff.id1 = NULL;
- return got_error_prefix_errno("got_object_id_dup");
+ return got_error_from_errno("got_object_id_dup");
}
view->state.diff.f = NULL;
view->state.diff.first_displayed_line = 1;
free(view->state.diff.id2);
view->state.diff.id2 = NULL;
if (view->state.diff.f && fclose(view->state.diff.f) == EOF)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
return err;
}
if (asprintf(&header, "diff %s %s",
id_str1 ? id_str1 : "/dev/null", id_str2) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(id_str1);
free(id_str2);
return err;
free(s->id2);
s->id2 = got_object_id_dup(entry->id);
if (s->id2 == NULL)
- return got_error_prefix_errno("got_object_id_dup");
+ return got_error_from_errno("got_object_id_dup");
err = got_object_open_as_commit(&selected_commit, s->repo, entry->id);
if (err)
} else if (argc == 2) {
repo_path = getcwd(NULL, 0);
if (repo_path == NULL)
- return got_error_prefix_errno("getcwd");
+ return got_error_from_errno("getcwd");
id_str1 = argv[0];
id_str2 = argv[1];
} else if (argc == 3) {
repo_path = realpath(argv[0], NULL);
if (repo_path == NULL)
- return got_error_prefix_errno2("realpath", argv[0]);
+ return got_error_from_errno2("realpath", argv[0]);
id_str1 = argv[1];
id_str2 = argv[2];
} else
view = view_open(0, 0, 0, 0, TOG_VIEW_DIFF);
if (view == NULL) {
- error = got_error_prefix_errno("view_open");
+ error = got_error_from_errno("view_open");
goto done;
}
error = open_diff_view(view, id1, id2, NULL, &refs, repo);
werase(view->window);
if (asprintf(&line, "commit %s", id_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
free(id_str);
return err;
}
*first_displayed_line - 1 + selected_line, nlines,
blame_complete ? "" : "annotating... ", path) == -1) {
free(id_str);
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
free(id_str);
err = format_line(&wline, &width, line, view->ncols);
line->id = got_object_id_dup(id);
if (line->id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
line->annotated = 1;
}
if (blame->f) {
if (fclose(blame->f) != 0 && err == NULL)
- err = got_error_prefix_errno("fclose");
+ err = got_error_from_errno("fclose");
blame->f = NULL;
}
if (blame->lines) {
goto done;
blame->f = got_opentemp();
if (blame->f == NULL) {
- err = got_error_prefix_errno("got_opentemp");
+ err = got_error_from_errno("got_opentemp");
goto done;
}
err = got_object_blob_dump_to_file(&blame->filesize, &blame->nlines,
blame->lines = calloc(blame->nlines, sizeof(*blame->lines));
if (blame->lines == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
goto done;
}
blame->cb_args.nlines = blame->nlines;
blame->cb_args.commit_id = got_object_id_dup(commit_id);
if (blame->cb_args.commit_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
blame->cb_args.quit = done;
s->blame_complete = 0;
s->path = path;
if (s->path == NULL)
- return got_error_prefix_errno("open_blame_view");
+ return got_error_from_errno("open_blame_view");
s->repo = repo;
s->refs = refs;
s->commit_id = commit_id;
diff_view = view_open(0, 0, 0, begin_x, TOG_VIEW_DIFF);
if (diff_view == NULL) {
got_object_commit_close(commit);
- err = got_error_prefix_errno("view_open");
+ err = got_error_from_errno("view_open");
break;
}
err = open_diff_view(diff_view, pid ? pid->id : NULL,
cwd = getcwd(NULL, 0);
if (cwd == NULL) {
- error = got_error_prefix_errno("getcwd");
+ error = got_error_from_errno("getcwd");
goto done;
}
if (repo_path == NULL) {
repo_path =
strdup(got_worktree_get_repo_path(worktree));
if (repo_path == NULL)
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
if (error)
goto done;
} else {
repo_path = strdup(cwd);
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
}
prefix, (strcmp(prefix, "/") != 0) ? "/" : "",
worktree_subdir, worktree_subdir[0] ? "/" : "",
path) == -1) {
- error = got_error_prefix_errno("asprintf");
+ error = got_error_from_errno("asprintf");
goto done;
}
error = got_repo_map_path(&in_repo_path, repo, p, 0);
view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME);
if (view == NULL) {
- error = got_error_prefix_errno("view_open");
+ error = got_error_from_errno("view_open");
goto done;
}
error = open_blame_view(view, in_repo_path, commit_id, &refs, repo);
if (show_ids) {
err = got_object_id_str(&id_str, te->id);
if (err)
- return got_error_prefix_errno(
+ return got_error_from_errno(
"got_object_id_str");
}
if (asprintf(&line, "%s %s%s", id_str ? id_str : "",
te->name, S_ISDIR(te->mode) ? "/" :
((te->mode & S_IXUSR) ? "*" : "")) == -1) {
free(id_str);
- return got_error_prefix_errno("asprintf");
+ return got_error_from_errno("asprintf");
}
free(id_str);
err = format_line(&wline, &width, line, view->ncols);
*path = calloc(1, len);
if (path == NULL)
- return got_error_prefix_errno("calloc");
+ return got_error_from_errno("calloc");
(*path)[0] = '/';
pt = TAILQ_LAST(parents, tog_parent_trees);
blame_view = view_open(0, 0, 0, begin_x, TOG_VIEW_BLAME);
if (blame_view == NULL)
- return got_error_prefix_errno("view_open");
+ return got_error_from_errno("view_open");
err = open_blame_view(blame_view, path, commit_id, refs, repo);
if (err) {
log_view = view_open(0, 0, 0, begin_x, TOG_VIEW_LOG);
if (log_view == NULL)
- return got_error_prefix_errno("view_open");
+ return got_error_from_errno("view_open");
err = tree_entry_path(&path, parents, te);
if (err)
goto done;
if (asprintf(&s->tree_label, "commit %s", commit_id_str) == -1) {
- err = got_error_prefix_errno("asprintf");
+ err = got_error_from_errno("asprintf");
goto done;
}
s->first_displayed_entry = SIMPLEQ_FIRST(&s->entries->head);
s->commit_id = got_object_id_dup(commit_id);
if (s->commit_id == NULL) {
- err = got_error_prefix_errno("got_object_id_dup");
+ err = got_error_from_errno("got_object_id_dup");
goto done;
}
s->refs = refs;
break;
parent = calloc(1, sizeof(*parent));
if (parent == NULL) {
- err = got_error_prefix_errno("calloc");
+ err = got_error_from_errno("calloc");
break;
}
parent->tree = s->tree;
struct got_worktree *worktree;
char *cwd = getcwd(NULL, 0);
if (cwd == NULL)
- return got_error_prefix_errno("getcwd");
+ return got_error_from_errno("getcwd");
error = got_worktree_open(&worktree, cwd);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
} else
repo_path = cwd;
if (repo_path == NULL) {
- error = got_error_prefix_errno("strdup");
+ error = got_error_from_errno("strdup");
goto done;
}
} else if (argc == 1) {
repo_path = realpath(argv[0], NULL);
if (repo_path == NULL)
- return got_error_prefix_errno2("realpath", argv[0]);
+ return got_error_from_errno2("realpath", argv[0]);
} else
usage_log();
view = view_open(0, 0, 0, 0, TOG_VIEW_TREE);
if (view == NULL) {
- error = got_error_prefix_errno("view_open");
+ error = got_error_from_errno("view_open");
goto done;
}
error = open_tree_view(view, tree, commit_id, &refs, repo);
if (error == NULL)
got_repo_close(repo);
} else
- error = got_error_prefix_errno2("realpath",
+ error = got_error_from_errno2("realpath",
argv[0]);
if (error) {
if (hflag) {