From 3eb14b975e277c0094be80a0e62c8de42bb80f31 Mon Sep 17 00:00:00 2001 From: jozan Date: Thu, 5 Nov 2020 21:17:14 +0000 Subject: Cleaner FossilOrigin-Name: 03d9d3326460b4854e1c9bf6335c6fefcf4925bd1c0d13c2e1822c74fd6e8964 --- src/c_lfiles.c | 18 +++--------------- src/c_unixize.c | 7 ++----- src/u_utils.c | 14 ++++++++++++++ src/u_utils.h | 1 + 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/c_lfiles.c b/src/c_lfiles.c index f39c330..c39cd02 100644 --- a/src/c_lfiles.c +++ b/src/c_lfiles.c @@ -138,30 +138,18 @@ c_lfiles_gather(void) head = NULL; link = NULL; if (getcwd(path, MAXPATHLEN) == NULL) { - dprintf( - STDERR_FILENO, - "unixize: %s\n", - strerror(errno) - ); + u_dump_errno(); return (NULL); } dirp = opendir(path); if (dirp == NULL) { - dprintf( - STDERR_FILENO, - "unixize: %s\n", - strerror(errno) - ); + u_dump_errno(); return (NULL); } while ((dp = readdir(dirp)) != NULL) { link = c_lfiles_new(dp->d_name, dp->d_type); if (link == NULL) { - dprintf( - STDERR_FILENO, - "unixize: %s\n", - strerror(errno) - ); + u_dump_errno(); c_lfiles_clear(&link); return (NULL); } diff --git a/src/c_unixize.c b/src/c_unixize.c index 85f020f..31bae1b 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -53,6 +53,7 @@ #include "c_lfiles.h" #include "c_opts.h" +#include "u_utils.h" int main @@ -65,11 +66,7 @@ main c_get_opts(&opts, argc, argv); if (chdir((const char*)opts.dir) == -1) { - dprintf( - STDERR_FILENO, - "unixize: %s\n", - strerror(errno) - ); + u_dump_err(); return (1); } og_files = c_lfiles_gather(); diff --git a/src/u_utils.c b/src/u_utils.c index cfaec25..13cb245 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -43,7 +43,11 @@ * 2020-11-05 19:27 */ +#include +#include #include +#include +#include void u_memdel(void** ptr) @@ -51,3 +55,13 @@ u_memdel(void** ptr) free(*ptr); *ptr = NULL; } + +void +u_dump_errno(void) +{ + dprintf( + STDERR_FILENO, + "unixize: %s\n", + strerror(errno) + ); +} diff --git a/src/u_utils.h b/src/u_utils.h index b95fa86..a4568a8 100644 --- a/src/u_utils.h +++ b/src/u_utils.h @@ -44,3 +44,4 @@ */ void u_memdel(void**); +void u_dump_errno(void); -- cgit v1.2.3