From 8bae98406fcf2ce815186a265084a09afd72b94c Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 20 Apr 2010 21:19:29 +0100 Subject: [PATCH] replace most calls to unlink/sysdie with xunlink --- backends/innduct.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/backends/innduct.c b/backends/innduct.c index 27fba90..9fcd2ff 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -382,6 +382,11 @@ static int xwaitpid(pid_t *pid, const char *what) { return status; } +static void xunlink(const char *path, const char *what) { + int r= unlink(path); + if (r) sysdie("can't unlink %s %s", path, what); +} + static void check_isreg(const struct stat *stab, const char *path, const char *what) { if (!S_ISREG(stab->st_mode)) @@ -1198,8 +1203,7 @@ typedef void *feedfile_got_article(oop_source *lp, oop_read *rd, if (r) sysdie("link feedfile %s to flushing file %s", feedfile, dut_path); /* => Hardlinked */ - r= unlink(feedfile); - if (r) sysdie("unlink old feedfile link %s", feedfile); + xunlink(feedfile, "old feedfile link"); /* => Moved */ spawn_inndcomm_flush(); /* => Flushing, sets sms to sm_FLUSHING */ @@ -1545,9 +1549,8 @@ static void statemc_init(void) { open_defer(); /* so that we will later close it and rename it */ break; case 2: - if (unlink(path_defer)) - sysdie("could not unlink stale defer file link %s (presumably" - " hardlink to backlog file)", path_defer); + xunlink(path_defer, "stale defer file link" + " (presumably hardlink to backlog file)"); break; default: die("defer file %s has unexpected link count %d", @@ -1572,8 +1575,7 @@ static void statemc_init(void) { if (samefile(&stab_d, &stab_f)) { debug("startup: F==D => Hardlinked"); - r= unlink(path_flushing); - if (r) sysdie("unlink feed file %s during startup", feedfile); + xunlink(path_flushing, "feed file (during startup)"); found_moved: debug(" => Moved"); startup_set_input_file(file_d); @@ -1652,8 +1654,7 @@ static void *statemc_check_input_done(oop_source *lp, close_defer(); - if (unlink(path_flushing)) - sysdie("could not unlink old flushing file %s", path_flushing); + xunlink(path_flushing, "old flushing file"); if (sms==sm_DROPPING) { if (search_backlog_file()) { @@ -1661,8 +1662,7 @@ static void *statemc_check_input_done(oop_source *lp, return; } notice("feed dropped and our work is complete"); - r= unlink(path_lock); - if (r) sysdie("unlink lockfile for old feed %s", path_lock); + xunlink(path_lock, "lockfile for old feed"); exit(0); } -- 2.30.2