]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
env: cleanup env_list API
authorKarel Zak <kzak@redhat.com>
Wed, 28 Aug 2024 08:24:41 +0000 (10:24 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 4 Sep 2024 11:39:03 +0000 (13:39 +0200)
* rename env_from_fd() to env_list_from_fd()
* rename remove_entry() to ul_remove_entry()

Signed-off-by: Karel Zak <kzak@redhat.com>
include/env.h
lib/env.c
sys-utils/nsenter.c
text-utils/more.c

index d4dde7f224234a597cf09003ed67da78b3406cc3..ba0f670d3a828ce2a05ab36f0f9e76e6bd0e6c6d 100644 (file)
@@ -15,11 +15,9 @@ extern void __sanitize_env(struct ul_env_list **org);
 
 extern struct ul_env_list *env_list_add_variable(struct ul_env_list *ls,
                                const char *name, const char *value);
-
-
 extern int env_list_setenv(struct ul_env_list *ls, int overwrite);
 extern void env_list_free(struct ul_env_list *ls);
-extern struct ul_env_list *env_from_fd(int pid);
+extern struct ul_env_list *env_list_from_fd(int pid);
 
 extern char *safe_getenv(const char *arg);
 
@@ -34,7 +32,7 @@ static inline void xsetenv(char const *name, char const *val, int overwrite)
                err(XSETENV_EXIT_CODE, _("failed to set the %s environment variable"), name);
 }
 
-static inline int remove_entry(char **argv, int remove, int last)
+static inline int ul_remove_entry(char **argv, int remove, int last)
 {
        memmove(argv + remove, argv + remove + 1, sizeof(char *) * (last - remove));
        return last - 1;
index cfc5e3c04e8c80d677c45b0ca74368c00279b310..02c115867851398d0d517d2965314fcce0f1e09b 100644 (file)
--- a/lib/env.c
+++ b/lib/env.c
@@ -121,11 +121,11 @@ struct ul_env_list *env_list_add_variable(
 }
 
 /*
- * Use env_from_fd() to read environment from @fd.
+ * Use env_list_from_fd() to read environment from @fd.
  *
  * @fd must be /proc/<pid>/environ file.
 */
-struct ul_env_list *env_from_fd(int fd)
+struct ul_env_list *env_list_from_fd(int fd)
 {
        char *buf = NULL, *p;
        ssize_t rc = 0;
@@ -189,7 +189,7 @@ void __sanitize_env(struct ul_env_list **org)
                         if (strncmp(*cur, *bad, strlen(*bad)) == 0) {
                                if (org)
                                        *org = env_list_add_from_string(*org, *cur);
-                                last = remove_entry(envp, cur - envp, last);
+                                last = ul_remove_entry(envp, cur - envp, last);
                                 cur--;
                                 break;
                         }
@@ -204,7 +204,7 @@ void __sanitize_env(struct ul_env_list **org)
                                 continue;  /* OK */
                        if (org)
                                *org = env_list_add_from_string(*org, *cur);
-                        last = remove_entry(envp, cur - envp, last);
+                        last = ul_remove_entry(envp, cur - envp, last);
                         cur--;
                         break;
                 }
index d6a50fd95f2aa38fccc4e926bec6250e49cb4353..0f5babaada42cc183f0d8484f6dee4fb8d20caff 100644 (file)
@@ -644,7 +644,7 @@ int main(int argc, char *argv[])
 
        /* Pass environment variables of the target process to the spawned process */
        if (env_fd >= 0) {
-               if ((envls = env_from_fd(env_fd)) == NULL)
+               if ((envls = env_list_from_fd(env_fd)) == NULL)
                        err(EXIT_FAILURE, _("failed to get environment variables"));
                clearenv();
                if (env_list_setenv(envls, 0) < 0)
index 953e94db10ea063ec44d593eb1de049fc36f1408..a8d2ef1766ad01a3a61969fde0961f6ba547d3ba 100644 (file)
@@ -299,7 +299,7 @@ static void argscan(struct more_control *ctl, int as_argc, char **as_argv)
                        }
                }
                if (move) {
-                       as_argc = remove_entry(as_argv, opt, as_argc);
+                       as_argc = ul_remove_entry(as_argv, opt, as_argc);
                        opt--;
                }
        }