diff options
author | Ferass El Hafidi <vitali64pmemail@protonmail.com> | 2023-03-04 22:43:03 +0100 |
---|---|---|
committer | Ferass El Hafidi <vitali64pmemail@protonmail.com> | 2023-03-04 22:43:03 +0100 |
commit | 9c1c188c029f0492a9baf81248a355169bdb2577 (patch) | |
tree | 917390aa39114b3ab354738464e9433441a415b9 | |
parent | 70cfc203beeae805e0c5c6947fd0d36e91fff7d2 (diff) | |
download | fases-9c1c188c029f0492a9baf81248a355169bdb2577.tar.gz fases-9c1c188c029f0492a9baf81248a355169bdb2577.zip |
core/*: Return errprint.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
-rw-r--r-- | core/chmod.c | 4 | ||||
-rw-r--r-- | core/date.c | 6 | ||||
-rw-r--r-- | core/dirname.c | 4 | ||||
-rw-r--r-- | core/echo.c | 6 | ||||
-rw-r--r-- | core/ed.c | 2 | ||||
-rw-r--r-- | core/head.c | 2 | ||||
-rw-r--r-- | core/more.c | 2 | ||||
-rw-r--r-- | core/printf.c | 4 | ||||
-rw-r--r-- | core/sleep.c | 4 | ||||
-rw-r--r-- | core/tail.c | 2 | ||||
-rw-r--r-- | core/touch.c | 2 | ||||
-rw-r--r-- | core/tty.c | 2 | ||||
-rw-r--r-- | core/uname.c | 2 |
13 files changed, 29 insertions, 13 deletions
diff --git a/core/chmod.c b/core/chmod.c index 8fe0618..b6b51fb 100644 --- a/core/chmod.c +++ b/core/chmod.c @@ -4,8 +4,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ +#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ #define DESCRIPTION "Change file modes." #define OPERANDS "mode file" #include "../common/common.h" @@ -86,5 +88,5 @@ int main(int argc, char *const argv[]) { } chmod(argv[1], owner_modes | group_modes | other_modes); - return 0; + return errprint(argv[0], "chmod()", errno); } diff --git a/core/date.c b/core/date.c index 3ea3f92..a5c1469 100644 --- a/core/date.c +++ b/core/date.c @@ -1,6 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause */ #include <time.h> #include <stdio.h> +#include <errno.h> + +#define REQ_ERRPRINT +#include "../common/common.h" int main(int argc, char *argv[]) { time_t epoch = time(NULL); @@ -16,5 +20,5 @@ int main(int argc, char *argv[]) { } strftime(date_s, 31, format, date); printf("%s\n", date_s); - return 0; + return errprint(argv[0], NULL, errno); } diff --git a/core/dirname.c b/core/dirname.c index 3810f07..b4ff098 100644 --- a/core/dirname.c +++ b/core/dirname.c @@ -4,8 +4,10 @@ #include <stdlib.h> #include <string.h> #include <libgen.h> +#include <errno.h> #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ +#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ #define DESCRIPTION "Return directory portion of <string>." #define OPERANDS "string" #include "../common/common.h" @@ -20,5 +22,5 @@ int main(int argc, char *argv[]) { dirnamestr = dirname(argv[1]); printf("%s\n", dirnamestr); - return 0; + return errprint(argv[0], NULL, errno); } diff --git a/core/echo.c b/core/echo.c index e61c21d..fe5642e 100644 --- a/core/echo.c +++ b/core/echo.c @@ -1,6 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause */ #include <unistd.h> #include <stdio.h> +#include <errno.h> + +#define REQ_ERRPRINT +#include "../common/common.h" int main(int argc, char *const argv[]) { int i = 1; @@ -9,5 +13,5 @@ int main(int argc, char *const argv[]) { printf("%s ", argv[i]); } printf("\n"); - return 0; + return errprint(argv[0], NULL, errno); } @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) { continue; case 'q': if (fildes) close(fildes); - return 0; + return errprint(argv0, NULL, errno); case 'H': /* Help mode */ if (i < 0) { print_error((error = "unexpected address"), help_mode); diff --git a/core/head.c b/core/head.c index 1a49819..1b0d87b 100644 --- a/core/head.c +++ b/core/head.c @@ -44,5 +44,5 @@ int main(int argc, char *const argv[]) { if (file != stdin) fclose(file); if (argc == 0) return 0; /* TODO: Remove this stupid hack. */ } - return 0; + return errprint(argv0, NULL, errno); } diff --git a/core/more.c b/core/more.c index ff25abe..462ab10 100644 --- a/core/more.c +++ b/core/more.c @@ -82,5 +82,5 @@ int main(int argc, char *const argv[]) { break; } } - return 0; + return errprint(argv0, NULL, errno); } diff --git a/core/printf.c b/core/printf.c index c830b1d..b0c0d77 100644 --- a/core/printf.c +++ b/core/printf.c @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause */ #include <unistd.h> #include <stdio.h> +#include <errno.h> #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ +#define REQ_ERRPRINT /* Require print_usage() from ../common/common.h */ #define DESCRIPTION "Write formatted strings to standard output." #define OPERANDS "format [string]" #include "../common/common.h" @@ -13,5 +15,5 @@ int main(int argc, char *const argv[]) { return 1; } printf(argv[1], argv[2] ? argv[2] : ""); - return 0; + return errprint(argv[0], NULL, errno); } diff --git a/core/sleep.c b/core/sleep.c index abe9f68..e331738 100644 --- a/core/sleep.c +++ b/core/sleep.c @@ -2,8 +2,10 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <errno.h> #define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ +#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ #define DESCRIPTION "Suspend execution for an interval." #define OPERANDS "time" #include "../common/common.h" @@ -24,5 +26,5 @@ int main(int argc, char *argv[]) { return 1; } - return 0; + return errprint(argv[0], NULL, errno); } diff --git a/core/tail.c b/core/tail.c index 68257a3..38694e6 100644 --- a/core/tail.c +++ b/core/tail.c @@ -52,5 +52,5 @@ int main(int argc, char *const argv[]) { } } - return 0; + return errprint(argv0, NULL, errno); } diff --git a/core/touch.c b/core/touch.c index 625a321..a80efe8 100644 --- a/core/touch.c +++ b/core/touch.c @@ -78,5 +78,5 @@ int main(int argc, char *argv[]) { utimensat(AT_FDCWD, argv[i], times, 0); else if (errno != ENOENT) return errprint(argv0, argv[i], errno); } - return 0; + return errprint(argv0, NULL, errno); } @@ -17,5 +17,5 @@ int main(int, char *argv[]) { return 1; } else if (errno) return errprint(argv[0], NULL, errno); printf("%s\n", terminalname); - return 0; + return errprint(argv[0], NULL, errno); } diff --git a/core/uname.c b/core/uname.c index 2010821..92e9a23 100644 --- a/core/uname.c +++ b/core/uname.c @@ -41,5 +41,5 @@ int main(int argc, char *const argv[]) { if (param['m']) printf("%s", name.machine); if (argc == 0) printf("%s ", name.sysname); printf("\n"); - return 0; + return errprint(argv0, NULL, errno); } |