about summary refs log tree commit diff
path: root/src/skaembutils
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-07 21:43:42 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-07 21:43:42 +0000
commit1ddf95240c77ae0786dd29e14acdf3549be9094c (patch)
treeebff87b299cb9fec7a841c03ac13e54a9f165952 /src/skaembutils
parent1a5f11e0cf9e5287a50f032838e787c38003a1a4 (diff)
downloads6-portable-utils-1ddf95240c77ae0786dd29e14acdf3549be9094c.tar.gz
s6-portable-utils-1ddf95240c77ae0786dd29e14acdf3549be9094c.tar.xz
s6-portable-utils-1ddf95240c77ae0786dd29e14acdf3549be9094c.zip
Types fix: first pass
 Preparation for the skalibs size_t API change.
Diffstat (limited to 'src/skaembutils')
-rw-r--r--src/skaembutils/s6-basename.c3
-rw-r--r--src/skaembutils/s6-chmod.c1
-rw-r--r--src/skaembutils/s6-chown.c22
-rw-r--r--src/skaembutils/s6-cut.c21
-rw-r--r--src/skaembutils/s6-dumpenv.c4
-rw-r--r--src/skaembutils/s6-expr.c41
-rw-r--r--src/skaembutils/s6-false.c2
-rw-r--r--src/skaembutils/s6-grep.c9
-rw-r--r--src/skaembutils/s6-head.c19
-rw-r--r--src/skaembutils/s6-ln.c4
-rw-r--r--src/skaembutils/s6-mkdir.c2
-rw-r--r--src/skaembutils/s6-printenv.c2
-rw-r--r--src/skaembutils/s6-quote-filter.c5
-rw-r--r--src/skaembutils/s6-quote.c5
-rw-r--r--src/skaembutils/s6-seq.c5
-rw-r--r--src/skaembutils/s6-sort.c20
-rw-r--r--src/skaembutils/s6-tail.c19
-rw-r--r--src/skaembutils/s6-unquote-filter.c11
-rw-r--r--src/skaembutils/s6-unquote.c7
-rw-r--r--src/skaembutils/s6-update-symlinks.c20
20 files changed, 114 insertions, 108 deletions
diff --git a/src/skaembutils/s6-basename.c b/src/skaembutils/s6-basename.c
index 113e14b..6ca6217 100644
--- a/src/skaembutils/s6-basename.c
+++ b/src/skaembutils/s6-basename.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/allreadwrite.h>
 #include <skalibs/bytestr.h>
@@ -33,7 +34,7 @@ int main (int argc, char const *const *argv)
     strerr_diefu2sys(111, "get basename of ", argv[0]) ;
   if (argc >= 2)
   {
-    unsigned int n = str_len(argv[1]) ;
+    size_t n = str_len(argv[1]) ;
     if ((n < sa.len) && !byte_diff(argv[1], n, sa.s + sa.len - n))
       sa.len -= n ;
   }
diff --git a/src/skaembutils/s6-chmod.c b/src/skaembutils/s6-chmod.c
index 9cf6f80..95f350f 100644
--- a/src/skaembutils/s6-chmod.c
+++ b/src/skaembutils/s6-chmod.c
@@ -1,6 +1,5 @@
 /* ISC license. */
 
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <skalibs/uint.h>
 #include <skalibs/strerr2.h>
diff --git a/src/skaembutils/s6-chown.c b/src/skaembutils/s6-chown.c
index ef6a4a0..02b7ca7 100644
--- a/src/skaembutils/s6-chown.c
+++ b/src/skaembutils/s6-chown.c
@@ -3,6 +3,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <skalibs/sgetopt.h>
+#include <skalibs/uint64.h>
+#include <skalibs/gidstuff.h>
 #include <skalibs/uint.h>
 #include <skalibs/strerr2.h>
 #include <skalibs/djbunix.h>
@@ -11,7 +13,8 @@
 
 int main (int argc, char const *const *argv, char const *const *envp)
 {
-  int uid = -1, gid = -1 ;
+  uid_t uid = -1 ;
+  gid_t gid = -1 ;
   PROG = "s6-chown" ;
   {
     subgetopt_t l = SUBGETOPT_ZERO ;
@@ -23,29 +26,26 @@ int main (int argc, char const *const *argv, char const *const *envp)
       {
         case 'u':
         {
-          unsigned int u ;
-          if (!uint0_scan(l.arg, &u)) strerr_dieusage(100, USAGE) ;
+          uint64 u ;
+          if (!uint640_scan(l.arg, &u)) strerr_dieusage(100, USAGE) ;
           uid = u ;
           break ;
         }
         case 'g':
         {
-          unsigned int g ;
-          if (!uint0_scan(l.arg, &g)) strerr_dieusage(100, USAGE) ;
-          gid = g ;
+          if (!gid0_scan(l.arg, &gid)) strerr_dieusage(100, USAGE) ;
           break ;
         }
         case 'U':
         {
-          unsigned int x ;
+          uint64 u ;
           char const *s = env_get2(envp, "UID") ;
           if (!s) strerr_dienotset(100, "UID") ;
-          if (!uint0_scan(s, &x)) strerr_dieinvalid(100, "UID") ;
-          uid = x ;
+          if (!uint640_scan(s, &u)) strerr_dieinvalid(100, "UID") ;
+          uid = u ;
           s = env_get2(envp, "GID") ;
           if (!s) strerr_dienotset(100, "GID") ;
-          if (!uint0_scan(s, &x)) strerr_dieinvalid(100, "GID") ;
-          gid = x ;
+          if (!gid0_scan(s, &gid)) strerr_dieinvalid(100, "GID") ;
           break ;
         }
         default : strerr_dieusage(100, USAGE) ;
diff --git a/src/skaembutils/s6-cut.c b/src/skaembutils/s6-cut.c
index bb729d0..d843222 100644
--- a/src/skaembutils/s6-cut.c
+++ b/src/skaembutils/s6-cut.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <skalibs/sgetopt.h>
@@ -22,8 +23,8 @@ static int diuint_cmpleft (void const *a, void const *b)
 
 static void diuintalloc_normalize (genalloc *list)
 {
-  unsigned int i = 1, cur = 0 ;
-  unsigned int len = genalloc_len(diuint, list) ;
+  size_t i = 1, cur = 0 ;
+  size_t len = genalloc_len(diuint, list) ;
   register diuint *const s = genalloc_s(diuint, list) ;
   qsort(s, len, sizeof(diuint), &diuint_cmpleft) ;
   for (; i < len ; i++)
@@ -36,7 +37,7 @@ static void diuintalloc_normalize (genalloc *list)
 
 static void scanlist (genalloc *list, char const *s)
 {
-  register unsigned int i = 0 ;
+  register size_t i = 0 ;
   genalloc_setlen(diuint, list, 0) ;
   while (s[i])
   {
@@ -45,14 +46,14 @@ static void scanlist (genalloc *list, char const *s)
     if (s[i] == '-') iv.left = 1 ;
     else
     {
-      unsigned int j = uint_scan(s+i, &iv.left) ;
+      size_t j = uint_scan(s+i, &iv.left) ;
       if (!j || !iv.left) strerr_dief2x(100, "invalid list argument: ", s) ;
       i += j ;
     }
     if (s[i] != '-') iv.right = iv.left ;
     else
     {
-      unsigned int j = uint_scan(s + ++i, &iv.right) ;
+      size_t j = uint_scan(s + ++i, &iv.right) ;
       if (!j) iv.right = 0 ;
       else if (iv.right < iv.left)
         strerr_dief2x(100, "invalid list argument: ", s) ;
@@ -72,7 +73,7 @@ static void scanlist (genalloc *list, char const *s)
   }
 }
 
-static int doit (int fd, diuint const *s, unsigned int len, unsigned int flags, char delim)
+static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char delim)
 {
   char buf[BUFFER_INSIZE] ;
   buffer b = BUFFER_INIT(&buffer_flush1read, fd, buf, BUFFER_INSIZE) ;
@@ -85,10 +86,10 @@ static int doit (int fd, diuint const *s, unsigned int len, unsigned int flags,
     if (!r) break ;
     if (flags & 2)
     {
-      register unsigned int i = 0 ;
+      register size_t i = 0 ;
       for (; i < len ; i++)
       {
-        register unsigned int j = s[i].right ;
+        register size_t j = s[i].right ;
         if (s[i].left >= satmp.len) break ;
         if (!j || (j > satmp.len))
         {
@@ -101,7 +102,7 @@ static int doit (int fd, diuint const *s, unsigned int len, unsigned int flags,
     }
     else
     {
-      register unsigned int i = 0, j = 0, count = 1 ;
+      register size_t i = 0, j = 0, count = 1 ;
       for (; i < len ; i++)
       {
         for (; count < s[i].left ; count++)
@@ -122,7 +123,7 @@ static int doit (int fd, diuint const *s, unsigned int len, unsigned int flags,
         }
         for (; !s[i].right || (count <= s[i].right) ; count++)
         {
-          register unsigned int k = byte_chr(satmp.s + j, satmp.len - j, delim) ;
+          register size_t k = byte_chr(satmp.s + j, satmp.len - j, delim) ;
           if ((count > s[0].left) && (buffer_put(buffer_1, &delim, 1) < 0)) return 0 ;
           if (buffer_put(buffer_1, satmp.s + j, k) < 0) return 0 ;
           j += k ;
diff --git a/src/skaembutils/s6-dumpenv.c b/src/skaembutils/s6-dumpenv.c
index 3c025d4..7439c51 100644
--- a/src/skaembutils/s6-dumpenv.c
+++ b/src/skaembutils/s6-dumpenv.c
@@ -15,7 +15,7 @@
 int main (int argc, char const *const *argv, char const *const *envp)
 {
   mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ;
-  unsigned int dirlen ;
+  size_t dirlen ;
 
   PROG = "s6-dumpenv" ;
   {
@@ -50,7 +50,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
     
   for (; *envp ; envp++)
   {
-    unsigned int varlen = str_chr(*envp, '=') ;
+    size_t varlen = str_chr(*envp, '=') ;
     char fn[dirlen + varlen + 2] ;
     byte_copy(fn, dirlen, argv[0]) ;
     fn[dirlen] = '/' ;
diff --git a/src/skaembutils/s6-expr.c b/src/skaembutils/s6-expr.c
index 4404d44..accb0e6 100644
--- a/src/skaembutils/s6-expr.c
+++ b/src/skaembutils/s6-expr.c
@@ -1,13 +1,15 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <unistd.h>
 #include <skalibs/allreadwrite.h>
 #include <skalibs/bytestr.h>
-#include <skalibs/uint.h>
+#include <skalibs/ulong.h>
 #include <skalibs/fmtscan.h>
 #include <skalibs/strerr2.h>
 
 #define USAGE "s6-expr arithmetic expression"
+#define bail() strerr_dief1x(2, "invalid expression")
 
 enum opnum
 {
@@ -42,7 +44,7 @@ struct node
   unsigned int type ;
   unsigned int arg1 ;
   unsigned int arg2 ;
-  int data ;
+  long data ;
 } ;
 
 static unsigned int lex (struct node *tree, char const *const *argv)
@@ -82,8 +84,7 @@ static unsigned int lex (struct node *tree, char const *const *argv)
     {
       tree[pos].op = T_DATA ;
       tree[pos].type = 0 ;
-      if (!int_scan(argv[pos], &tree[pos].data))
-        strerr_dief1x(2, "invalid expression") ;
+      if (!long_scan(argv[pos], &tree[pos].data)) bail() ;
     }
   }
   return pos ;
@@ -125,32 +126,28 @@ static unsigned int parse (struct node *tree, unsigned int n)
   {
     switch (table[tree[pos].type][tree[stack[sp]].type])
     {
-      case 'x' :  _exit(2) ;
+      case 'x' :  bail() ;
       case '!' :  cont = 0 ; break ;
       case 's' :  stack[++sp] = pos++ ; break ;
+      case 'M' :
+        if (tree[stack[sp-2]].type != 7) bail() ;
+        stack[sp-2] = stack[sp-1] ;
+        sp -= 2 ;
       case 'm' :  reduce(tree, stack, &sp, 2) ; break ;
       case 'a' :  reduce(tree, stack, &sp, 3) ; break ;
       case 'c' :  reduce(tree, stack, &sp, 4) ; break ;
       case 'A' :  reduce(tree, stack, &sp, 5) ; break ;
       case 'O' :  reduce(tree, stack, &sp, 6) ; break ;
       case 'E' :  tree[stack[sp]].type = 14 ; break ;
-      case 'M' : 
-      {
-        if (tree[stack[sp-2]].type != 7) _exit(2) ;
-        stack[sp-2] = stack[sp-1] ;
-        sp -= 2 ;
-        reduce(tree, stack, &sp, 2) ;
-        break ;
-      }
       case 'z' : 
       default : strerr_dief1x(101, "internal error in parse, please submit a bug-report.") ; /* can't happen */
     }
   }
-  if (sp != 2) strerr_dief1x(2, "invalid expression") ;
+  if (sp != 2) bail() ;
   return stack[1] ;
 }
 
-static int run (struct node const *tree, unsigned int root)
+static long run (struct node const *tree, unsigned int root)
 {
   switch (tree[root].op)
   {
@@ -158,12 +155,12 @@ static int run (struct node const *tree, unsigned int root)
       return tree[root].data ;
     case T_OR :
     {
-      int r = run(tree, tree[root].arg1) ;
+      long r = run(tree, tree[root].arg1) ;
       return r ? r : run(tree, tree[root].arg2) ;
     }
     case T_AND :
     {
-      int r = run(tree, tree[root].arg1) ;
+      long r = run(tree, tree[root].arg1) ;
       return r ? run(tree, tree[root].arg2) ? r : 0 : 0 ;
     }
     case T_EQUAL :
@@ -188,22 +185,22 @@ static int run (struct node const *tree, unsigned int root)
       return run(tree, tree[root].arg1) / run(tree, tree[root].arg2) ;
     case T_MOD :
       return run(tree, tree[root].arg1) % run(tree, tree[root].arg2) ;
-    default: strerr_dief1x(101, "internal error in run, please submit a bug-report") ;
+    default : strerr_dief1x(101, "internal error in run, please submit a bug-report") ;
   }
 }
 
 int main (int argc, char const *const *argv)
 {
-  char fmt[UINT_FMT+1] ;
-  int val ;
-  unsigned int len ;
+  char fmt[ULONG_FMT+1] ;
+  long val ;
+  size_t len ;
   PROG = "s6-expr" ;
   if (argc <= 1) return 2 ;
   {
     struct node tree[argc + 1] ;
     val = run(tree, parse(tree, lex(tree, argv+1))) ;
   }
-  len = int_fmt(fmt, val) ;
+  len = long_fmt(fmt, val) ;
   fmt[len++] = '\n' ;
   if (allwrite(1, fmt, len) < len)
     strerr_diefu1sys(111, "write to stdout") ;
diff --git a/src/skaembutils/s6-false.c b/src/skaembutils/s6-false.c
index fb13dcd..0e78d8b 100644
--- a/src/skaembutils/s6-false.c
+++ b/src/skaembutils/s6-false.c
@@ -1,6 +1,6 @@
 /* ISC license. */
 
-int main ()
+int main (void)
 {
   return 1 ;
 }
diff --git a/src/skaembutils/s6-grep.c b/src/skaembutils/s6-grep.c
index b42e807..0af770c 100644
--- a/src/skaembutils/s6-grep.c
+++ b/src/skaembutils/s6-grep.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <regex.h>
 #include <string.h>
@@ -56,7 +57,7 @@ int main (int argc, char const *const *argv)
     stralloc line = STRALLOC_ZERO ;
     regex_t re ;
     unsigned int num = 0 ;
-    unsigned int arglen = str_len(argv[0]) ;
+    size_t arglen = str_len(argv[0]) ;
     if (!flags.fixed)
     {
       register int e = regcomp(&re, argv[0], REG_NOSUB | (flags.extended ? REG_EXTENDED : 0) | (flags.ignorecase ? REG_ICASE : 0)) ;
@@ -106,7 +107,7 @@ int main (int argc, char const *const *argv)
           if (flags.num)
           {
             char fmt[UINT_FMT] ;
-            register unsigned int n = uint_fmt(fmt, num) ;
+            register size_t n = uint_fmt(fmt, num) ;
             fmt[n++] = ':' ;
             if (buffer_put(buffer_1, fmt, n) < (int)n)
               strerr_diefu1sys(111, "write to stdout") ;
@@ -123,9 +124,9 @@ int main (int argc, char const *const *argv)
   if (flags.count)
   {
     char fmt[UINT_FMT] ;
-    register unsigned int n = uint_fmt(fmt, count) ;
+    register size_t n = uint_fmt(fmt, count) ;
     fmt[n++] = '\n' ;
-    if (buffer_put(buffer_1, fmt, n) < (int)n)
+    if (buffer_put(buffer_1, fmt, n) < (ssize_t)n)
       strerr_diefu1sys(111, "write to stdout") ;
   }
   return !count ;
diff --git a/src/skaembutils/s6-head.c b/src/skaembutils/s6-head.c
index 1ef24c0..589ff45 100644
--- a/src/skaembutils/s6-head.c
+++ b/src/skaembutils/s6-head.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <skalibs/allreadwrite.h>
 #include <skalibs/sgetopt.h>
@@ -13,10 +14,10 @@
 #define USAGE "s6-head [ -S ] [ -1..9 | -n lines | -c chars ] [ file... ]"
 #define dieusage() strerr_dieusage(100, USAGE)
 
-typedef int headfunc_t (int, unsigned int) ;
+typedef int headfunc_t (int, size_t) ;
 typedef headfunc_t *headfunc_t_ref ;
 
-static int dolines (int fd, unsigned int lines)
+static int dolines (int fd, size_t lines)
 {
   char buf[BUFFER_INSIZE] ;
   buffer in = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE) ;
@@ -24,15 +25,15 @@ static int dolines (int fd, unsigned int lines)
   siovec_t v[2] ;
   while (lines)
   {
-    unsigned int w = 0 ;
-    register int r = buffer_fill(&in) ;
+    size_t w = 0 ;
+    ssize_t r = buffer_fill(&in) ;
     if (r <= 0) return !r ;
     out.c.n = in.c.n ; out.c.p = in.c.p ;
     buffer_rpeek(&in, v) ;
     for (;;)
     {
-      unsigned int n = siovec_len(v, 2) ;
-      register unsigned int i ;
+      size_t n = siovec_len(v, 2) ;
+      size_t i ;
       if (!n) break ;
       i = siovec_bytechr(v, 2, '\n') ;
       if (i < n)
@@ -53,12 +54,12 @@ static int dolines (int fd, unsigned int lines)
   return 1 ;
 }
 
-static int safedolines (int fd, unsigned int lines)
+static int safedolines (int fd, size_t lines)
 {
   char tmp[lines] ;
   while (lines)
   {
-    unsigned int r = allread(fd, tmp, lines) ;
+    size_t r = allread(fd, tmp, lines) ;
     if ((r < lines) && (errno != EPIPE)) return 0 ;
     lines -= byte_count(tmp, r, '\n') ;
     if (buffer_put(buffer_1, tmp, r) < (int)r) return 0 ;
@@ -67,7 +68,7 @@ static int safedolines (int fd, unsigned int lines)
   return 1 ;
 }
 
-static int safedochars (int fd, unsigned int chars)
+static int safedochars (int fd, size_t chars)
 {
   return (fd_catn(fd, 1, chars) >= chars) ;
 }
diff --git a/src/skaembutils/s6-ln.c b/src/skaembutils/s6-ln.c
index d8d95c8..9ed0730 100644
--- a/src/skaembutils/s6-ln.c
+++ b/src/skaembutils/s6-ln.c
@@ -51,7 +51,7 @@ static void force (char const *old, char const *new, linkfunc_t_ref doit)
 {
   if ((*doit)(old, new) == -1)
   {
-    unsigned int base = satmp.len ;
+    size_t base = satmp.len ;
     if (errno != EEXIST)
       strerr_diefu5sys(111, "make a link", " from ", new, " to ", old) ;
     if (!stralloc_catb(&satmp, new, str_len(new))
@@ -104,7 +104,7 @@ int main (int argc, char const *const *argv)
   {
     stralloc sa = STRALLOC_ZERO ;
     unsigned int i = 0 ;
-    unsigned int base ;
+    size_t base ;
     if (!stralloc_cats(&sa, argv[argc-1]) || !stralloc_catb(&sa, "/", 1))
       strerr_diefu1sys(111, "stralloc_cats") ;
     base = sa.len ;
diff --git a/src/skaembutils/s6-mkdir.c b/src/skaembutils/s6-mkdir.c
index 92bae67..baec9a0 100644
--- a/src/skaembutils/s6-mkdir.c
+++ b/src/skaembutils/s6-mkdir.c
@@ -34,7 +34,7 @@ static int doit (char const *s, unsigned int mode, int verbose, int ee)
 
 static int doparents (char const *s, unsigned int mode, int verbose)
 {
-  unsigned int n = str_len(s), i = 0 ;
+  size_t n = str_len(s), i = 0 ;
   char tmp[n+1] ;
   for (; i < n ; i++)
   {
diff --git a/src/skaembutils/s6-printenv.c b/src/skaembutils/s6-printenv.c
index 3f4571b..85a252d 100644
--- a/src/skaembutils/s6-printenv.c
+++ b/src/skaembutils/s6-printenv.c
@@ -40,7 +40,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
     }
     else
     {
-      unsigned int written = 0 ;
+      unsigned int written = 0 ; /* XXX */
       if (!netstring_put(buffer_1, *envp, str_len(*envp), &written))
         strerr_diefu1sys(111, "write a netstring to stdout") ;
     }
diff --git a/src/skaembutils/s6-quote-filter.c b/src/skaembutils/s6-quote-filter.c
index d9489a1..3308f22 100644
--- a/src/skaembutils/s6-quote-filter.c
+++ b/src/skaembutils/s6-quote-filter.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/strerr2.h>
@@ -14,8 +15,8 @@ int main (int argc, char const *const *argv)
   stralloc src = STRALLOC_ZERO ;
   stralloc dst = STRALLOC_ZERO ;
   char const *delim = "\"" ;
-  unsigned int delimlen ;
-  unsigned int startquote = 1 ;
+  size_t delimlen ;
+  size_t startquote = 1 ;
   PROG = "s6-quote-filter" ;
   {
     subgetopt_t l = SUBGETOPT_ZERO ;
diff --git a/src/skaembutils/s6-quote.c b/src/skaembutils/s6-quote.c
index b370e39..6925806 100644
--- a/src/skaembutils/s6-quote.c
+++ b/src/skaembutils/s6-quote.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/strerr2.h>
 #include <skalibs/allreadwrite.h>
@@ -12,9 +13,9 @@ int main (int argc, char const *const *argv)
 {
   stralloc sa = STRALLOC_ZERO ;
   char const *delim = "\"" ;
-  unsigned int delimlen ;
+  size_t delimlen ;
+  size_t startquote = 1 ;
   int nl = 1 ;
-  int startquote = 1 ;
   PROG = "s6-quote" ;
   {
     subgetopt_t l = SUBGETOPT_ZERO ;
diff --git a/src/skaembutils/s6-seq.c b/src/skaembutils/s6-seq.c
index bad4afd..db319e6 100644
--- a/src/skaembutils/s6-seq.c
+++ b/src/skaembutils/s6-seq.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <skalibs/uint.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/buffer.h>
@@ -11,8 +12,8 @@
 int main (int argc, char const *const *argv)
 {
   char const *sep = "\n" ;
-  unsigned int fixed = 0, seplen = 1, i = 1, increment = 1 ;
-  unsigned int last ;
+  size_t fixed = 0, seplen = 1 ;
+  unsigned int i = 1, increment = 1, last ;
   char fmt[UINT_FMT] ;
   PROG = "s6-seq" ;
   {
diff --git a/src/skaembutils/s6-sort.c b/src/skaembutils/s6-sort.c
index afac913..ec22e0d 100644
--- a/src/skaembutils/s6-sort.c
+++ b/src/skaembutils/s6-sort.c
@@ -25,7 +25,7 @@ static int flagnoblanks = 0, flagreverse = 0, flaguniq = 0 ;
 
 static strncmp_t_ref comp = &strncmp ;
 
-static int compit (register char const *s1, register unsigned int n1, register char const *s2, register unsigned int n2)
+static int compit (register char const *s1, register size_t n1, register char const *s2, register size_t n2)
 {
   register int r ;
   if (flagnoblanks)
@@ -43,9 +43,9 @@ static int sacmp (stralloc const *a, stralloc const *b)
   return compit(a->s, a->len - 1, b->s, b->len - 1) ;
 }
 
-static int slurplines (genalloc *lines, char sep)
+static ssize_t slurplines (genalloc *lines, char sep)
 {
-  unsigned int i = 0 ;
+  ssize_t i = 0 ;
   for (;; i++)
   {
     stralloc sa = STRALLOC_ZERO ;
@@ -56,29 +56,29 @@ static int slurplines (genalloc *lines, char sep)
     stralloc_shrink(&sa) ;
     if (!genalloc_append(stralloc, lines, &sa)) return -1 ;
   }
-  return (int)i ;
+  return i ;
 }
 
 static void uniq (genalloc *lines)
 {
-  unsigned int len = genalloc_len(stralloc, lines) ;
+  size_t len = genalloc_len(stralloc, lines) ;
   register stralloc *s = genalloc_s(stralloc, lines) ;
-  register unsigned int i = 1 ;
+  register size_t i = 1 ;
   for (; i < len ; i++)
     if (!sacmp(s+i-1, s+i)) stralloc_free(s+i-1) ;
 }
 
-static int outputlines (stralloc const *s, unsigned int len)
+static ssize_t outputlines (stralloc const *s, size_t len)
 {
-  register unsigned int i = 0 ;
+  register size_t i = 0 ;
   for (; i < len ; i++)
     if (buffer_put(buffer_1, s[i].s, s[i].len) < 0) return 0 ;
   return buffer_flush(buffer_1) ;
 }
 
-static int check (stralloc const *s, unsigned int len)
+static int check (stralloc const *s, size_t len)
 {
-  register unsigned int i = 1 ;
+  register size_t i = 1 ;
   for (; i < len ; i++)
     if (sacmp(s+i-1, s+i) >= !flaguniq) return 0 ;
   return 1 ;
diff --git a/src/skaembutils/s6-tail.c b/src/skaembutils/s6-tail.c
index cc2d1f1..4c71f9c 100644
--- a/src/skaembutils/s6-tail.c
+++ b/src/skaembutils/s6-tail.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/allreadwrite.h>
@@ -13,10 +14,10 @@
 
 #define USAGE "s6-tail [ -c chars | -n lines | -1..9 ] [ file ]"
 
-typedef int tailfunc_t (int, unsigned int) ;
+typedef int tailfunc_t (int, size_t) ;
 typedef tailfunc_t *tailfunc_t_ref ;
 
-static int pluslines (int fd, unsigned int n)
+static int pluslines (int fd, size_t n)
 {
   if (n) n-- ;
   {
@@ -25,12 +26,12 @@ static int pluslines (int fd, unsigned int n)
     unsigned int count = 0 ;
     while (count < n)
     {
-      register int r = buffer_fill(&b) ;
+      register ssize_t r = buffer_fill(&b) ;
       if (r <= 0) return !r ;
       while (!buffer_isempty(&b) && (count < n))
       {
         siovec_t v[2] ;
-        unsigned int i ;
+        size_t i ;
         buffer_rpeek(&b, v) ;
         i = siovec_bytechr(v, 2, '\n') ;
         if (i < buffer_len(&b))
@@ -47,7 +48,7 @@ static int pluslines (int fd, unsigned int n)
   return (fd_cat(fd, 1) >= 0) ;
 }
 
-static int pluschars (int fd, unsigned int n)
+static int pluschars (int fd, size_t n)
 {
   if (n-- > 1)
   {
@@ -65,11 +66,11 @@ static int pluschars (int fd, unsigned int n)
   return (fd_cat(fd, 1) >= 0) ;
 }
 
-static int minuslines (int fd, unsigned int n)
+static int minuslines (int fd, size_t n)
 {
   char buf[BUFFER_INSIZE] ;
   buffer b = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE) ;
-  unsigned int head = 0, tail = 0 ;
+  size_t head = 0, tail = 0 ;
   stralloc tab[n+1] ;
   for (; head <= n ; head++) tab[head] = stralloc_zero ;
   head = 0 ;
@@ -103,13 +104,13 @@ static int minuslines (int fd, unsigned int n)
   return 0 ;
 }
 
-static int minuschars (int fd, unsigned int n)
+static int minuschars (int fd, size_t n)
 {
   char buf[BUFFER_INSIZE + n] ;
   buffer b = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE + n) ;
   for (;;)
   {
-    register int r = buffer_fill(&b) ;
+    register ssize_t r = buffer_fill(&b) ;
     if (!r) break ;
     if (r < 0) return 0 ;
     buffer_rseek(&b, buffer_len(&b)) ;
diff --git a/src/skaembutils/s6-unquote-filter.c b/src/skaembutils/s6-unquote-filter.c
index 08477ef..887b517 100644
--- a/src/skaembutils/s6-unquote-filter.c
+++ b/src/skaembutils/s6-unquote-filter.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <errno.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/bytestr.h>
@@ -13,11 +14,11 @@
 
 static unsigned int strictness = 1 ;
 static char const *delim = "\"" ;
-static unsigned int delimlen = 1 ;
+static size_t delimlen = 1 ;
 
-static void fillfmt (char *fmt, char const *s, unsigned int len)
+static void fillfmt (char *fmt, char const *s, size_t len)
 {
-  register unsigned int n = len < 39 ? len+1 : 36 ;
+  register size_t n = len < 39 ? len+1 : 36 ;
   byte_copy(fmt, n, s) ;
   if (len >= 39)
   {
@@ -27,7 +28,7 @@ static void fillfmt (char *fmt, char const *s, unsigned int len)
   fmt[n] = 0 ;
 }
 
-static int doit (char const *s, unsigned int len)
+static int doit (char const *s, size_t len)
 {
   if (delimlen)
   {
@@ -73,7 +74,7 @@ static int doit (char const *s, unsigned int len)
     }
   }
   {
-    unsigned int r, w ;
+    unsigned int r, w ; /* XXX */
     char d[len] ;
     if (!string_unquote_withdelim(d, &w, s + !!delimlen, len - !!delimlen, &r, delim, delimlen))
     {
diff --git a/src/skaembutils/s6-unquote.c b/src/skaembutils/s6-unquote.c
index 37c3dfb..1da51e8 100644
--- a/src/skaembutils/s6-unquote.c
+++ b/src/skaembutils/s6-unquote.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <sys/types.h>
 #include <skalibs/sgetopt.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/uint.h>
@@ -12,9 +13,9 @@
 int main (int argc, char const *const *argv)
 {
   char const *delim = "\"" ;
-  unsigned int len, delimlen ;
-  int nl = 1 ;
   char const *string ;
+  size_t len, delimlen ;
+  int nl = 1 ;
   PROG = "s6-unquote" ;
   {
     subgetopt_t l = SUBGETOPT_ZERO ;
@@ -42,7 +43,7 @@ int main (int argc, char const *const *argv)
       strerr_dief1x(100, "invalid starting quote character") ;
   }
   {
-    unsigned int r = 0, w = 0 ;
+    unsigned int r = 0, w = 0 ; /* XXX */
     char buf[len+1] ;
     if (!string_unquote_withdelim(buf, &w, string, len, &r, delim, delimlen))
     {
diff --git a/src/skaembutils/s6-update-symlinks.c b/src/skaembutils/s6-update-symlinks.c
index 91d76fa..b99317b 100644
--- a/src/skaembutils/s6-update-symlinks.c
+++ b/src/skaembutils/s6-update-symlinks.c
@@ -67,16 +67,16 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos)
   if (errno != EEXIST) return ERROR ;
 
   {
-    unsigned int dstbase = blah->dst.len ;
-    unsigned int srcbase = blah->src.len ;
-    unsigned int tmpbase = blah->tmp.len ;
-    unsigned int dststop ;
-    unsigned int srcstop ;
+    size_t dstbase = blah->dst.len ;
+    size_t srcbase = blah->src.len ;
+    size_t tmpbase = blah->tmp.len ;
+    size_t dststop ;
+    size_t srcstop ;
     signed int diffsize = 0 ;
     int collect = 1 ;
 
     {
-      register unsigned int n = str_len(blah->dst.s + dstpos) ;
+      register size_t n = str_len(blah->dst.s + dstpos) ;
       if (!stralloc_readyplus(&blah->dst, n+1)) return ERROR ;
       stralloc_catb(&blah->dst, blah->dst.s + dstpos, n) ;
     }
@@ -178,7 +178,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos)
 
     blah->src.len = srcbase ;
     {
-      register unsigned int n = str_len(blah->src.s + srcpos) ;
+      register size_t n = str_len(blah->src.s + srcpos) ;
       if (!stralloc_readyplus(&blah->src, n+1))
       {
         blah->dst.len = dstbase ;
@@ -241,14 +241,14 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos)
    /* recurse */
 
     {
-      unsigned int i = tmpbase ;
+      size_t i = tmpbase ;
       while (i < blah->tmp.len)
       {
         diffsize++ ;
         blah->dst.len = dststop ;
         blah->src.len = srcstop ;
         {
-          register unsigned int n = str_len(blah->tmp.s + i) + 1 ;
+          register size_t n = str_len(blah->tmp.s + i) + 1 ;
           if (!stralloc_catb(&blah->dst, blah->tmp.s + i, n)
            || !stralloc_catb(&blah->src, blah->tmp.s + i, n))
           {
@@ -303,7 +303,7 @@ int main (int argc, char *const *argv)
     for (; *p ; p++) if (**p != '/') strerr_dieusage(100, USAGE) ;
   }
   {
-    register unsigned int i = str_len(argv[1]) ;
+    register size_t i = str_len(argv[1]) ;
     while (i && (argv[1][i-1] == '/')) argv[1][--i] = 0 ;
     if (!i) strerr_diefu1x(100, "replace root directory") ;
   }