diff options
author | Mattias Andrée <maandree@kth.se> | 2019-11-01 22:06:40 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-11-01 22:06:40 +0100 |
commit | c57844b08bced71778f38f2346464c3e0836287c (patch) | |
tree | e3733b4c99818ee6c77ed3d4d37becf30f92268f /unsetenv.c | |
parent | Use installed liberror (diff) | |
download | liberror-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.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -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; } |