[wiki] [sites] build-page: treat read error as fatal, simplify chdir error handling || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Thu, 03 Jan 2019 13:42:27 +0100

commit 763e91701525df3278d9a6bc7e37826f04d47138
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Thu Jan 3 13:42:01 2019 +0100

    build-page: treat read error as fatal, simplify chdir error handling

diff --git a/build-page.c b/build-page.c
index 52603a5e..386f30a1 100644
--- a/build-page.c
+++ b/build-page.c
_AT_@ -136,6 +136,9 @@ oneline(char *buf, size_t bufsiz, char const *path)
                 return -1;
         }
         r = fgets(buf, bufsiz, fp);
+ if (ferror(fp))
+ die_perror("fgets: %s", path);
+
         fclose(fp);
 
         if (r)
_AT_@ -304,10 +307,8 @@ main(int argc, char *argv[])
         if ((page = strchr(argv[1], '/')))
                 *page++ = ' domain = argv[1];
- if (chdir(domain) == -1) {
- perror(domain);
- return 1;
- }
+ if (chdir(domain) == -1)
+ die_perror("chdir: %s", domain);
 
         print_header(domain, page);
         print_nav_bar(domain, page);
Received on Thu Jan 03 2019 - 13:42:27 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 03 2019 - 13:48:26 CET