summaryrefslogtreecommitdiff
path: root/tests/unsetenv.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:50 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:50 +0100
commitff33e1d252f46bec1a33e28700da3282fc24047a (patch)
tree5c15bc695be820b393a8496c5807ecafbbdeb89b /tests/unsetenv.c
parentb2ac982cc8b5290699eb5f52fb043d3d15e2624b (diff)
parent5f59a34ab747dde8ede7357f3431bf06bd6002fe (diff)
Update upstream source from tag 'upstream/1.4.2'
Update to upstream version '1.4.2' with Debian dir 493e96bcd865e4f9990e20bee26408c96231d727
Diffstat (limited to 'tests/unsetenv.c')
-rw-r--r--tests/unsetenv.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/unsetenv.c b/tests/unsetenv.c
index d38ed37a..dab1b90c 100644
--- a/tests/unsetenv.c
+++ b/tests/unsetenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2002, 2005-2025 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2002, 2005-2026 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is free software: you can redistribute it and/or modify
@@ -56,15 +56,13 @@ __libc_lock_define_initialized (static, envlock)
int
unsetenv (const char *name)
{
- size_t len;
-
if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
{
__set_errno (EINVAL);
return -1;
}
- len = strlen (name);
+ size_t len = strlen (name);
#if HAVE_DECL__PUTENV /* native Windows */
/* The Microsoft documentation
@@ -79,14 +77,13 @@ unsetenv (const char *name)
of the form "NAME=". (NB: This is a different convention than with glibc
putenv, which expects a string of the form "NAME"!) */
{
- int putenv_result;
char *name_ = malloc (len + 2);
if (name_ == NULL)
return -1;
memcpy (name_, name, len);
name_[len] = '=';
name_[len + 1] = 0;
- putenv_result = _putenv (name_);
+ int putenv_result = _putenv (name_);
/* In this particular case it is OK to free() the argument passed to
_putenv. */
free (name_);
@@ -138,12 +135,12 @@ extern int unsetenv (const char *);
int
rpl_unsetenv (const char *name)
{
- int result = 0;
if (!name || !*name || strchr (name, '='))
{
errno = EINVAL;
return -1;
}
+ int result = 0;
while (getenv (name))
# if !VOID_UNSETENV
result =