aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerass El Hafidi <vitali64pmemail@protonmail.com>2023-03-04 22:43:03 +0100
committerFerass El Hafidi <vitali64pmemail@protonmail.com>2023-03-04 22:43:03 +0100
commit9c1c188c029f0492a9baf81248a355169bdb2577 (patch)
tree917390aa39114b3ab354738464e9433441a415b9
parent70cfc203beeae805e0c5c6947fd0d36e91fff7d2 (diff)
downloadfases-9c1c188c029f0492a9baf81248a355169bdb2577.tar.gz
fases-9c1c188c029f0492a9baf81248a355169bdb2577.zip
core/*: Return errprint.
Signed-off-by: Ferass El Hafidi <vitali64pmemail@protonmail.com>
-rw-r--r--core/chmod.c4
-rw-r--r--core/date.c6
-rw-r--r--core/dirname.c4
-rw-r--r--core/echo.c6
-rw-r--r--core/ed.c2
-rw-r--r--core/head.c2
-rw-r--r--core/more.c2
-rw-r--r--core/printf.c4
-rw-r--r--core/sleep.c4
-rw-r--r--core/tail.c2
-rw-r--r--core/touch.c2
-rw-r--r--core/tty.c2
-rw-r--r--core/uname.c2
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);
}
diff --git a/core/ed.c b/core/ed.c
index a5e27f4..36cf24e 100644
--- a/core/ed.c
+++ b/core/ed.c
@@ -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);
}
diff --git a/core/tty.c b/core/tty.c
index 2e663e1..6b85e2f 100644
--- a/core/tty.c
+++ b/core/tty.c
@@ -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);
}