summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-08 22:37:23 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-08 22:37:23 +0000
commitc0bfd8814f6cd8e45a230deca0f28954ed38480e (patch)
tree3fe2e7692806402346cae9509b22d790e5a6b39d
parentda010cd4a3a4da1b03940b76b138e75cc36106cf (diff)
downloads6-rc-c0bfd8814f6cd8e45a230deca0f28954ed38480e.tar.xz
Types fix: first pass
-rw-r--r--src/include/s6-rc/s6rc-db.h22
-rw-r--r--src/include/s6-rc/s6rc-utils.h3
-rw-r--r--src/libs6rc/s6rc_db_check_depcycles.c16
-rw-r--r--src/libs6rc/s6rc_db_check_pipelines.c12
-rw-r--r--src/libs6rc/s6rc_db_check_revdeps.c9
-rw-r--r--src/libs6rc/s6rc_db_read.c19
-rw-r--r--src/libs6rc/s6rc_db_read_sizes.c7
-rw-r--r--src/libs6rc/s6rc_db_read_uint32.c3
-rw-r--r--src/libs6rc/s6rc_lock.c5
-rw-r--r--src/libs6rc/s6rc_read_uint.c3
-rw-r--r--src/libs6rc/s6rc_sanitize_dir.c9
-rw-r--r--src/libs6rc/s6rc_servicedir_block.c3
-rw-r--r--src/libs6rc/s6rc_servicedir_copy_online.c5
-rw-r--r--src/libs6rc/s6rc_servicedir_internal.c7
-rw-r--r--src/libs6rc/s6rc_servicedir_manage.c20
-rw-r--r--src/libs6rc/s6rc_servicedir_unblock.c3
-rw-r--r--src/libs6rc/s6rc_servicedir_unsupervise.c5
-rw-r--r--src/s6-rc/s6-rc-bundle.c24
-rw-r--r--src/s6-rc/s6-rc-compile.c100
-rw-r--r--src/s6-rc/s6-rc-db.c24
-rw-r--r--src/s6-rc/s6-rc-fdholder-filler.c3
-rw-r--r--src/s6-rc/s6-rc-init.c5
-rw-r--r--src/s6-rc/s6-rc-oneshot-run.c6
-rw-r--r--src/s6-rc/s6-rc-update.c57
-rw-r--r--src/s6-rc/s6-rc.c26
25 files changed, 211 insertions, 185 deletions
diff --git a/src/include/s6-rc/s6rc-db.h b/src/include/s6-rc/s6rc-db.h
index 0053af9..60287e9 100644
--- a/src/include/s6-rc/s6rc-db.h
+++ b/src/include/s6-rc/s6rc-db.h
@@ -3,7 +3,7 @@
#ifndef S6RC_DB_H
#define S6RC_DB_H
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/diuint32.h>
#include <skalibs/buffer.h>
@@ -16,14 +16,14 @@
typedef struct s6rc_oneshot_s s6rc_oneshot_t, *s6rc_oneshot_t_ref ;
struct s6rc_oneshot_s
{
- uint32 argc[2] ;
- uint32 argv[2] ;
+ uint32_t argc[2] ;
+ uint32_t argv[2] ;
} ;
typedef struct s6rc_longrun_s s6rc_longrun_t, *s6rc_longrun_t_ref ;
struct s6rc_longrun_s
{
- uint32 pipeline[2] ;
+ uint32_t pipeline[2] ;
} ;
typedef union s6rc_longshot_u s6rc_longshot_t, *s6rc_longshot_t_ref ;
@@ -36,11 +36,11 @@ union s6rc_longshot_u
typedef struct s6rc_service_s s6rc_service_t, *s6rc_service_t_ref ;
struct s6rc_service_s
{
- uint32 name ;
- uint32 flags ;
- uint32 deps[2] ;
- uint32 ndeps[2] ;
- uint32 timeout[2] ;
+ uint32_t name ;
+ uint32_t flags ;
+ uint32_t deps[2] ;
+ uint32_t ndeps[2] ;
+ uint32_t timeout[2] ;
s6rc_longshot_t x ;
} ;
@@ -55,10 +55,10 @@ struct s6rc_db_s
unsigned int ndeps ;
char *string ;
char const **argvs ;
- uint32 *deps ;
+ uint32_t *deps ;
} ;
-extern int s6rc_db_read_uint32 (buffer *, uint32 *) ;
+extern int s6rc_db_read_uint32 (buffer *, uint32_t *) ;
extern int s6rc_db_read_sizes (int, s6rc_db_t *) ;
extern int s6rc_db_read (int, s6rc_db_t *) ;
diff --git a/src/include/s6-rc/s6rc-utils.h b/src/include/s6-rc/s6rc-utils.h
index e7a6d0c..4eb65f5 100644
--- a/src/include/s6-rc/s6rc-utils.h
+++ b/src/include/s6-rc/s6rc-utils.h
@@ -3,12 +3,13 @@
#ifndef S6RC_UTILS_H
#define S6RC_UTILS_H
+#include <sys/types.h>
#include <skalibs/stralloc.h>
#include <s6-rc/s6rc-db.h>
extern void s6rc_graph_closure (s6rc_db_t const *, unsigned char *, unsigned int, int) ;
extern int s6rc_lock (char const *, int, int *, char const *, int, int *) ;
extern int s6rc_read_uint (char const *, unsigned int *) ;
-extern int s6rc_sanitize_dir (stralloc *, char const *, unsigned int *) ;
+extern int s6rc_sanitize_dir (stralloc *, char const *, size_t *) ;
#endif
diff --git a/src/libs6rc/s6rc_db_check_depcycles.c b/src/libs6rc/s6rc_db_check_depcycles.c
index db6ed6e..5f7baa7 100644
--- a/src/libs6rc/s6rc_db_check_depcycles.c
+++ b/src/libs6rc/s6rc_db_check_depcycles.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/diuint32.h>
#include <skalibs/bitarray.h>
#include <skalibs/bytestr.h>
@@ -10,22 +10,22 @@ typedef struct recinfo_s recinfo_t, *recinfo_t_ref ;
struct recinfo_s
{
s6rc_db_t const *db ;
- uint32 n ;
+ uint32_t n ;
unsigned char *gray ;
unsigned char *black ;
unsigned char h : 1 ;
} ;
-static uint32 s6rc_db_checknocycle_rec (recinfo_t *recinfo, uint32 i)
+static uint32_t s6rc_db_checknocycle_rec (recinfo_t *recinfo, uint32_t i)
{
if (!bitarray_peek(recinfo->black, i))
{
- uint32 j = recinfo->db->services[i].ndeps[recinfo->h] ;
+ uint32_t j = recinfo->db->services[i].ndeps[recinfo->h] ;
if (bitarray_peek(recinfo->gray, i)) return i ;
bitarray_set(recinfo->gray, i) ;
while (j--)
{
- register uint32 r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ;
+ register uint32_t r = s6rc_db_checknocycle_rec(recinfo, recinfo->db->deps[recinfo->h * recinfo->db->ndeps + recinfo->db->services[i].deps[recinfo->h] + j]) ;
if (r < recinfo->n) return r ;
}
bitarray_set(recinfo->black, i) ;
@@ -35,8 +35,8 @@ static uint32 s6rc_db_checknocycle_rec (recinfo_t *recinfo, uint32 i)
int s6rc_db_check_depcycles (s6rc_db_t const *db, int h, diuint32 *problem)
{
- uint32 n = db->nshort + db->nlong ;
- uint32 i = n ;
+ uint32_t n = db->nshort + db->nlong ;
+ uint32_t i = n ;
unsigned char gray[bitarray_div8(n)] ;
unsigned char black[bitarray_div8(n)] ;
recinfo_t info = { .db = db, .n = n, .gray = gray, .black = black, .h = !!h } ;
@@ -44,7 +44,7 @@ int s6rc_db_check_depcycles (s6rc_db_t const *db, int h, diuint32 *problem)
byte_zero(black, bitarray_div8(n)) ;
while (i--)
{
- register uint32 r = s6rc_db_checknocycle_rec(&info, i) ;
+ register uint32_t r = s6rc_db_checknocycle_rec(&info, i) ;
if (r < n)
{
problem->left = i ;
diff --git a/src/libs6rc/s6rc_db_check_pipelines.c b/src/libs6rc/s6rc_db_check_pipelines.c
index d2547fc..19f4993 100644
--- a/src/libs6rc/s6rc_db_check_pipelines.c
+++ b/src/libs6rc/s6rc_db_check_pipelines.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/diuint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/bitarray.h>
@@ -8,16 +8,16 @@
int s6rc_db_check_pipelines (s6rc_db_t const *db, diuint32 *problem)
{
- uint32 i = db->nlong ;
+ uint32_t i = db->nlong ;
unsigned char black[bitarray_div8(db->nlong)] ;
byte_zero(black, bitarray_div8(db->nlong)) ;
while (i--) if (!bitarray_peek(black, i))
{
- uint32 j = i ;
- uint32 start ;
+ uint32_t j = i ;
+ uint32_t start ;
for (;;)
{
- register uint32 k = db->services[j].x.longrun.pipeline[0] ;
+ register uint32_t k = db->services[j].x.longrun.pipeline[0] ;
if (k >= db->nlong) break ;
if (k == i || bitarray_peek(black, k))
{
@@ -31,7 +31,7 @@ int s6rc_db_check_pipelines (s6rc_db_t const *db, diuint32 *problem)
j = i ;
for (;;)
{
- register uint32 k = db->services[j].x.longrun.pipeline[1] ;
+ register uint32_t k = db->services[j].x.longrun.pipeline[1] ;
if (k >= db->nlong) break ;
if (k == i || bitarray_peek(black, k))
{
diff --git a/src/libs6rc/s6rc_db_check_revdeps.c b/src/libs6rc/s6rc_db_check_revdeps.c
index a4342b1..3b64c36 100644
--- a/src/libs6rc/s6rc_db_check_revdeps.c
+++ b/src/libs6rc/s6rc_db_check_revdeps.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/bitarray.h>
#include <s6-rc/s6rc-db.h>
int s6rc_db_check_revdeps (s6rc_db_t const *db)
{
- unsigned int n = db->nshort + db->nlong ;
- unsigned int m = bitarray_div8(n) ;
+ size_t n = db->nshort + db->nlong ;
+ size_t m = bitarray_div8(n) ;
unsigned char matrix[n * m] ;
register unsigned int i = n ;
register unsigned char const *p = matrix ;
@@ -23,7 +24,7 @@ int s6rc_db_check_revdeps (s6rc_db_t const *db)
register unsigned int j = db->services[i].ndeps[0] ;
while (j--) bitarray_not(matrix + m * db->deps[db->services[i].deps[0] + j], i, 1) ;
}
- i = n * m ;
- while (i--) if (*p++) return 1 ;
+ n *= m ;
+ while (n--) if (*p++) return 1 ;
return 0 ;
}
diff --git a/src/libs6rc/s6rc_db_read.c b/src/libs6rc/s6rc_db_read.c
index 254ffa1..e327c19 100644
--- a/src/libs6rc/s6rc_db_read.c
+++ b/src/libs6rc/s6rc_db_read.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
@@ -17,14 +19,14 @@
#define DBG(...)
#endif
-static int s6rc_db_check_valid_string (char const *string, unsigned int stringlen, unsigned int pos)
+static int s6rc_db_check_valid_string (char const *string, size_t stringlen, size_t pos)
{
if (pos >= stringlen) return 0 ;
if (str_nlen(string + pos, stringlen - pos) == stringlen - pos) return 0 ;
return 1 ;
}
-static inline int s6rc_db_check_valid_strings (char const *string, unsigned int stringlen, unsigned int pos, unsigned int n)
+static inline int s6rc_db_check_valid_strings (char const *string, size_t stringlen, size_t pos, unsigned int n)
{
while (n--)
{
@@ -34,9 +36,9 @@ static inline int s6rc_db_check_valid_strings (char const *string, unsigned int
return 1 ;
}
-static inline int s6rc_db_read_deps (buffer *b, unsigned int max, uint32 *deps, unsigned int ndeps)
+static inline int s6rc_db_read_deps (buffer *b, unsigned int max, uint32_t *deps, unsigned int ndeps)
{
- uint32 x ;
+ uint32_t x ;
ndeps <<= 1 ;
while (ndeps--)
{
@@ -99,7 +101,7 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db)
DBG(" oneshot") ;
for (; j < 2 ; j++)
{
- uint32 pos, argc ;
+ uint32_t pos, argc ;
if (!s6rc_db_read_uint32(b, &argc)) return -1 ;
DBG(" argc[%u] is %u, nargvs is %u", j, argc, nargvs) ;
if (argc > nargvs) return 0 ;
@@ -111,7 +113,8 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db)
sv->x.oneshot.argv[j] = argvpos ;
sv->x.oneshot.argc[j] = argc ;
argvpos += argc ; nargvs -= argc ;
- if (!nargvs--) return 0 ; db->argvs[argvpos++] = 0 ;
+ if (!nargvs--) return 0 ;
+ db->argvs[argvpos++] = 0 ;
}
}
{
@@ -124,9 +127,9 @@ static inline int s6rc_db_read_services (buffer *b, s6rc_db_t *db)
return 1 ;
}
-static inline int s6rc_db_read_string (buffer *b, char *string, unsigned int len)
+static inline int s6rc_db_read_string (buffer *b, char *string, size_t len)
{
- if (buffer_get(b, string, len) < (int)len) return -1 ;
+ if (buffer_get(b, string, len) < (ssize_t)len) return -1 ;
return 1 ;
}
diff --git a/src/libs6rc/s6rc_db_read_sizes.c b/src/libs6rc/s6rc_db_read_sizes.c
index 4d1537f..de596e2 100644
--- a/src/libs6rc/s6rc_db_read_sizes.c
+++ b/src/libs6rc/s6rc_db_read_sizes.c
@@ -1,7 +1,8 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
#include <skalibs/djbunix.h>
@@ -10,7 +11,7 @@
static inline int s6rc_db_read_sizes_buffer (buffer *b, s6rc_db_t *db)
{
- uint32 x ;
+ uint32_t x ;
if (!s6rc_db_read_uint32(b, &x)) return 0 ;
db->nshort = x ;
if (!s6rc_db_read_uint32(b, &x)) return 0 ;
@@ -38,7 +39,7 @@ int s6rc_db_read_sizes (int fdcompiled, s6rc_db_t *db)
}
{
char c ;
- register int r = buffer_get(&b, &c, 1) ;
+ register ssize_t r = buffer_get(&b, &c, 1) ;
if (r < 0)
{
r = errno ;
diff --git a/src/libs6rc/s6rc_db_read_uint32.c b/src/libs6rc/s6rc_db_read_uint32.c
index 05d1f9e..937847b 100644
--- a/src/libs6rc/s6rc_db_read_uint32.c
+++ b/src/libs6rc/s6rc_db_read_uint32.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/buffer.h>
#include <s6-rc/s6rc-db.h>
-int s6rc_db_read_uint32 (buffer *b, uint32 *x)
+int s6rc_db_read_uint32 (buffer *b, uint32_t *x)
{
unsigned int w = 0 ;
char pack[4] ;
diff --git a/src/libs6rc/s6rc_lock.c b/src/libs6rc/s6rc_lock.c
index 75a22be..34c2544 100644
--- a/src/libs6rc/s6rc_lock.c
+++ b/src/libs6rc/s6rc_lock.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/diuint.h>
@@ -13,7 +14,7 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
if (lwhat)
{
- unsigned int llen = str_len(live) ;
+ size_t llen = str_len(live) ;
char lfn[llen + 6] ;
byte_copy(lfn, llen, live) ;
byte_copy(lfn + llen, 6, "/lock") ;
@@ -24,7 +25,7 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
if (cwhat)
{
- unsigned int clen = str_len(compiled) ;
+ size_t clen = str_len(compiled) ;
char cfn[clen + 6] ;
byte_copy(cfn, clen, compiled) ;
byte_copy(cfn + clen, 6, "/lock") ;
diff --git a/src/libs6rc/s6rc_read_uint.c b/src/libs6rc/s6rc_read_uint.c
index 6953190..87022c6 100644
--- a/src/libs6rc/s6rc_read_uint.c
+++ b/src/libs6rc/s6rc_read_uint.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
@@ -8,7 +9,7 @@
int s6rc_read_uint (char const *file, unsigned int *u)
{
char buf[UINT_FMT + 1] ;
- register int r = openreadnclose(file, buf, UINT_FMT) ;
+ register ssize_t r = openreadnclose(file, buf, UINT_FMT) ;
if (r < 0) return (errno == ENOENT) ? 0 : -1 ;
buf[byte_chr(buf, r, '\n')] = 0 ;
if (!uint0_scan(buf, u)) return (errno = EINVAL, -1) ;
diff --git a/src/libs6rc/s6rc_sanitize_dir.c b/src/libs6rc/s6rc_sanitize_dir.c
index 69c4d13..fa7079d 100644
--- a/src/libs6rc/s6rc_sanitize_dir.c
+++ b/src/libs6rc/s6rc_sanitize_dir.c
@@ -1,16 +1,17 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <s6-rc/s6rc-utils.h>
-int s6rc_sanitize_dir (stralloc *sa, char const *fn, unsigned int *dirlen)
+int s6rc_sanitize_dir (stralloc *sa, char const *fn, size_t *dirlen)
{
+ size_t base = sa->len ;
+ size_t fnlen = str_len(fn) ;
+ size_t ddirlen ;
int wasnull = !sa->s ;
- unsigned int base = sa->len ;
- unsigned int fnlen = str_len(fn) ;
- unsigned int ddirlen ;
if (!sadirname(sa, fn, fnlen)) return 0 ;
if (sa->len != base + 1 || sa->s[base] != '/')
if (!stralloc_catb(sa, "/", 1)) goto err ;
diff --git a/src/libs6rc/s6rc_servicedir_block.c b/src/libs6rc/s6rc_servicedir_block.c
index d01481b..9fb28b1 100644
--- a/src/libs6rc/s6rc_servicedir_block.c
+++ b/src/libs6rc/s6rc_servicedir_block.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <skalibs/bytestr.h>
@@ -9,7 +10,7 @@
int s6rc_servicedir_block (char const *dir)
{
- unsigned int dirlen = str_len(dir) ;
+ size_t dirlen = str_len(dir) ;
s6_svstatus_t status ;
char fn[dirlen + 6] ;
if (!s6_svstatus_read(dir, &status)) return -1 ;
diff --git a/src/libs6rc/s6rc_servicedir_copy_online.c b/src/libs6rc/s6rc_servicedir_copy_online.c
index 76d9e10..902e6ad 100644
--- a/src/libs6rc/s6rc_servicedir_copy_online.c
+++ b/src/libs6rc/s6rc_servicedir_copy_online.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
@@ -11,8 +12,8 @@
int s6rc_servicedir_copy_online (char const *src, char const *dst)
{
- unsigned int srclen = str_len(src) ;
- unsigned int dstlen = str_len(dst) ;
+ size_t srclen = str_len(src) ;
+ size_t dstlen = str_len(dst) ;
unsigned int n ;
unsigned int i = 0 ;
int wantup = 0 ;
diff --git a/src/libs6rc/s6rc_servicedir_internal.c b/src/libs6rc/s6rc_servicedir_internal.c
index 7522313..ccc4644 100644
--- a/src/libs6rc/s6rc_servicedir_internal.c
+++ b/src/libs6rc/s6rc_servicedir_internal.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <skalibs/uint.h>
@@ -27,9 +28,9 @@ unsigned int const s6rc_servicedir_file_maxlen = 15 ;
int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_desc_t const *p)
{
- unsigned int srclen = str_len(src) ;
- unsigned int dstlen = str_len(dst) ;
- unsigned int plen = str_len(p->name) ;
+ size_t srclen = str_len(src) ;
+ size_t dstlen = str_len(dst) ;
+ size_t plen = str_len(p->name) ;
char srcfn[srclen + plen + 2] ;
char dstfn[dstlen + plen + 2] ;
byte_copy(srcfn, srclen, src) ;
diff --git a/src/libs6rc/s6rc_servicedir_manage.c b/src/libs6rc/s6rc_servicedir_manage.c
index 795c982..c665564 100644
--- a/src/libs6rc/s6rc_servicedir_manage.c
+++ b/src/libs6rc/s6rc_servicedir_manage.c
@@ -1,10 +1,10 @@
/* ISC license. */
#include <sys/types.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
-#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/direntry.h>
@@ -16,11 +16,11 @@
#include <s6/ftrigw.h>
#include <s6-rc/s6rc-servicedir.h>
-static void rollback (char const *live, char const *s, unsigned int len)
+static void rollback (char const *live, char const *s, size_t len)
{
while (len)
{
- unsigned int n = str_len(s) + 1 ;
+ size_t n = str_len(s) + 1 ;
s6rc_servicedir_unsupervise(live, s, 0) ;
s += n ; len -= n ;
}
@@ -30,9 +30,9 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
{
ftrigr_t a = FTRIGR_ZERO ;
stralloc newnames = STRALLOC_ZERO ;
- genalloc ids = GENALLOC_ZERO ; /* uint16 */
+ genalloc ids = GENALLOC_ZERO ; /* uint16_t */
gid_t gid = getgid() ;
- unsigned int livelen = str_len(live) ;
+ size_t livelen = str_len(live) ;
int ok = 1 ;
int e = 0 ;
DIR *dir ;
@@ -50,9 +50,9 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
if (!d) break ;
if (d->d_name[0] == '.') continue ;
{
- unsigned int len = str_len(d->d_name) ;
+ size_t len = str_len(d->d_name) ;
int r ;
- uint16 id ;
+ uint16_t id ;
char srcfn[livelen + 20 + len] ;
char dstfn[livelen + 10 + len] ;
byte_copy(srcfn, livelen + 12, dirfn) ;
@@ -99,12 +99,12 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
r = s6_svc_writectl(scanfn, S6_SVSCAN_CTLDIR, "a", 1) ;
if (r < 0) { e = errno ; goto closederr ; }
if (!r) ok = 3 ;
- else if (ftrigr_wait_and(&a, genalloc_s(uint16, &ids), genalloc_len(uint16, &ids), deadline, stamp) < 0)
+ else if (ftrigr_wait_and(&a, genalloc_s(uint16_t, &ids), genalloc_len(uint16_t, &ids), deadline, stamp) < 0)
{ e = errno ; goto closederr ; }
}
ftrigr_end(&a) ;
- genalloc_free(uint16, &ids) ;
+ genalloc_free(uint16_t, &ids) ;
stralloc_free(&newnames) ;
return ok ;
@@ -112,7 +112,7 @@ int s6rc_servicedir_manage (char const *live, tain_t const *deadline, tain_t *st
dir_close(dir) ;
closederr:
ftrigr_end(&a) ;
- genalloc_free(uint16, &ids) ;
+ genalloc_free(uint16_t, &ids) ;
rollback(live, newnames.s, newnames.len) ;
stralloc_free(&newnames) ;
errno = e ;
diff --git a/src/libs6rc/s6rc_servicedir_unblock.c b/src/libs6rc/s6rc_servicedir_unblock.c
index 6fd846c..0c2ae23 100644
--- a/src/libs6rc/s6rc_servicedir_unblock.c
+++ b/src/libs6rc/s6rc_servicedir_unblock.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <skalibs/bytestr.h>
@@ -10,7 +11,7 @@ int s6rc_servicedir_unblock (char const *dir, int h)
{
if (h)
{
- unsigned int dirlen = str_len(dir) ;
+ size_t dirlen = str_len(dir) ;
char fn[dirlen + 6] ;
byte_copy(fn, dirlen, dir) ;
byte_copy(fn + dirlen, 6, "/down") ;
diff --git a/src/libs6rc/s6rc_servicedir_unsupervise.c b/src/libs6rc/s6rc_servicedir_unsupervise.c
index 14a1164..bc5ab63 100644
--- a/src/libs6rc/s6rc_servicedir_unsupervise.c
+++ b/src/libs6rc/s6rc_servicedir_unsupervise.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <skalibs/bytestr.h>
#include <s6/s6-supervise.h>
@@ -7,8 +8,8 @@
void s6rc_servicedir_unsupervise (char const *live, char const *name, int keepsupervisor)
{
- unsigned int namelen = str_len(name) ;
- unsigned int livelen = str_len(live) ;
+ size_t namelen = str_len(name) ;
+ size_t livelen = str_len(live) ;
char fn[livelen + 14 + namelen] ;
byte_copy(fn, livelen, live) ;
byte_copy(fn + livelen, 9, "/scandir/") ;
diff --git a/src/s6-rc/s6-rc-bundle.c b/src/s6-rc/s6-rc-bundle.c
index 75c3ac1..6e6544b 100644
--- a/src/s6-rc/s6-rc-bundle.c
+++ b/src/s6-rc/s6-rc-bundle.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
@@ -22,8 +24,8 @@
static void cleanup (char const *compiled)
{
+ size_t len = str_len(compiled) ;
int e = errno ;
- unsigned int len = str_len(compiled) ;
char fn[len + sizeof("/resolve.cdb.new")] ;
byte_copy(fn, len, compiled) ;
byte_copy(fn + len, sizeof("/resolve.cdb.new"), "/resolve.cdb.new") ;
@@ -36,9 +38,9 @@ static void cleanup (char const *compiled)
static inline int renameit (char const *compiled, char const *src, char const *dst)
{
- unsigned int clen = str_len(compiled) ;
- unsigned int srclen = str_len(src) ;
- unsigned int dstlen = str_len(dst) ;
+ size_t clen = str_len(compiled) ;
+ size_t srclen = str_len(src) ;
+ size_t dstlen = str_len(dst) ;
char srcfn[clen + srclen + 2] ;
char dstfn[clen + dstlen + 2] ;
byte_copy(srcfn, clen, compiled) ;
@@ -52,7 +54,7 @@ static inline int renameit (char const *compiled, char const *src, char const *d
static void check (cdb_t *cr, s6rc_db_t *db, char const *name, int h, int force, char const *compiled)
{
- unsigned int namelen = str_len(name) ;
+ size_t namelen = str_len(name) ;
register int r = cdb_find(cr, name, namelen) ;
if (r < 0) strerr_diefu3sys(111, "cdb_find in ", compiled, "/resolve.cdb") ;
if (!r)
@@ -65,7 +67,7 @@ static void check (cdb_t *cr, s6rc_db_t *db, char const *name, int h, int force,
strerr_dief4x(1, "identifier ", name, " already exists in database ", compiled) ;
if (cdb_datalen(cr) == 4)
{
- uint32 x ;
+ uint32_t x ;
char pack[4] ;
if (cdb_read(cr, pack, 4, cdb_datapos(cr)) < 0)
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
@@ -81,7 +83,7 @@ static void modify_resolve (int fdcompiled, s6rc_db_t *db, char const *const *to
{
cdb_t cr = CDB_ZERO ;
struct cdb_make cw = CDB_MAKE_ZERO ;
- uint32 kpos ;
+ uint32_t kpos ;
unsigned int i = toaddn ;
int fdw ;
int fdr = open_readatb(fdcompiled, "resolve.cdb") ;
@@ -160,7 +162,7 @@ static void modify_resolve (int fdcompiled, s6rc_db_t *db, char const *const *to
j >>= 2 ;
while (j--)
{
- uint32 x ;
+ uint32_t x ;
uint32_unpack_big(pack + (j << 2), &x) ;
if (x >= db->nshort + db->nlong)
strerr_dief2x(4, "invalid database in ", compiled) ;
@@ -171,7 +173,7 @@ static void modify_resolve (int fdcompiled, s6rc_db_t *db, char const *const *to
{
char pack[(total << 2) + 1] ;
char *s = pack ;
- uint32 j = n ;
+ uint32_t j = n ;
while (j--) if (bitarray_peek(bits, j))
{
uint32_pack_big(s, j) ;
@@ -287,7 +289,7 @@ int main (int argc, char const **argv)
if (what != 2 && argc < 2) dieusage() ;
{
- unsigned int livelen = str_len(live) ;
+ size_t livelen = str_len(live) ;
int fdcompiled = -1 ;
int compiledlock ;
s6rc_db_t dbblob ;
@@ -320,7 +322,7 @@ int main (int argc, char const **argv)
unsigned int n = dbblob.nshort + dbblob.nlong ;
s6rc_service_t serviceblob[n] ;
char const *argvblob[dbblob.nargvs] ;
- uint32 depsblob[dbblob.ndeps << 1] ;
+ uint32_t depsblob[dbblob.ndeps << 1] ;
char stringblob[dbblob.stringlen] ;
register int r ;
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index 83f94df..97ecb3d 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
@@ -96,8 +98,8 @@ struct common_s
unsigned int kname ; /* pos in keep */
unsigned int ndeps ;
unsigned int depindex ; /* pos in indices */
- uint32 annotation_flags ;
- uint32 timeout[2] ;
+ uint32_t annotation_flags ;
+ uint32_t timeout[2] ;
} ;
typedef struct oneshot_s oneshot_t, *oneshot_t_ref ;
@@ -133,7 +135,7 @@ struct before_s
genalloc longruns ; /* longrun_t */
genalloc bundles ; /* bundle_t */
unsigned int nargvs ;
- uint32 specialdeps[2] ;
+ uint32_t specialdeps[2] ;
} ;
#define BEFORE_ZERO { .indices = GENALLOC_ZERO, .oneshots = GENALLOC_ZERO, .longruns = GENALLOC_ZERO, .bundles = GENALLOC_ZERO, .nargvs = 0, .specialdeps = { 0, 0 } } ;
@@ -212,7 +214,7 @@ static int add_name_nocheck (before_t *be, char const *srcdir, char const *name,
0,
.type = type
} ;
- unsigned int namelen = str_len(name) ;
+ size_t namelen = str_len(name) ;
unsigned int i = genalloc_len(nameinfo_t, &nameinfo) ;
if (type == SVTYPE_ONESHOT || type == SVTYPE_LONGRUN)
if (!stralloc_catb(&keep, name, namelen + 1)) dienomem() ;
@@ -266,7 +268,7 @@ static int uint_uniq (unsigned int const *list, unsigned int n, unsigned int pos
static int add_namelist (before_t *be, int dirfd, char const *srcdir, char const *name, char const *list, unsigned int *listindex, unsigned int *n)
{
buffer b ;
- unsigned int start = satmp.len ;
+ size_t start = satmp.len ;
int cont = 1 ;
char buf[2048] ;
int fd = open_readatb(dirfd, list) ;
@@ -279,7 +281,7 @@ static int add_namelist (before_t *be, int dirfd, char const *srcdir, char const
if (!r) cont = 0 ;
else
{
- unsigned int i = start ;
+ size_t i = start ;
if (r < 0)
{
if (errno != EPIPE) strerr_diefu6sys(111, "read ", srcdir, "/", name, "/", list) ;
@@ -336,11 +338,11 @@ static void read_script (before_t *be, int dirfd, char const *srcdir, char const
be->nargvs += r+1 ;
}
-static uint32 read_timeout (int dirfd, char const *srcdir, char const *name, char const *tname)
+static uint32_t read_timeout (int dirfd, char const *srcdir, char const *name, char const *tname)
{
char buf[64] ;
- uint32 timeout = 0 ;
- unsigned int r = openreadnclose_at(dirfd, tname, buf, 63) ;
+ uint32_t timeout = 0 ;
+ size_t r = openreadnclose_at(dirfd, tname, buf, 63) ;
if (!r)
{
if (errno && errno != ENOENT)
@@ -470,7 +472,7 @@ static inline void add_bundle (before_t *be, int dirfd, char const *srcdir, char
static inline void add_source (before_t *be, int dirfd, char const *srcdir, char const *name)
{
char typestr[8] = "" ;
- register unsigned int r ;
+ register size_t r ;
if (verbosity >= 2) strerr_warni4x("parsing ", srcdir, "/", name) ;
r = openreadnclose_at(dirfd, "type", typestr, 8) ;
if (!r)
@@ -488,8 +490,8 @@ static inline void add_source (before_t *be, int dirfd, char const *srcdir, char
static inline void add_sources (before_t *be, char const *srcdir)
{
- unsigned int start = satmp.len ;
- unsigned int cur ;
+ size_t start = satmp.len ;
+ size_t cur ;
DIR *dir = opendir(srcdir) ;
if (!dir) strerr_diefu2sys(111, "opendir ", srcdir) ;
if (!stralloc_cats(&satmp, srcdir) || !stralloc_catb(&satmp, "/", 1)) dienomem() ;
@@ -640,7 +642,7 @@ static inline void flatlist_bundles (bundle_t *bundles, unsigned int nbundles, u
for (; i < nbundles ; i++)
{
unsigned char const *mybits = barray + i * nbits ;
- uint32 *mydeps = bdeps + bundles[i].listindex ;
+ uint32_t *mydeps = bdeps + bundles[i].listindex ;
unsigned int j = 0, k = 0 ;
for (; k < bundles[i].n ; j++)
if (bitarray_peek(mybits, j)) mydeps[k++] = j ;
@@ -786,7 +788,7 @@ static inline void flatlist_services (s6rc_db_t *db, unsigned char const *sarray
if (verbosity >= 3) strerr_warni1x("converting service dependency array") ;
for (; i < n ; i++)
{
- uint32 *mydeps = db->deps + db->services[i].deps[0] ;
+ uint32_t *mydeps = db->deps + db->services[i].deps[0] ;
unsigned int j = 0, k = 0 ;
for (; k < db->services[i].ndeps[0] ; j++)
if (bitarray_peek(sarray + j * nbits, i)) mydeps[k++] = j ;
@@ -823,8 +825,8 @@ static void cleanup (char const *compiled)
static void auto_dir (char const *compiled, char const *dir)
{
- unsigned int clen = str_len(compiled) ;
- unsigned int dlen = str_len(dir) ;
+ size_t clen = str_len(compiled) ;
+ size_t dlen = str_len(dir) ;
char fn[clen + dlen + 2] ;
byte_copy(fn, clen, compiled) ;
fn[clen] = dlen ? '/' : 0 ;
@@ -838,8 +840,8 @@ static void auto_dir (char const *compiled, char const *dir)
static void auto_file (char const *compiled, char const *file, char const *s, unsigned int n)
{
- unsigned int clen = str_len(compiled) ;
- unsigned int flen = str_len(file) ;
+ size_t clen = str_len(compiled) ;
+ size_t flen = str_len(file) ;
char fn[clen + flen + 2] ;
byte_copy(fn, clen, compiled) ;
fn[clen] = '/' ;
@@ -853,8 +855,8 @@ static void auto_file (char const *compiled, char const *file, char const *s, un
static void auto_symlink (char const *compiled, char const *name, char const *target)
{
- unsigned int clen = str_len(compiled) ;
- unsigned int flen = str_len(name) ;
+ size_t clen = str_len(compiled) ;
+ size_t flen = str_len(name) ;
char fn[clen + flen + 2] ;
byte_copy(fn, clen, compiled) ;
fn[clen] = '/' ;
@@ -868,8 +870,8 @@ static void auto_symlink (char const *compiled, char const *name, char const *ta
static void auto_rights (char const *compiled, char const *file, mode_t mode)
{
- unsigned int clen = str_len(compiled) ;
- unsigned int flen = str_len(file) ;
+ size_t clen = str_len(compiled) ;
+ size_t flen = str_len(file) ;
char fn[clen + flen + 2] ;
byte_copy(fn, clen, compiled) ;
fn[clen] = '/' ;
@@ -895,19 +897,19 @@ static inline void write_sizes (char const *compiled, s6rc_db_t const *db)
{
char pack[20] ;
if (verbosity >= 3) strerr_warni3x("writing ", compiled, "/n") ;
- uint32_pack_big(pack, (uint32)db->nshort) ;
- uint32_pack_big(pack + 4, (uint32)db->nlong) ;
- uint32_pack_big(pack + 8, (uint32)db->stringlen) ;
- uint32_pack_big(pack + 12, (uint32)db->nargvs) ;
- uint32_pack_big(pack + 16, (uint32)db->ndeps) ;
+ uint32_pack_big(pack, (uint32_t)db->nshort) ;
+ uint32_pack_big(pack + 4, (uint32_t)db->nlong) ;
+ uint32_pack_big(pack + 8, (uint32_t)db->stringlen) ;
+ uint32_pack_big(pack + 12, (uint32_t)db->nargvs) ;
+ uint32_pack_big(pack + 16, (uint32_t)db->ndeps) ;
auto_file(compiled, "n", pack, 20) ;
}
static void make_skel (char const *compiled, char const *name, uint64 const *uids, unsigned int uidn, gid_t const *gids, unsigned int gidn, unsigned int notif)
{
- unsigned int namelen = str_len(name) ;
+ size_t namelen = str_len(name) ;
char fmt[UINT_FMT] ;
- unsigned int i = uint_fmt(fmt, notif) ;
+ size_t i = uint_fmt(fmt, notif) ;
fmt[i++] = '\n' ;
char fn[namelen + 29] ;
byte_copy(fn, 12, "servicedirs/") ;
@@ -938,7 +940,7 @@ static inline void write_oneshot_runner (char const *compiled, uint64 const *uid
i = gidn ;
while (i--)
{
- unsigned int len = gid_fmt(fn + 28 + S6RC_ONESHOT_RUNNER_LEN, gids[i]) ;
+ size_t len = gid_fmt(fn + 28 + S6RC_ONESHOT_RUNNER_LEN, gids[i]) ;
fn[28 + S6RC_ONESHOT_RUNNER_LEN + len] = 0 ;
auto_dir(compiled, fn) ;
byte_copy(fn + 28 + S6RC_ONESHOT_RUNNER_LEN + len, 7, "/allow") ;
@@ -949,7 +951,7 @@ static inline void write_oneshot_runner (char const *compiled, uint64 const *uid
i = uidn ;
while (i--)
{
- unsigned int len = uint64_fmt(fn + 28 + S6RC_ONESHOT_RUNNER_LEN, uids[i]) ;
+ size_t len = uint64_fmt(fn + 28 + S6RC_ONESHOT_RUNNER_LEN, uids[i]) ;
fn[28 + S6RC_ONESHOT_RUNNER_LEN + len] = 0 ;
auto_dir(compiled, fn) ;
byte_copy(fn + 28 + S6RC_ONESHOT_RUNNER_LEN + len, 7, "/allow") ;
@@ -961,21 +963,21 @@ static inline void write_oneshot_runner (char const *compiled, uint64 const *uid
static inline int write_pipelines (stralloc *sa, s6rc_db_t const *db)
{
- uint32 i = db->nlong ;
+ uint32_t i = db->nlong ;
unsigned char black[bitarray_div8(db->nlong)] ;
byte_zero(black, bitarray_div8(db->nlong)) ;
while (i--) if (!bitarray_peek(black, i))
{
- uint32 j = i ;
+ uint32_t j = i ;
for (;;)
{
- register uint32 k = db->services[j].x.longrun.pipeline[0] ;
+ register uint32_t k = db->services[j].x.longrun.pipeline[0] ;
if (k >= db->nlong) break ;
j = k ;
}
for (;;)
{
- register uint32 k = db->services[j].x.longrun.pipeline[1] ;
+ register uint32_t k = db->services[j].x.longrun.pipeline[1] ;
bitarray_set(black, j) ;
if (k >= db->nlong) break ;
if (!string_quote(sa, db->string + db->services[k].name, str_len(db->string + db->services[k].name))
@@ -988,12 +990,12 @@ static inline int write_pipelines (stralloc *sa, s6rc_db_t const *db)
static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, uint64 const *uids, unsigned int uidn, gid_t const *gids, unsigned int gidn, char const *fdhuser)
{
- unsigned int base = satmp.len ;
+ size_t base = satmp.len ;
make_skel(compiled, S6RC_FDHOLDER, uids, uidn, gids, gidn, 1) ;
{
char fn[62 + S6RC_FDHOLDER_LEN + UINT64_FMT] = "servicedirs/" S6RC_FDHOLDER "/data/rules/uid/" ;
char fmt[7 + UINT64_FMT] = "../uid/" ;
- unsigned int i = uint64_fmt(fmt + 7, uids[0]) ;
+ size_t i = uint64_fmt(fmt + 7, uids[0]) ;
fmt[7 + i] = 0 ;
byte_copy(fn + 28 + S6RC_FDHOLDER_LEN, i + 1, fmt + 7) ;
auto_dir(compiled, fn) ;
@@ -1014,7 +1016,7 @@ static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, ui
for (i = 1 ; i < uidn ; i++)
{
- unsigned int len = uint64_fmt(fn + 28 + S6RC_FDHOLDER_LEN, uids[i]) ;
+ size_t len = uint64_fmt(fn + 28 + S6RC_FDHOLDER_LEN, uids[i]) ;
fn[28 + S6RC_FDHOLDER_LEN + len] = 0 ;
auto_symlink(compiled, fn, fmt + 7) ;
}
@@ -1022,7 +1024,7 @@ static inline void write_fdholder (char const *compiled, s6rc_db_t const *db, ui
i = gidn ;
while (i--)
{
- unsigned int len = gid_fmt(fn + 28 + S6RC_FDHOLDER_LEN, gids[i]) ;
+ size_t len = gid_fmt(fn + 28 + S6RC_FDHOLDER_LEN, gids[i]) ;
fn[28 + S6RC_FDHOLDER_LEN + len] = 0 ;
auto_symlink(compiled, fn, fmt) ;
}
@@ -1065,7 +1067,7 @@ static inline void write_specials (char const *compiled, s6rc_db_t const *db, ui
static inline void write_resolve (char const *compiled, s6rc_db_t const *db, bundle_t const *bundles, unsigned int nbundles, uint32 const *bdeps)
{
- unsigned int clen = str_len(compiled) ;
+ size_t clen = str_len(compiled) ;
int fd ;
struct cdb_make c = CDB_MAKE_ZERO ;
unsigned int i = db->nshort + db->nlong ;
@@ -1089,7 +1091,7 @@ static inline void write_resolve (char const *compiled, s6rc_db_t const *db, bun
while (i--)
{
char pack[4] ;
- uint32_pack_big(pack, (uint32)i) ;
+ uint32_pack_big(pack, i) ;
if (cdb_make_add(&c, db->string + db->services[i].name, str_len(db->string + db->services[i].name), pack, 4) < 0)
{
cleanup(compiled) ;
@@ -1143,7 +1145,7 @@ static void dircopy (char const *compiled, char const *srcfn, char const *dstfn)
static inline void write_exe_wrapper (char const *compiled, char const *fn, s6rc_db_t const *db, unsigned int i, unsigned int fd, char const *exe, int needargs)
{
- unsigned int base = satmp.len ;
+ size_t base = satmp.len ;
if (!stralloc_cats(&satmp, "#!" EXECLINE_SHEBANGPREFIX "execlineb -")
|| !stralloc_cats(&satmp, needargs ? "S0\n" : "P\n")) dienomem() ;
if (db->services[i].x.longrun.pipeline[0] < db->nlong)
@@ -1177,14 +1179,14 @@ static inline void write_exe_wrapper (char const *compiled, char const *fn, s6rc
static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db, char const *const *srcdirs)
{
- unsigned int clen = str_len(compiled) ;
+ size_t clen = str_len(compiled) ;
unsigned int i = 2 ;
if (verbosity >= 3) strerr_warni3x("writing ", compiled, "/servicedirs") ;
for (; i < db->nlong ; i++)
{
struct stat st ;
- unsigned int srcdirlen = str_len(srcdirs[i]) ;
- unsigned int len = str_len(db->string + db->services[i].name) ;
+ size_t srcdirlen = str_len(srcdirs[i]) ;
+ size_t len = str_len(db->string + db->services[i].name) ;
unsigned int fd = 0 ;
int ispipelined = db->services[i].x.longrun.pipeline[0] < db->nlong || db->services[i].x.longrun.pipeline[1] < db->nlong ;
register int r ;
@@ -1211,7 +1213,7 @@ static inline void write_servicedirs (char const *compiled, s6rc_db_t const *db,
if (r)
{
char fmt[UINT_FMT] ;
- unsigned int fmtlen = uint_fmt(fmt, fd) ;
+ size_t fmtlen = uint_fmt(fmt, fd) ;
fmt[fmtlen++] = '\n' ;
byte_copy(dstfn + clen + 13 + len, 17, "/notification-fd") ;
if (!openwritenclose_unsafe(dstfn, fmt, fmtlen))
@@ -1318,7 +1320,7 @@ static inline int write_service (buffer *b, s6rc_service_t const *sv, int type)
static inline void write_db (char const *compiled, s6rc_db_t const *db)
{
- unsigned int clen = str_len(compiled) ;
+ size_t clen = str_len(compiled) ;
buffer b ;
int fd ;
char buf[4096] ;
@@ -1346,7 +1348,7 @@ static inline void write_db (char const *compiled, s6rc_db_t const *db)
{
unsigned int i = db->ndeps << 1 ;
- uint32 const *deps = db->deps ;
+ uint32_t const *deps = db->deps ;
while (i--)
{
char pack[4] ;
@@ -1461,7 +1463,7 @@ int main (int argc, char const *const *argv)
genalloc_free(nameinfo_t, &nameinfo) ;
avltree_free(&names_map) ;
{
- uint32 deps[db.ndeps << 1] ;
+ uint32_t deps[db.ndeps << 1] ;
db.deps = deps ;
flatlist_services(&db, sarray) ;
write_compiled(compiled, &db, srcdirs, bundles, nbundles, bdeps, uids, uidn, gids, gidn, fdhuser) ;
diff --git a/src/s6-rc/s6-rc-db.c b/src/s6-rc/s6-rc-db.c
index 0d8df53..01a0ccc 100644
--- a/src/s6-rc/s6-rc-db.c
+++ b/src/s6-rc/s6-rc-db.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <unistd.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
@@ -32,7 +34,7 @@ static void print_bundle_contents (char const *name)
if (!r) strerr_dief3x(3, name, " is not a valid identifier in ", compiled) ;
if (cdb_datalen(&c) == 4)
{
- uint32 x ;
+ uint32_t x ;
char pack[4] ;
if (cdb_read(&c, pack, 4, cdb_datapos(&c)) < 0)
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
@@ -56,7 +58,7 @@ static void print_bundle_contents (char const *name)
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
while (len--)
{
- uint32 x ;
+ uint32_t x ;
uint32_unpack_big(p, &x) ; p += 4 ;
if (x >= db->nshort + db->nlong)
strerr_dief2x(4, "invalid database in ", compiled) ;
@@ -86,7 +88,7 @@ static void print_services (unsigned int from, unsigned int to)
static void print_all (int bundlesonly)
{
cdb_t c = CDB_ZERO ;
- uint32 kpos ;
+ uint32_t kpos ;
int fd = open_readatb(fdcompiled, "resolve.cdb") ;
if (fd < 0) strerr_diefu3sys(111, "open ", compiled, "/resolve.cdb") ;
if (!cdb_init_map(&c, fd, 1))
@@ -102,7 +104,7 @@ static void print_all (int bundlesonly)
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
if (bundlesonly && cdb_datalen(&c) == 4)
{
- uint32 x ;
+ uint32_t x ;
char pack[4] ;
if (cdb_read(&c, pack, 4, cdb_datapos(&c)) < 0)
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
@@ -127,7 +129,7 @@ static unsigned int resolve_service (char const *name)
{
cdb_t c = CDB_ZERO ;
int fd = open_readatb(fdcompiled, "resolve.cdb") ;
- uint32 x ;
+ uint32_t x ;
char pack[4] ;
register int r ;
if (fd < 0) strerr_diefu3sys(111, "open ", compiled, "/resolve.cdb") ;
@@ -160,8 +162,8 @@ static void print_type (char const *name)
static void print_timeout (char const *name, int h)
{
+ size_t len ;
unsigned int n = resolve_service(name) ;
- unsigned int len ;
char fmt[UINT32_FMT] ;
if (n >= db->nshort + db->nlong)
strerr_dief5x(5, "in database ", compiled, ": identifier ", name, " represents a bundle") ;
@@ -248,14 +250,14 @@ static void print_union (char const *const *argv, int h, int isdeps, int doclosu
strerr_diefu3sys(111, "cdb_read ", compiled, "/resolve.cdb") ;
while (len--)
{
- uint32 x ;
+ uint32_t x ;
uint32_unpack_big(p, &x) ; p += 4 ;
if (x >= db->nshort + db->nlong)
strerr_dief2x(4, "invalid database in ", compiled) ;
if (isdeps)
{
- register uint32 ndeps = db->services[x].ndeps[h] ;
- register uint32 const *deps = db->deps + h * db->ndeps + db->services[x].deps[h] ;
+ register uint32_t ndeps = db->services[x].ndeps[h] ;
+ register uint32_t const *deps = db->deps + h * db->ndeps + db->services[x].deps[h] ;
while (ndeps--) state[*deps++] |= 1 ;
}
else state[x] |= 1 ;
@@ -373,7 +375,7 @@ int main (int argc, char const *const *argv)
if (what == 2) subwhat = 1 + parse_list(argv[1]) ;
{
- unsigned int livelen = str_len(live) ;
+ size_t livelen = str_len(live) ;
int compiledlock ;
s6rc_db_t dbblob ;
char compiledblob[compiled ? str_len(compiled) : livelen + 10] ;
@@ -406,7 +408,7 @@ int main (int argc, char const *const *argv)
unsigned int n = dbblob.nshort + dbblob.nlong ;
s6rc_service_t serviceblob[n] ;
char const *argvblob[dbblob.nargvs] ;
- uint32 depsblob[dbblob.ndeps << 1] ;
+ uint32_t depsblob[dbblob.ndeps << 1] ;
char stringblob[dbblob.stringlen] ;
register int r ;
diff --git a/src/s6-rc/s6-rc-fdholder-filler.c b/src/s6-rc/s6-rc-fdholder-filler.c
index 03eeb31..73283c1 100644
--- a/src/s6-rc/s6-rc-fdholder-filler.c
+++ b/src/s6-rc/s6-rc-fdholder-filler.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/uint.h>
@@ -49,7 +50,7 @@ int main (int argc, char const *const *argv)
s6_fdholder_fd_t dump[n<<1] ;
for (; i < n ; i++)
{
- unsigned int len = str_len(argv[i]) ;
+ size_t len = str_len(argv[i]) ;
if (len + 12 > S6_FDHOLDER_ID_SIZE)
{
errno = ENAMETOOLONG ;
diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c
index 98d07e5..e434756 100644
--- a/src/s6-rc/s6-rc-init.c
+++ b/src/s6-rc/s6-rc-init.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/uint.h>
@@ -17,7 +18,7 @@
#define dieusage() strerr_dieusage(100, USAGE)
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-static unsigned int llen ;
+static size_t llen ;
static void cleanup (void)
{
@@ -33,7 +34,7 @@ static void cleanup (void)
int main (int argc, char const *const *argv)
{
tain_t deadline, tto ;
- unsigned int dirlen ;
+ size_t dirlen ;
char const *live = S6RC_LIVE_BASE ;
char const *compiled = S6RC_COMPILED_BASE ;
PROG = "s6-rc-init" ;
diff --git a/src/s6-rc/s6-rc-oneshot-run.c b/src/s6-rc/s6-rc-oneshot-run.c
index f7fbc0e..6fe7255 100644
--- a/src/s6-rc/s6-rc-oneshot-run.c
+++ b/src/s6-rc/s6-rc-oneshot-run.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/sgetopt.h>
@@ -39,7 +41,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!uint0_scan(argv[1], &number)) dieusage() ;
{
- unsigned int livelen = str_len(live) ;
+ size_t livelen = str_len(live) ;
int fdcompiled, compiledlock ;
s6rc_db_t db ;
char compiled[livelen + 10] ;
@@ -68,7 +70,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
s6rc_service_t serviceblob[db.nshort + db.nlong] ;
char const *argvblob[db.nargvs] ;
- uint32 depsblob[db.ndeps << 1] ;
+ uint32_t depsblob[db.ndeps << 1] ;
char stringblob[db.stringlen] ;
register int r ;
diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c
index 417718d..2b37453 100644
--- a/src/s6-rc/s6-rc-update.c
+++ b/src/s6-rc/s6-rc-update.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <sys/types.h>
+#include <stdint.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
@@ -33,7 +34,7 @@
#define dienomem() strerr_diefu1sys(111, "build string") ;
static char const *live = S6RC_LIVE_BASE ;
-static unsigned int livelen = sizeof(S6RC_LIVE_BASE) - 1 ;
+static size_t livelen = sizeof(S6RC_LIVE_BASE) - 1 ;
static unsigned int verbosity = 1 ;
@@ -61,9 +62,9 @@ static unsigned int verbosity = 1 ;
128 -> depends on a new service, has to be restarted
*/
-static inline void parse_line (stralloc *sa, char const *s, unsigned int slen, unsigned int *newnames, unsigned char *oldstate, cdb_t *oldc, s6rc_db_t const *olddb)
+static inline void parse_line (stralloc *sa, char const *s, size_t slen, unsigned int *newnames, unsigned char *oldstate, cdb_t *oldc, s6rc_db_t const *olddb)
{
- unsigned int base = sa->len ;
+ size_t base = sa->len ;
unsigned int oldn = olddb->nshort + olddb->nlong ;
int n ;
if (!stralloc_readyplus(sa, slen)) dienomem() ;
@@ -80,7 +81,7 @@ static inline void parse_line (stralloc *sa, char const *s, unsigned int slen, u
if (n--)
{
char pack[4] ;
- uint32 x ;
+ uint32_t x ;
unsigned int cur ;
register int r = cdb_find(oldc, sa->s + base + slen, str_len(sa->s + base + slen)) ;
if (r < 0) strerr_diefu3sys(111, "read ", live, "/compiled/resolve.cdb") ;
@@ -96,7 +97,7 @@ static inline void parse_line (stralloc *sa, char const *s, unsigned int slen, u
cur = base + slen + str_len(sa->s + base + slen) + 1 ;
if (n >= 2 && !str_diff(sa->s + cur, "->"))
{
- register unsigned int newnamelen = str_len(sa->s + cur + 3) ;
+ register size_t newnamelen = str_len(sa->s + cur + 3) ;
byte_copy(sa->s + sa->len, newnamelen + 1, sa->s + cur + 3) ;
newnames[x] = sa->len ; oldstate[x] |= 16 ;
sa->len += newnamelen + 1 ;
@@ -118,7 +119,7 @@ static inline void parse_conversion_file (char const *convfile, stralloc *sa, un
int fd = open_readb(convfile) ;
char buf[4096] ;
buffer b = BUFFER_INIT(&fd_readsv, fd, buf, 4096) ;
- unsigned int base = satmp.len ;
+ size_t base = satmp.len ;
if (fd < 0) strerr_diefu2sys(111, "open ", convfile) ;
for (;;)
@@ -184,7 +185,7 @@ static inline void fill_convtable_and_flags (unsigned char *conversion_table, un
if (len == 1) oldstate[i] |= 8 ;
while (len--)
{
- uint32 x ;
+ uint32_t x ;
uint32_unpack_big(p, &x) ; p += 4 ;
if (x >= newn)
strerr_dief3x(4, "invalid resolve database in ", newfn, "/resolve.cdb") ;
@@ -221,10 +222,10 @@ static inline void stuff_with_newc (int fdnewc, char const *newfn, unsigned char
static void compute_transitions (char const *convfile, unsigned char *oldstate, int fdoldc, s6rc_db_t const *olddb, unsigned char *newstate, unsigned int *invimage, int fdnewc, char const *newfn, s6rc_db_t const *newdb, stralloc *sa)
{
+ size_t sabase = sa->len ;
unsigned int oldn = olddb->nshort + olddb->nlong ;
unsigned int newn = newdb->nshort + newdb->nlong ;
unsigned int newm = bitarray_div8(newn) ;
- unsigned int sabase = sa->len ;
unsigned int oldindex[oldn] ;
unsigned char conversion_table[oldn * newm] ;
byte_zero(conversion_table, oldn * newm) ;
@@ -296,11 +297,11 @@ static void compute_transitions (char const *convfile, unsigned char *oldstate,
static inline void rollback_servicedirs (char const *newlive, unsigned char const *newstate, unsigned int const *invimage, s6rc_db_t const *olddb, s6rc_db_t const *newdb, unsigned int n)
{
- unsigned int newllen = str_len(newlive) ;
+ size_t newllen = str_len(newlive) ;
unsigned int i = n ;
while (i--)
{
- unsigned int newnamelen = str_len(newdb->string + newdb->services[i].name) ;
+ size_t newnamelen = str_len(newdb->string + newdb->services[i].name) ;
char newfn[newllen + 14 + newnamelen] ;
byte_copy(newfn, newllen, newlive) ;
byte_copy(newfn + newllen, 13, "/servicedirs/") ;
@@ -308,7 +309,7 @@ static inline void rollback_servicedirs (char const *newlive, unsigned char cons
if (newstate[i] & 1)
{
char const *oldname = newstate[i] & 8 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + newdb->services[i].name ;
- unsigned int oldnamelen = str_len(oldname) ;
+ size_t oldnamelen = str_len(oldname) ;
char oldfn[livelen + 23 + oldnamelen] ;
byte_copy(oldfn, livelen, live) ;
byte_copy(oldfn + livelen, 22, "/compiled/servicedirs/") ;
@@ -325,10 +326,10 @@ static inline void rollback_servicedirs (char const *newlive, unsigned char cons
static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t const *olddb, unsigned char const *newstate, s6rc_db_t const *newdb, char const *newcompiled, unsigned int *invimage, stralloc *sa)
{
- unsigned int tmpbase = satmp.len ;
- unsigned int sabase = sa->len ;
- unsigned int newclen = str_len(newcompiled) ;
- unsigned int dirlen, llen, newlen, sdlen ;
+ size_t tmpbase = satmp.len ;
+ size_t sabase = sa->len ;
+ size_t newclen = str_len(newcompiled) ;
+ size_t dirlen, llen, newlen, sdlen ;
int e = 0 ;
unsigned int i = 0 ;
if (sareadlink(&satmp, live) < 0) strerr_diefu2sys(111, "readlink ", live) ;
@@ -338,7 +339,7 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
newlen = --sa->len ;
if (mkdir(sa->s + sabase, 0755) < 0) strerr_diefu2sys(111, "mkdir ", sa->s + sabase) ;
{
- unsigned int tmplen = satmp.len ;
+ size_t tmplen = satmp.len ;
char fn[llen - sabase + 9] ;
if (!stralloc_cats(sa, "/scandir") || !stralloc_0(sa)) { e = errno ; goto err ; }
byte_copy(fn, llen - sabase, sa->s + sabase) ;
@@ -366,7 +367,7 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
for (; i < newdb->nlong ; i++)
{
- unsigned int newnamelen = str_len(newdb->string + newdb->services[i].name) ;
+ size_t newnamelen = str_len(newdb->string + newdb->services[i].name) ;
char newfn[newclen + 14 + newnamelen] ;
byte_copy(newfn, newclen, newcompiled) ;
byte_copy(newfn + newclen, 13, "/servicedirs/") ;
@@ -377,7 +378,7 @@ static inline void make_new_livedir (unsigned char const *oldstate, s6rc_db_t co
if (newstate[i] & 1)
{
char const *oldname = newstate[i] & 8 ? olddb->string + olddb->services[invimage[i]].name : newdb->string + newdb->services[i].name ;
- unsigned int oldnamelen = str_len(oldname) ;
+ size_t oldnamelen = str_len(oldname) ;
char oldfn[livelen + 14 + oldnamelen] ;
byte_copy(oldfn, livelen, live) ;
byte_copy(oldfn + livelen, 13, "/servicedirs/") ;
@@ -444,7 +445,7 @@ static inline int delete_unused_pipes (s6_fdholder_t *a, s6rc_db_t const *olddb,
if (!(oldstate[i] & 8)
&& olddb->services[i].x.longrun.pipeline[0] < olddb->nlong)
{
- unsigned int len = str_len(olddb->string + olddb->services[i].name) ;
+ size_t len = str_len(olddb->string + olddb->services[i].name) ;
char pipename[len + 13] ;
byte_copy(pipename, 12, "pipe:s6rc-w-") ;
byte_copy(pipename + 12, len + 1, olddb->string + olddb->services[i].name) ;
@@ -466,8 +467,8 @@ static inline int rename_pipes (s6_fdholder_t *a, s6rc_db_t const *olddb, s6rc_d
if ((newstate[i] & 20) == 20 && newdb->services[i].x.longrun.pipeline[0] < newdb->nlong)
{
int fd ;
- unsigned int oldlen = str_len(olddb->string + olddb->services[invimage[i]].name) ;
- unsigned int newlen = str_len(newdb->string + newdb->services[i].name) ;
+ size_t oldlen = str_len(olddb->string + olddb->services[invimage[i]].name) ;
+ size_t newlen = str_len(newdb->string + newdb->services[i].name) ;
char oldpipename[oldlen + 13] ;
char newpipename[newlen + 13] ;
byte_copy(oldpipename, 12, "pipe:s6rc-r-") ;
@@ -512,7 +513,7 @@ static inline int create_new_pipes (s6_fdholder_t *a, s6rc_db_t const *newdb, un
if (!(newstate[i] & 4) && newdb->services[i].x.longrun.pipeline[0] < newdb->nlong)
{
int p[2] ;
- unsigned int len = str_len(newdb->string + newdb->services[i].name) ;
+ size_t len = str_len(newdb->string + newdb->services[i].name) ;
char pipename[len + 13] ;
byte_copy(pipename, 12, "pipe:s6rc-r-") ;
byte_copy(pipename + 12, len + 1, newdb->string + newdb->services[i].name) ;
@@ -684,10 +685,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
stralloc sa = STRALLOC_ZERO ;
s6rc_service_t oldserviceblob[oldn] ;
char const *oldargvblob[olddb.nargvs] ;
- uint32 olddepsblob[olddb.ndeps << 1] ;
+ uint32_t olddepsblob[olddb.ndeps << 1] ;
s6rc_service_t newserviceblob[newn] ;
char const *newargvblob[newdb.nargvs] ;
- uint32 newdepsblob[newdb.ndeps << 1] ;
+ uint32_t newdepsblob[newdb.ndeps << 1] ;
unsigned int invimage[newn] ;
char oldstringblob[olddb.stringlen] ;
char newstringblob[newdb.stringlen] ;
@@ -718,8 +719,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
/* Initial state */
byte_copy(dbfn + livelen + 1, 6, "state") ;
- r = openreadnclose(dbfn, (char *)oldstate, oldn) ;
- if (r != oldn) strerr_diefu2sys(111, "read ", dbfn) ;
+ {
+ register ssize_t rr = openreadnclose(dbfn, (char *)oldstate, oldn) ;
+ if (rr != oldn) strerr_diefu2sys(111, "read ", dbfn) ;
+ }
r = oldn ;
while (r--) oldstate[r] &= 1 ;
byte_zero(newstate, newn) ;
@@ -783,8 +786,6 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!dryrun)
{
- int r ;
-
/* Update state and service directories */
if (verbosity >= 2)
diff --git a/src/s6-rc/s6-rc.c b/src/s6-rc/s6-rc.c
index 3ae779a..26ca196 100644
--- a/src/s6-rc/s6-rc.c
+++ b/src/s6-rc/s6-rc.c
@@ -35,7 +35,7 @@ struct pidindex_s
static unsigned int verbosity = 1 ;
static char const *live = S6RC_LIVE_BASE ;
-static unsigned int livelen ;
+static size_t livelen ;
static pidindex_t *pidindex ;
static unsigned int npids = 0 ;
static s6rc_db_t *db ;
@@ -127,7 +127,7 @@ static pid_t start_oneshot (unsigned int i, int h)
static pid_t start_longrun (unsigned int i, int h)
{
- unsigned int svdlen = str_len(db->string + db->services[i].name) ;
+ size_t svdlen = str_len(db->string + db->services[i].name) ;
unsigned int m = 0 ;
char fmt[UINT32_FMT] ;
char vfmt[UINT_FMT] ;
@@ -172,7 +172,7 @@ static void success_longrun (unsigned int i, int h)
{
if (!dryrun[0])
{
- unsigned int svdlen = str_len(db->string + db->services[i].name) ;
+ size_t svdlen = str_len(db->string + db->services[i].name) ;
char fn[livelen + svdlen + 15] ;
byte_copy(fn, livelen, live) ;
byte_copy(fn + livelen, 9, "/scandir/") ;
@@ -458,10 +458,9 @@ int main (int argc, char const *const *argv)
int spfd ;
s6rc_service_t serviceblob[n] ;
char const *argvblob[dbblob.nargvs] ;
- uint32 depsblob[dbblob.ndeps << 1] ;
+ uint32_t depsblob[dbblob.ndeps << 1] ;
char stringblob[dbblob.stringlen] ;
unsigned char stateblob[n] ;
- register int r ;
dbblob.services = serviceblob ;
dbblob.argvs = argvblob ;
@@ -474,7 +473,7 @@ int main (int argc, char const *const *argv)
byte_copy(dbfn + livelen + 1, 6, "state") ;
{
- r = openreadnclose(dbfn, (char *)state, n) ;
+ register ssize_t r = openreadnclose(dbfn, (char *)state, n) ;
if (r != n) strerr_diefu2sys(111, "read ", dbfn) ;
{
register unsigned int i = n ;
@@ -484,10 +483,11 @@ int main (int argc, char const *const *argv)
/* Read the db from the file */
-
- r = s6rc_db_read(fdcompiled, &dbblob) ;
- if (r < 0) strerr_diefu3sys(111, "read ", dbfn, "/db") ;
- if (!r) strerr_dief3x(4, "invalid service database in ", dbfn, "/db") ;
+ {
+ register int r = s6rc_db_read(fdcompiled, &dbblob) ;
+ if (r < 0) strerr_diefu3sys(111, "read ", dbfn, "/db") ;
+ if (!r) strerr_dief3x(4, "invalid service database in ", dbfn, "/db") ;
+ }
/* Resolve the args and add them to the selection */
@@ -501,8 +501,7 @@ int main (int argc, char const *const *argv)
for (; *argv ; argv++)
{
unsigned int len ;
- register int r ;
- r = cdb_find(&c, *argv, str_len(*argv)) ;
+ register int r = cdb_find(&c, *argv, str_len(*argv)) ;
if (r < 0) strerr_diefu3sys(111, "read ", dbfn, "/resolve.cdb") ;
if (!r)
strerr_dief4x(3, *argv, " is not a recognized identifier in ", dbfn, "/resolve.cdb") ;
@@ -518,7 +517,7 @@ int main (int argc, char const *const *argv)
if (r < 0) strerr_diefu3sys(111, "read ", dbfn, "/resolve.cdb") ;
while (len--)
{
- uint32 x ;
+ uint32_t x ;
uint32_unpack_big(p, &x) ; p += 4 ;
if (x >= n)
strerr_dief3x(4, "invalid resolve database in ", dbfn, "/resolve.cdb") ;
@@ -574,6 +573,7 @@ int main (int argc, char const *const *argv)
if (prune)
{
+ register int r ;
if (up) invert_selection() ;
r = doit(spfd, 0) ;
if (r) return r ;