aboutsummaryrefslogtreecommitdiffstats
path: root/pipe.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-11-01 22:06:40 +0100
committerMattias Andrée <maandree@kth.se>2019-11-01 22:06:40 +0100
commitc57844b08bced71778f38f2346464c3e0836287c (patch)
treee3733b4c99818ee6c77ed3d4d37becf30f92268f /pipe.c
parentUse installed liberror (diff)
downloadliberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.gz
liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.bz2
liberror-libc-c57844b08bced71778f38f2346464c3e0836287c.tar.xz
Add some functions and add functions with _failed suffix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'pipe.c')
-rw-r--r--pipe.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/pipe.c b/pipe.c
index 3c0fed5..a0cd32f 100644
--- a/pipe.c
+++ b/pipe.c
@@ -2,19 +2,16 @@
#include "internal.h"
-int
-liberror_pipe(int fds[2])
+void
+liberror_pipe_failed(int fds[2])
{
const char *desc;
- if (!fds) {
- desc = "Output parameter is NULL";
- goto error;
- }
- if (!pipe(fds))
- return 0;
switch (errno) {
case EFAULT:
- desc = "Output parameter is an invalid pointer";
+ if (!fds)
+ desc = "Output parameter is NULL";
+ else
+ desc = "Output parameter is an invalid pointer";
break;
case EMFILE:
desc = "The process have too many file descriptors open";
@@ -26,8 +23,17 @@ liberror_pipe(int fds[2])
desc = "";
break;
}
-error:
- liberror_save_backtrace(NULL);
liberror_set_error_errno(desc, "pipe", errno);
+ (void) fds;
+}
+
+
+int
+liberror_pipe(int fds[2])
+{
+ if (!pipe(fds))
+ return 0;
+ liberror_save_backtrace(NULL);
+ liberror_pipe_failed(fds);
return -1;
}