summaryrefslogtreecommitdiff
path: root/src/libs6rc
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 /src/libs6rc
parentda010cd4a3a4da1b03940b76b138e75cc36106cf (diff)
downloads6-rc-c0bfd8814f6cd8e45a230deca0f28954ed38480e.tar.xz
Types fix: first pass
Diffstat (limited to 'src/libs6rc')
-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
15 files changed, 70 insertions, 56 deletions
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/") ;