commit - 718b3ab0e353c4ccb510b0ec9c3673b1c9a7344e
commit + 0a585a0d6446ac47834148d4071c8374ffc15bc2
blob - 176c6094f97ba96eef191fd7cce0f0fb50a415f8
blob + 40c422e336c4d5c0b4b5787d84c0659f5b64eb5b
--- got/got.c
+++ got/got.c
if (dotgit)
*dotgit = '\0';
if (asprintf(&worktree_path, "%s/%s", cwd, base) == -1) {
+ error = got_error_from_errno();
free(cwd);
- return got_error(GOT_ERR_NO_MEM);
+ return error;
}
free(cwd);
} else if (argc == 2) {
repo_path = argv[0];
worktree_path = strdup(argv[1]);
if (worktree_path == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
} else
usage_checkout();
entry = calloc(1, sizeof(*entry));
if (entry == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
entry->id = got_object_id_dup(root_id);
if (entry->id == NULL) {
+ err = got_error_from_errno();
free(entry);
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
entry->commit = root_commit;
TAILQ_INSERT_HEAD(&commits, entry, entry);
pentry = calloc(1, sizeof(*pentry));
if (pentry == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
got_object_commit_close(pcommit);
break;
}
pentry->id = got_object_id_dup(pid->id);
if (pentry->id == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
got_object_commit_close(pcommit);
break;
}
blob - 0d03e126ff7964bff61f602b55e570eb2f97f80e
blob + ad4669b8af10e9550be1ac1e704c3103fe2a4717
--- include/got_error.h
+++ include/got_error.h
*/
/* Error codes */
-#define GOT_ERR_ERRNO 0
-#define GOT_ERR_NO_MEM 1
+#define GOT_ERR_OK 0
+#define GOT_ERR_ERRNO 1
#define GOT_ERR_NOT_GIT_REPO 2
#define GOT_ERR_NOT_ABSPATH 3
#define GOT_ERR_BAD_PATH 4
int code;
const char *msg;
} got_errors[] = {
+ { GOT_ERR_OK, "no error occured?!?" },
{ GOT_ERR_ERRNO, "see errno" },
- { GOT_ERR_NO_MEM, "out of memory" },
{ GOT_ERR_NOT_GIT_REPO, "no git repository found" },
{ GOT_ERR_NOT_ABSPATH, "absolute path expected" },
{ GOT_ERR_BAD_PATH, "bad path" },
blob - 2fdd381ceed1dd1ccdb46640879c87952edbd56e
blob + c20c1b37c4bb7b60227b956fd033fecaa0c99a90
--- lib/diffreg.c
+++ lib/diffreg.c
goto closem;
}
if (prepare(ds, 0, f1, ds->stb1.st_size, flags)) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
if (prepare(ds, 1, f2, ds->stb2.st_size, flags)) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
equiv(ds->sfile[0], ds->slen[0], ds->sfile[1], ds->slen[1], ds->member);
ds->member = reallocarray(ds->member, ds->slen[1] + 2, sizeof(*ds->member));
if (ds->member == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
ds->class = (int *)ds->file[0];
if (unsort(ds->sfile[0], ds->slen[0], ds->class)) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
ds->class = reallocarray(ds->class, ds->slen[0] + 2, sizeof(*ds->class));
if (ds->class == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
ds->klist = calloc(ds->slen[0] + 2, sizeof(*ds->klist));
if (ds->klist == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
ds->clen = 0;
ds->clistlen = 100;
ds->clist = calloc(ds->clistlen, sizeof(*ds->clist));
if (ds->clist == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
i = stone(ds, ds->class, ds->slen[0], ds->member, ds->klist, flags);
- free(ds->member);
- free(ds->class);
- if (i < 0) {
- err = got_error(GOT_ERR_NO_MEM);
+ if (i < 0) {
+ err = got_error_from_errno();
+ free(ds->member);
+ free(ds->class);
goto closem;
}
+ free(ds->member);
+ free(ds->class);
ds->J = reallocarray(ds->J, ds->len[0] + 2, sizeof(*ds->J));
if (ds->J == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
unravel(ds, ds->klist[i]);
ds->ixold = reallocarray(ds->ixold, ds->len[0] + 2, sizeof(*ds->ixold));
if (ds->ixold == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
ds->ixnew = reallocarray(ds->ixnew, ds->len[1] + 2, sizeof(*ds->ixnew));
if (ds->ixnew == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto closem;
}
check(ds, f1, f2, flags);
if (output(outfile, ds, args, args->label[0], f1, args->label[1], f2,
flags))
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
closem:
if (ds->anychange) {
args->status |= 1;
blob - 6c2d120fdfd7717d4ea98634d7730201bdf56fd3
blob + 6511dec1ab084d3e840d1133d5f07de1af53674e
--- lib/fileindex.c
+++ lib/fileindex.c
*entry = calloc(1, sizeof(**entry));
if (*entry == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*entry)->path = strdup(relpath);
if ((*entry)->path == NULL) {
+ const struct got_error *err = got_error_from_errno();
free(*entry);
*entry = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
(*entry)->ctime_sec = sb.st_ctime;
blob - 7037325a47c164cee43c0303029705ceb1a19f7a
blob + 7f38f5a672366753baf1915c00cc6a8d37a515e4
--- lib/object.c
+++ lib/object.c
*outbuf = calloc(1, len);
if (*outbuf == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
free(*outbuf);
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*obj)->type = type;
(*obj)->hdrlen = hdrlen;
(*obj)->size = size;
buf = calloc(zbsize, sizeof(char));
if (buf == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
err = got_inflate_init(&zb, NULL, zbsize);
if (err)
if (strchr(zb.outbuf, '\0') == NULL) {
buf = recallocarray(buf, 1 + i, 2 + i, zbsize);
if (buf == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
}
char *path_objects = got_repo_get_path_objects(repo);
if (path_objects == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
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(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
free(hex);
free(path_objects);
*commit = calloc(1, sizeof(**commit));
if (*commit == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*commit)->tree_id = calloc(1, sizeof(*(*commit)->tree_id));
if ((*commit)->tree_id == NULL) {
+ err = got_error_from_errno();
free(*commit);
*commit = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
SIMPLEQ_INIT(&(*commit)->parent_ids);
pid = calloc(1, sizeof(*pid));
if (pid == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
pid->id = calloc(1, sizeof(*pid->id));
if (pid->id == NULL) {
+ err = got_error_from_errno();
free(pid);
- err = got_error(GOT_ERR_NO_MEM);
goto done;
}
s += tlen;
*p = '\0';
(*commit)->author = strdup(s);
if ((*commit)->author == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
s += strlen((*commit)->author) + 1;
*p = '\0';
(*commit)->committer = strdup(s);
if ((*commit)->committer == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
s += strlen((*commit)->committer) + 1;
(*commit)->logmsg = strndup(s, remain);
if ((*commit)->logmsg == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
done:
*te = calloc(1, sizeof(**te));
if (*te == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*te)->id = calloc(1, sizeof(*(*te)->id));
if ((*te)->id == NULL) {
+ err = got_error_from_errno();
free(*te);
*te = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
*elen = strlen(buf) + 1;
space = strchr(buf, ' ');
if (space == NULL) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
free(*te);
*te = NULL;
- return got_error(GOT_ERR_BAD_OBJ_DATA);
+ return err;
}
while (*p != ' ') {
if (*p < '0' && *p > '7') {
*tree = calloc(1, sizeof(**tree));
if (*tree == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
SIMPLEQ_INIT(&(*tree)->entries);
buf = calloc(1, blocksize);
if (buf == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
remain = blocksize;
total = 0;
uint8_t *newbuf;
newbuf = reallocarray(buf, 1, total + blocksize);
if (newbuf == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
buf = newbuf;
*blob = calloc(1, sizeof(**blob));
if (*blob == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
if (obj->flags & GOT_OBJ_FLAG_PACKED) {
(*blob)->read_buf = calloc(1, blocksize);
if ((*blob)->read_buf == NULL) {
+ err = got_error_from_errno();
free(*blob);
*blob = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
err = got_packfile_extract_object(&((*blob)->f), obj, repo);
if (err) {
blob - 13400cde614412fa2c8db10001786781d672f8d8
blob + f9c3ce7964f9b871111c17a917f1e3348cae9ea3
--- 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(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
if (stat(path_pack, &sb) != 0) {
free(path_pack);
p = calloc(1, sizeof(*p));
if (p == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
p->sorted_ids = calloc(nobj, sizeof(*p->sorted_ids));
if (p->sorted_ids == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
p->crc32 = calloc(nobj, sizeof(*p->crc32));
if (p->crc32 == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
p->offsets = calloc(nobj, sizeof(*p->offsets));
if (p->offsets == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
p->large_offsets = calloc(nobj, sizeof(*p->large_offsets));
if (p->large_offsets == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
*idx = get_object_idx(repo->packidx_cache[i], id);
if (*idx != -1) {
*packidx = repo->packidx_cache[i];
- if (*packidx == NULL)
- return got_error(GOT_ERR_NO_MEM);
return NULL;
}
}
path_packdir = got_repo_get_path_objects_pack(repo);
if (path_packdir == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
packdir = opendir(path_packdir);
if (packdir == NULL) {
if (asprintf(&path_packidx, "%s/%s", path_packdir,
dent->d_name) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
path_packdir = got_repo_get_path_objects_pack(repo);
if (path_packdir == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
sha1str = got_sha1_digest_to_str(packidx->trailer.packfile_sha1,
hex, sizeof(hex));
if (asprintf(path_packfile, "%s/%s%s%s", path_packdir,
GOT_PACK_PREFIX, sha1str, GOT_PACKFILE_SUFFIX) == -1) {
*path_packfile = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
}
return NULL;
pack->path_packfile = strdup(path_packfile);
if (pack->path_packfile == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
{
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*obj)->path_packfile = strdup(path_packfile);
if ((*obj)->path_packfile == NULL) {
+ const struct got_error *err = got_error_from_errno();
free(*obj);
*obj = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
(*obj)->type = type;
delta_type, delta_size, delta_data_offset, delta_buf,
delta_len);
if (delta == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
/* delta is freed in got_object_close() */
deltas->nentries++;
SIMPLEQ_INSERT_HEAD(&deltas->entries, delta, entry);
*obj = calloc(1, sizeof(**obj));
if (*obj == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*obj)->flags = 0;
(*obj)->hdrlen = 0;
(*obj)->path_packfile = strdup(path_packfile);
if ((*obj)->path_packfile == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
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(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
} else {
base_file = got_opentemp();
if (base_file == NULL)
uint8_t *p;
p = reallocarray(base_buf, 1, max_size);
if (p == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
base_buf = p;
return err;
accum_buf = malloc(max_size);
if (accum_buf == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
/* Deltas are ordered in ascending order. */
SIMPLEQ_FOREACH(delta, &deltas->entries, entry) {
uint8_t *p;
p = reallocarray(base_buf, 1, max_size);
if (p == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
base_buf = p;
blob - ddd0a1e67d31a851c76efbed97aea073100c7c67
blob + 8f96a5ac2f50abfaf71dbecfc5616812983db43a
--- lib/path.c
+++ lib/path.c
*count = 0;
if (s == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
do {
p = strsep(&s, "/");
if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
*path = NULL;
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
}
fd = mkstemp(*path);
blob - 07d6b874c947c74d3665545cea5b355672bb3220
blob + fd179690cf9795fbf834b926133053006ed3847d
--- lib/refs.c
+++ lib/refs.c
symref_name = strdup(name);
if (symref_name == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
symref_ref = strdup(line);
if (symref_ref == NULL) {
+ const struct got_error *err = got_error_from_errno();
free(symref_name);
- return got_error(GOT_ERR_NO_MEM);
+ return err;
}
*ref = calloc(1, sizeof(**ref));
if (*ref == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*ref)->flags |= GOT_REF_IS_SYMBOLIC;
symref = &((*ref)->ref.symref);
symref->name = symref_name;
ref_name = strdup(name);
if (ref_name == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
if (!got_parse_sha1_digest(digest, line))
return got_error(GOT_ERR_NOT_REF);
*ref = calloc(1, sizeof(**ref));
if (*ref == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
(*ref)->ref.ref.name = ref_name;
memcpy(&(*ref)->ref.ref.sha1, digest, SHA1_DIGEST_LENGTH);
return NULL;
char *path_refs = get_refs_dir_path(repo, refname);
if (path_refs == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
/* XXX For now, this assumes that refs exist in the filesystem. */
if (asprintf(&path_ref, "%s/%s", path_refs, refname) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
*id = calloc(1, sizeof(**id));
if (*id == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
memcpy((*id)->sha1, ref->ref.ref.sha1, SHA1_DIGEST_LENGTH);
return NULL;
}
blob - 9dea7fe71449e02beed91b0051eb9da34de1a42e
blob + 086900f78bedad14dd2f6881c2e8949f43b8a9cc
--- lib/repository.c
+++ lib/repository.c
repo = calloc(1, sizeof(*repo));
if (repo == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
repo->path_git_dir = strdup(repo->path);
if (repo->path_git_dir == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (!is_git_repo(repo)) {
free(repo->path_git_dir);
if (asprintf(&repo->path_git_dir, "%s/%s", repo->path,
GOT_GIT_DIR) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (!is_git_repo(repo)) {
blob - 63c5da80f96650880e5a9b02c0efadd40d22d9c3
blob + 80b9f971f82e444c5e97fda10624390229449f99
--- lib/worktree.c
+++ lib/worktree.c
ssize_t n;
if (asprintf(&path, "%s/%s", path_got, name) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
path = NULL;
goto done;
}
*content = NULL;
if (asprintf(&path, "%s/%s", path_got, name) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
path = NULL;
goto done;
}
stat(path, &sb);
*content = calloc(1, sb.st_size);
if (*content == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (!got_path_is_absolute(prefix)) {
if (asprintf(&absprefix, "/%s", prefix) == -1)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
}
/* Create top-level directory (may already exist). */
/* Create .got directory (may already exist). */
if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (mkdir(path_got, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
/* Write the HEAD reference. */
refstr = got_ref_to_str(head_ref);
if (refstr == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
err = create_meta_file(path_got, GOT_WORKTREE_HEAD, refstr);
/* Store path to repository. */
repo_path = got_repo_get_path(repo);
if (repo_path == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
err = create_meta_file(path_got, GOT_WORKTREE_REPOSITORY, repo_path);
/* Stamp work tree with format file. */
if (asprintf(&formatstr, "%d", GOT_WORKTREE_FORMAT_VERSION) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
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(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
path_got = NULL;
goto done;
}
if (asprintf(&path_lock, "%s/%s", path_got, GOT_WORKTREE_LOCK) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
path_lock = NULL;
goto done;
}
*worktree = calloc(1, sizeof(**worktree));
if (*worktree == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
(*worktree)->lockfd = -1;
(*worktree)->root_path = strdup(path);
if ((*worktree)->root_path == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
err = read_meta_file(&(*worktree)->repo_path, path_got,
if (asprintf(&ondisk_path, "%s/%s", worktree->root_path,
apply_path_prefix(worktree, path)) == -1)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
fd = open(ondisk_path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
GOT_DEFAULT_FILE_MODE);
if (asprintf(&abspath, "%s/%s", worktree->root_path,
apply_path_prefix(worktree, path)) == -1)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
/* XXX queue work rather than editing disk directly? */
if (mkdir(abspath, GOT_DEFAULT_DIR_MODE) == -1) {
if (parent[0] == '/' && parent[1] == '\0')
parent = "";
if (asprintf(&path, "%s/%s", parent, te->name) == -1)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
/* Skip this entry if it is outside of our path prefix. */
len = MIN(strlen(worktree->path_prefix), strlen(path));
fileindex = got_fileindex_open();
if (fileindex == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (asprintf(&fileindex_path, "%s/%s/%s", worktree->root_path,
GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
fileindex_path = NULL;
goto done;
}
blob - 9024264945ebfbe8bb734400daa2cc59cb0f4b2a
blob + 93279f0bf680a472e0cb41a40a8d532c98c55778
--- lib/zbuf.c
+++ lib/zbuf.c
zb->inbuf = calloc(1, zb->inlen);
if (zb->inbuf == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
if (outbuf == NULL) {
zb->outbuf = calloc(1, zb->outlen);
if (zb->outbuf == NULL) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
goto done;
}
zb->flags |= GOT_ZSTREAM_F_OWN_OUTBUF;
*outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE);
if (*outbuf == NULL)
- return got_error(GOT_ERR_NO_MEM);
+ return got_error_from_errno();
err = got_inflate_init(&zb, *outbuf, GOT_ZSTREAM_BUFSIZE);
if (err)
return err;
newbuf = reallocarray(*outbuf, 1,
*outlen + GOT_ZSTREAM_BUFSIZE);
if (newbuf == NULL) {
+ err = got_error_from_errno();
free(*outbuf);
*outbuf = NULL;
*outlen = 0;
- err = got_error(GOT_ERR_NO_MEM);
goto done;
}
*outbuf = newbuf;
blob - 6f6b30cdc1b2834f1e57dff4822ac9c4b05dd250
blob + d822baa5771cc1ed7cc4de41a1385a96bf47e34e
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
}
if (asprintf(&next_parent, "%s/%s", parent, te->name) == -1) {
- err = got_error(GOT_ERR_NO_MEM);
+ err = got_error_from_errno();
got_object_close(treeobj);
break;
}