commit f54c4c24c918de10964c89c400b6552516bb0069 from: Stefan Sperling date: Fri Feb 08 11:18:15 2019 UTC get rid of xmalloc and a global declaration in worklist code commit - d947271fda9c2c8d82ecb1fd8693fb0f4f6cb1da commit + f54c4c24c918de10964c89c400b6552516bb0069 blob - 4dd70040f303660e558e4a7e2642facf5201f746 blob + 76ce96aa12df9c6519f2f358e39234f59bb9be64 --- lib/worklist.c +++ lib/worklist.c @@ -29,32 +29,36 @@ #include #include #include +#include #include #include #include "worklist.h" -#include "xmalloc.h" +#include "got_error.h" /* * adds a path to a worklist. */ -void +const struct got_error * worklist_add(const char *path, struct wklhead *worklist) { size_t len; struct worklist *wkl; sigset_t old, new; - wkl = xcalloc(1, sizeof(*wkl)); + wkl = calloc(1, sizeof(*wkl)); + if (wkl == NULL) + return got_error_from_errno(); len = strlcpy(wkl->wkl_path, path, sizeof(wkl->wkl_path)); if (len >= sizeof(wkl->wkl_path)) - errx(1, "path truncation in worklist_add"); + return got_error(GOT_ERR_NO_SPACE); sigfillset(&new); sigprocmask(SIG_BLOCK, &new, &old); SLIST_INSERT_HEAD(worklist, wkl, wkl_list); sigprocmask(SIG_SETMASK, &old, NULL); + return NULL; } /* blob - cf833e8580b2166a59813087f96dbbb6f081cf01 blob + bb596178909cc2e981c297f5208f629d2327227f --- lib/worklist.h +++ lib/worklist.h @@ -37,12 +37,10 @@ struct worklist { SLIST_HEAD(wklhead, worklist); -void worklist_add(const char *, struct wklhead *); +const struct got_error *worklist_add(const char *, struct wklhead *); void worklist_run(struct wklhead *, void (*cb)(struct worklist *)); void worklist_clean(struct wklhead *, void (*cb)(struct worklist *)); void worklist_unlink(struct worklist *); -extern struct wklhead temp_files; - #endif