aboutsummaryrefslogtreecommitdiffstats
path: root/src/repo/s6rc_repo_listcontents.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo/s6rc_repo_listcontents.c')
-rw-r--r--src/repo/s6rc_repo_listcontents.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/repo/s6rc_repo_listcontents.c b/src/repo/s6rc_repo_listcontents.c
index bb9a99b..1af3d77 100644
--- a/src/repo/s6rc_repo_listcontents.c
+++ b/src/repo/s6rc_repo_listcontents.c
@@ -19,8 +19,6 @@
int s6rc_repo_listcontents (char const *repo, char const *bundle, stralloc *storage, genalloc *indices)
{
- int swasnull = !storage->s ;
- int gwasnull = !indices->s ;
size_t sabase = storage->len ;
size_t gabase = genalloc_len(size_t, indices) ;
size_t repolen = strlen(repo) ;
@@ -33,37 +31,35 @@ int s6rc_repo_listcontents (char const *repo, char const *bundle, stralloc *stor
memcpy(refdb, repo, repolen) ;
memcpy(refdb + repolen, "/compiled/.ref", 15) ;
pid = child_spawn1_pipe(argv[0], argv, (char const *const *)environ, &fd, 1) ;
- if (!pid) { strerr_warnfu2sys("spawn ", argv[0]) ; return -1 ; }
- if (!slurpn(fd, storage, 0)) { strerr_warnfu2sys("read output from ", argv[0]) ; return -1 ; }
+ if (!pid) { strerr_warnfu2sys("spawn ", argv[0]) ; return 111 ; }
+ if (!slurpn(fd, storage, 0)) { strerr_warnfu2sys("read output from ", argv[0]) ; return 111 ; }
fd_close(fd) ;
- if (wait_pid(pid, &wstat) == -1)
- {
- strerr_warnfu2sys("wait for ", argv[0]) ;
- return -1 ;
- }
+ if (wait_pid(pid, &wstat) == -1) { strerr_warnfu2sys("wait for ", argv[0]) ; return 111 ; }
if (WIFSIGNALED(wstat))
{
char fmt[UINT_FMT] ;
fmt[uint_fmt(fmt, WTERMSIG(wstat))] = 0 ;
strerr_warnf3x(argv[0], " crashed with signal ", fmt) ;
- return -1 ;
+ return wait_estatus(wstat) ;
}
if (WEXITSTATUS(wstat))
{
char fmt[UINT_FMT] ;
fmt[uint_fmt(fmt, WEXITSTATUS(wstat))] = 0 ;
strerr_warnf3x(argv[0], " exited with code ", fmt) ;
- return (WEXITSTATUS(wstat) < 99) - 1 ;
+ return WEXITSTATUS(wstat) ;
}
- if (!string_index(storage->s, sabase, storage->len - sabase, '\n', indices)) goto err ;
+ if (!string_index(storage->s, sabase, storage->len - sabase, '\n', indices))
+ {
+ strerr_warnfu1sys("index result from s6-rc-db") ;
+ goto err ;
+ }
s6rc_repo_removeinternals(indices, gabase, storage->s) ;
- return 1 ;
+ return 0 ;
err:
- if (gwasnull) genalloc_free(size_t, indices) ;
- else genalloc_setlen(size_t, indices, gabase) ;
- if (swasnull) stralloc_free(storage) ;
- else storage->len = sabase ;
- return -1 ;
+ genalloc_setlen(size_t, indices, gabase) ;
+ storage->len = sabase ;
+ return 111 ;
}