]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
env: prefer ptrdiff_t
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 26 Mar 2021 21:56:36 +0000 (14:56 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 26 Mar 2021 22:17:28 +0000 (15:17 -0700)
* src/env.c (usvars_used, vnlen, unset_envvars, expansion)
(build_argv): Prefer ptrdiff_t to size_t when either will do.

src/env.c

index 341777cb8e9fc43d3d4b30af29fe594f915c1564..11db374d97737c0ae29434280cb9edfb2beaf2b5 100644 (file)
--- a/src/env.c
+++ b/src/env.c
 /* Array of envvars to unset.  */
 static const char **usvars;
 static size_t usvars_alloc;
-static size_t usvars_used;
+static ptrdiff_t usvars_used;
 
 /* Annotate the output with extra info to aid the user.  */
 static bool dev_debug;
 
 /* Buffer and length of extracted envvars in -S strings.  */
 static char *varname;
-static size_t vnlen;
+static ptrdiff_t vnlen;
 
 /* Possible actions on each signal.  */
 enum SIGNAL_MODE {
@@ -175,7 +175,7 @@ append_unset_var (const char *var)
 static void
 unset_envvars (void)
 {
-  for (size_t i = 0; i < usvars_used; ++i)
+  for (ptrdiff_t i = 0; i < usvars_used; ++i)
     {
       devmsg ("unset:    %s\n", usvars[i]);
 
@@ -271,11 +271,11 @@ extract_varname (const char *str)
              after ENVVAR expansion (the value is overestimated).
    maxargc - the maximum number of arguments (the size of the new argv).  */
 static void
-validate_split_str (const char *str, size_t *bufsize, int *maxargc)
+validate_split_str (const char *str, ptrdiff_t *bufsize, int *maxargc)
 {
   bool dq, sq, sp;
   const char *pch;
-  size_t buflen;
+  ptrdiff_t buflen;
   int cnt = 1;
 
   dq = sq = sp = false;
@@ -379,7 +379,7 @@ build_argv (const char *str, int extra_argc)
 
   char **newargv, **nextargv;
   int newargc = 0;
-  size_t buflen = 0;
+  ptrdiff_t buflen = 0;
 
   /* This macro is called before inserting any characters to the output
      buffer.  It checks if the previous character was a separator