aboutsummaryrefslogtreecommitdiffstats
path: root/unsetenv.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 /unsetenv.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 'unsetenv.c')
-rw-r--r--unsetenv.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/unsetenv.c b/unsetenv.c
index 1462618..82eebcb 100644
--- a/unsetenv.c
+++ b/unsetenv.c
@@ -2,23 +2,26 @@
#include "internal.h"
-int
-liberror_unsetenv(const char *name)
+void
+liberror_unsetenv_failed(const char *name)
{
const char *desc = "";
- if (!name) {
- errno = EINVAL;
+ if (!name)
desc = "Environment variable name is NULL";
- goto error;
- } else if (!unsetenv(name)) {
- return 0;
- } else if (!*name) {
+ else if (!*name)
desc = "Environment variable name is the empty string";
- } else if (errno == EINVAL) {
+ else if (errno == EINVAL)
desc = "Environment variable name contains the '=' character";
- }
-error:
- liberror_save_backtrace(NULL);
liberror_set_error_errno(desc, "setenv", errno);
+}
+
+
+int
+liberror_unsetenv(const char *name)
+{
+ if (!unsetenv(name))
+ return 0;
+ liberror_save_backtrace(NULL);
+ liberror_unsetenv_failed(name);
return -1;
}