about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-27 12:12:42 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-27 12:12:42 +0000
commit59027c94f50a0d983a2bf0ebb72ef406b4fef20d (patch)
tree18a2e2e1945ffd3d673c1bdc25b76d93dcf317d5 /src
parent54d4b6e74bf539930db2cafbe075416894900076 (diff)
downloads6-linux-utils-59027c94f50a0d983a2bf0ebb72ef406b4fef20d.tar.gz
s6-linux-utils-59027c94f50a0d983a2bf0ebb72ef406b4fef20d.tar.xz
s6-linux-utils-59027c94f50a0d983a2bf0ebb72ef406b4fef20d.zip
Make sure avltree indices (in s6-ps) are uint32_t
Diffstat (limited to 'src')
-rw-r--r--src/minutils/s6-ps.c9
-rw-r--r--src/minutils/s6-ps.h4
-rw-r--r--src/minutils/s6ps_grcache.c7
-rw-r--r--src/minutils/s6ps_otree.c2
-rw-r--r--src/minutils/s6ps_pwcache.c7
-rw-r--r--src/minutils/s6ps_ttycache.c7
6 files changed, 20 insertions, 16 deletions
diff --git a/src/minutils/s6-ps.c b/src/minutils/s6-ps.c
index c3d85fc..bba973b 100644
--- a/src/minutils/s6-ps.c
+++ b/src/minutils/s6-ps.c
@@ -2,6 +2,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
@@ -52,10 +53,10 @@ void *left_dtok (unsigned int d, void *x)
   return (void *)&genalloc_s(dius_t, (genalloc *)x)[d].left ;
 }
 
-int uint_cmp (void const *a, void const *b, void *x)
+int uint32_cmp (void const *a, void const *b, void *x)
 {
-  unsigned int aa = *(unsigned int *)a ;
-  unsigned int bb = *(unsigned int *)b ;
+  uint32_t aa = *(uint32_t *)a ;
+  uint32_t bb = *(uint32_t *)b ;
   (void)x ;
   return (aa < bb) ? -1 : (aa > bb) ;
 }
@@ -286,7 +287,7 @@ int main (int argc, char const *const *argv)
 
     {
       AVLTREEB_TYPE(n+1) pidtree ;
-      avltreeb_init(&pidtree, n+1, &pid_dtok, &uint_cmp, p) ;
+      avltreeb_init(&pidtree, n+1, &pid_dtok, &uint32_cmp, p) ;
       for (i = 0 ; i < n ; i++)
       {
         if (needstat && !s6ps_statparse(p+i))
diff --git a/src/minutils/s6-ps.h b/src/minutils/s6-ps.h
index 9afd701..f92488d 100644
--- a/src/minutils/s6-ps.h
+++ b/src/minutils/s6-ps.h
@@ -14,7 +14,7 @@
 typedef struct dius_s dius_t, *dius_t_ref ;
 struct dius_s
 {
-  unsigned int left ;
+  uint32_t left ;
   size_t right ;
 } ;
 #define DIUS_ZERO { .left = 0, .right = 0 }
@@ -146,7 +146,7 @@ typedef pfieldfmt_func_t *pfieldfmt_func_t_ref ;
 extern pfieldfmt_func_t_ref *s6ps_pfield_fmt ;
 
 extern void *left_dtok (unsigned int, void *) ;
-extern int uint_cmp (void const *, void const *, void *) ;
+extern int uint32_cmp (void const *, void const *, void *) ;
 extern int s6ps_pwcache_init (void) ;
 extern void s6ps_pwcache_finish (void) ;
 extern int s6ps_pwcache_lookup (stralloc *, uid_t) ;
diff --git a/src/minutils/s6ps_grcache.c b/src/minutils/s6ps_grcache.c
index f41ccf4..ba62098 100644
--- a/src/minutils/s6ps_grcache.c
+++ b/src/minutils/s6ps_grcache.c
@@ -1,5 +1,6 @@
 /* ISC license. */
 
+#include <stdint.h>
 #include <grp.h>
 #include <errno.h>
 #include <skalibs/types.h>
@@ -14,7 +15,7 @@ static genalloc grcache_index = GENALLOC_ZERO ;
 
 int s6ps_grcache_init (void)
 {
-  avltree_init(&grcache_tree, 5, 3, 8, &left_dtok, &uint_cmp, &grcache_index) ;
+  avltree_init(&grcache_tree, 5, 3, 8, &left_dtok, &uint32_cmp, &grcache_index) ;
   return 1 ;
 }
 
@@ -27,8 +28,8 @@ void s6ps_grcache_finish (void)
 int s6ps_grcache_lookup (stralloc *sa, gid_t gid)
 {
   int wasnull = !satmp.s ;
-  dius_t d = { .left = (unsigned int)gid, .right = satmp.len } ;
-  unsigned int i ;
+  dius_t d = { .left = (uint32_t)gid, .right = satmp.len } ;
+  uint32_t i ;
   if (!avltree_search(&grcache_tree, &d.left, &i))
   {
     struct group *gr ;
diff --git a/src/minutils/s6ps_otree.c b/src/minutils/s6ps_otree.c
index 0f7ccf1..f7952ab 100644
--- a/src/minutils/s6ps_otree.c
+++ b/src/minutils/s6ps_otree.c
@@ -59,7 +59,7 @@ void s6ps_otree (pscan_t *p, unsigned int n, avltreen *pidtree, unsigned int *or
  /* Compute the ppid tree */
   for (i = 0 ; i < n ; i++)
   {
-    unsigned int k ;
+    uint32_t k ;
     if (!avltreen_search(pidtree, &p[i].ppid, &k)) k = n-1 ;
     orderedlist[i] = k ; /* using orderedlist as ppindex */
     nchild[k]++ ;
diff --git a/src/minutils/s6ps_pwcache.c b/src/minutils/s6ps_pwcache.c
index 2f4c329..283a393 100644
--- a/src/minutils/s6ps_pwcache.c
+++ b/src/minutils/s6ps_pwcache.c
@@ -1,6 +1,7 @@
 /* ISC license. */
 
 #include <sys/types.h>
+#include <stdint.h>
 #include <pwd.h>
 #include <errno.h>
 #include <skalibs/types.h>
@@ -15,7 +16,7 @@ static genalloc pwcache_index = GENALLOC_ZERO ;
 
 int s6ps_pwcache_init (void)
 {
-  avltree_init(&pwcache_tree, 5, 3, 8, &left_dtok, &uint_cmp, &pwcache_index) ;
+  avltree_init(&pwcache_tree, 5, 3, 8, &left_dtok, &uint32_cmp, &pwcache_index) ;
   return 1 ;
 }
 
@@ -28,8 +29,8 @@ void s6ps_pwcache_finish (void)
 int s6ps_pwcache_lookup (stralloc *sa, uid_t uid)
 {
   int wasnull = !satmp.s ;
-  dius_t d = { .left = (unsigned int)uid, .right = satmp.len } ;
-  unsigned int i ;
+  dius_t d = { .left = (uint32_t)uid, .right = satmp.len } ;
+  uint32_t i ;
   if (!avltree_search(&pwcache_tree, &d.left, &i))
   {
     struct passwd *pw ;
diff --git a/src/minutils/s6ps_ttycache.c b/src/minutils/s6ps_ttycache.c
index df59334..7fa4bc0 100644
--- a/src/minutils/s6ps_ttycache.c
+++ b/src/minutils/s6ps_ttycache.c
@@ -5,6 +5,7 @@
 #endif
 
 #include <string.h>
+#include <stdint.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <skalibs/types.h>
@@ -22,7 +23,7 @@ static genalloc ttycache_index = GENALLOC_ZERO ;
 
 int s6ps_ttycache_init (void)
 {
-  avltree_init(&ttycache_tree, 5, 3, 8, &left_dtok, &uint_cmp, &ttycache_index) ;
+  avltree_init(&ttycache_tree, 5, 3, 8, &left_dtok, &uint32_cmp, &ttycache_index) ;
   return 1 ;
 }
 
@@ -112,8 +113,8 @@ static int ttyguess (stralloc *sa, dev_t ttynr)
 int s6ps_ttycache_lookup (stralloc *sa, dev_t ttynr)
 {
   int wasnull = !satmp.s ;
-  dius_t d = { .left = (unsigned int)ttynr, .right = satmp.len } ;
-  unsigned int i ;
+  dius_t d = { .left = (uint32_t)ttynr, .right = satmp.len } ;
+  uint32_t i ;
   if (!avltree_search(&ttycache_tree, &d.left, &i))
   {
     unsigned int n = genalloc_len(dius_t, &ttycache_index) ;