From e450f6efc39e55e32264d2daded6c757af0f7527 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 13 Mar 2017 10:31:14 +0000 Subject: Cleanups - mostly removing superfluous includes in headers --- src/include/skalibs/allreadwrite.h | 2 -- src/include/skalibs/bitarray.h | 5 ++--- src/include/skalibs/buffer.h | 2 -- src/include/skalibs/bytestr.h | 12 +++++------- src/include/skalibs/cbuffer.h | 1 - src/include/skalibs/djbunix.h | 2 -- src/include/skalibs/genalloc.h | 1 - src/include/skalibs/iopause.h | 1 - src/include/skalibs/netstring.h | 1 - src/include/skalibs/nonposix.h | 2 +- src/include/skalibs/selfpipe.h | 2 -- src/include/skalibs/siovec.h | 1 - src/include/skalibs/tai.h | 1 - src/include/skalibs/unix-transactional.h | 4 ++-- src/include/skalibs/unixmessage.h | 1 - src/libstddjb/bitarray_count.c | 5 ++--- src/libstddjb/buffer_get.c | 2 +- src/libstddjb/selfpipe_read.c | 4 ++-- 18 files changed, 15 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h index 9e42c1c..254d766 100644 --- a/src/include/skalibs/allreadwrite.h +++ b/src/include/skalibs/allreadwrite.h @@ -3,10 +3,8 @@ #ifndef ALLREADWRITE_H #define ALLREADWRITE_H -#include #include #include -#include extern ssize_t sanitize_read (ssize_t) ; extern ssize_t unsanitize_read (ssize_t) ; diff --git a/src/include/skalibs/bitarray.h b/src/include/skalibs/bitarray.h index 7344492..b333425 100644 --- a/src/include/skalibs/bitarray.h +++ b/src/include/skalibs/bitarray.h @@ -3,9 +3,8 @@ #ifndef BITARRAY_H #define BITARRAY_H -#include +#include #include -#include #define bitarray_div8(n) ((n) ? 1U + (((n) - 1) >> 3) : 0U) @@ -31,7 +30,7 @@ extern size_t bitarray_firstclear_skip (unsigned char const *, size_t, size_t) g extern size_t bitarray_firstset_skip (unsigned char const *, size_t, size_t) gccattr_pure ; #define bitarray_first_skip(s, n, k, h) ((h) ? bitarray_firstset_skip(s, n, k) : bitarray_firstclear_skip(s, n, k)) -extern uint64_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; +extern size_t bitarray_countones (unsigned char const *, size_t) gccattr_pure ; extern void bitarray_not (unsigned char *, size_t, size_t) ; extern void bitarray_and (unsigned char *, unsigned char const *, unsigned char const *, size_t) ; diff --git a/src/include/skalibs/buffer.h b/src/include/skalibs/buffer.h index 18db87e..a118a6d 100644 --- a/src/include/skalibs/buffer.h +++ b/src/include/skalibs/buffer.h @@ -3,9 +3,7 @@ #ifndef BUFFER_H #define BUFFER_H -#include #include -#include #include #include #include diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h index 25f05d3..1f3942b 100644 --- a/src/include/skalibs/bytestr.h +++ b/src/include/skalibs/bytestr.h @@ -10,10 +10,8 @@ #define T8(x) ((x) & 0xffU) #include -#include #include #include -#include #define byte_copy(to, n, from) memmove(to, (from), n) #define byte_copyr(to, n, from) memmove(to, (from), n) @@ -36,14 +34,14 @@ extern size_t byte_chr (char const *, size_t, int) gccattr_pure ; extern size_t byte_rchr (char const *, size_t, int) gccattr_pure ; extern size_t byte_in (char const *, size_t, char const *, size_t) gccattr_pure ; -#define byte_equal(s, n, t) (!byte_diff((s), (n), (t))) +#define byte_equal(s, n, t) (!memcmp(s, (t), n)) extern size_t byte_count (char const *, size_t, char) gccattr_pure ; -#define str_diffb(a, n, b) str_diffn(a, (b), n) +#define str_diffb(a, n, b) strncmp(a, (b), n) extern size_t str_chr (char const *, int) gccattr_pure ; extern size_t str_rchr (char const *, int) gccattr_pure ; extern int str_start (char const *, char const *) gccattr_pure ; -#define str_equal(s, t) (!str_diff(s, t)) +#define str_equal(s, t) (!strcmp(s, t)) extern size_t str_strn (char const *, size_t, char const *, size_t) gccattr_pure ; extern void case_lowers (char *) ; @@ -51,8 +49,8 @@ extern void case_lowerb (char *, size_t) ; extern void case_uppers (char *) ; extern void case_upperb (char *, size_t) ; #define case_diffb(a, n, b) case_diffn(a, (b), n) -#define case_equals(a, b) (!case_diffs(a, b)) -#define case_equalb(a, n, b) (!case_diffb(a, n, b)) +#define case_equals(a, b) (!strcasecmp(a, b)) +#define case_equalb(a, n, b) (!strcasecmp(a, (b), n)) #define case_starts(s, t) case_startb(s, strlen(s), t) extern int case_startb (char const *, size_t, char const *) gccattr_pure ; extern size_t case_str (char const *, char const *) gccattr_pure ; diff --git a/src/include/skalibs/cbuffer.h b/src/include/skalibs/cbuffer.h index 19b3078..c29af5d 100644 --- a/src/include/skalibs/cbuffer.h +++ b/src/include/skalibs/cbuffer.h @@ -3,7 +3,6 @@ #ifndef CBUFFER_H #define CBUFFER_H -#include #include #include #include diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index af76ec4..fb08658 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -6,8 +6,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/include/skalibs/genalloc.h b/src/include/skalibs/genalloc.h index 9c81acd..da83c2f 100644 --- a/src/include/skalibs/genalloc.h +++ b/src/include/skalibs/genalloc.h @@ -3,7 +3,6 @@ #ifndef GENALLOC_H #define GENALLOC_H -#include #include #include diff --git a/src/include/skalibs/iopause.h b/src/include/skalibs/iopause.h index d8f5e1c..8c8fddc 100644 --- a/src/include/skalibs/iopause.h +++ b/src/include/skalibs/iopause.h @@ -3,7 +3,6 @@ #ifndef IOPAUSE_H #define IOPAUSE_H -#include #include #include diff --git a/src/include/skalibs/netstring.h b/src/include/skalibs/netstring.h index 941011a..d41d1dd 100644 --- a/src/include/skalibs/netstring.h +++ b/src/include/skalibs/netstring.h @@ -3,7 +3,6 @@ #ifndef NETSTRING_H #define NETSTRING_H -#include #include #include #include diff --git a/src/include/skalibs/nonposix.h b/src/include/skalibs/nonposix.h index 26af211..ebce175 100644 --- a/src/include/skalibs/nonposix.h +++ b/src/include/skalibs/nonposix.h @@ -51,7 +51,7 @@ /* old versions of BSD: system headers are not self-contained, - starting with sys/types.h is the usual workaround */ + starting with sys/types.h normally always works. */ #include diff --git a/src/include/skalibs/selfpipe.h b/src/include/skalibs/selfpipe.h index c587f93..849db4a 100644 --- a/src/include/skalibs/selfpipe.h +++ b/src/include/skalibs/selfpipe.h @@ -1,7 +1,5 @@ /* ISC license. */ -/* MT-unsafe */ - #ifndef SELFPIPE_H #define SELFPIPE_H diff --git a/src/include/skalibs/siovec.h b/src/include/skalibs/siovec.h index a543d93..2fb987f 100644 --- a/src/include/skalibs/siovec.h +++ b/src/include/skalibs/siovec.h @@ -3,7 +3,6 @@ #ifndef SIOVEC_H #define SIOVEC_H -#include #include #include diff --git a/src/include/skalibs/tai.h b/src/include/skalibs/tai.h index 6ff8be7..53aad92 100644 --- a/src/include/skalibs/tai.h +++ b/src/include/skalibs/tai.h @@ -3,7 +3,6 @@ #ifndef TAI_H #define TAI_H -#include #include #include #include diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h index b1decb5..41b31b7 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -4,8 +4,8 @@ #define UNIX_TRANSACTIONAL_H #include -#include #include +#include #include #include @@ -59,7 +59,7 @@ extern int dd_open_write (dirdescriptor_t *, char const *, unsigned int) ; extern int dd_close (dirdescriptor_t *) ; /* after dd_open_read */ extern void dd_cancel (dirdescriptor_t *) ; /* after dd_open_write */ extern int dd_commit (dirdescriptor_t *) ; /* after dd_open_write */ -extern int dd_commit_devino (dirdescriptor_t *, uint64 *, uint64 *) ; /* after dd_open_write */ +extern int dd_commit_devino (dirdescriptor_t *, dev_t *, ino_t *) ; /* after dd_open_write */ #define dd_openreadnclose(blah, file, s, len) openreadnclose_at((blah)->fd, file, s, len) #define dd_openslurpclose(blah, file, sa) openslurpclose_at((blah)->fd, file, sa) diff --git a/src/include/skalibs/unixmessage.h b/src/include/skalibs/unixmessage.h index 4c98ed6..34386c3 100644 --- a/src/include/skalibs/unixmessage.h +++ b/src/include/skalibs/unixmessage.h @@ -3,7 +3,6 @@ #ifndef UNIXMESSAGE_H #define UNIXMESSAGE_H -#include #include #include #include diff --git a/src/libstddjb/bitarray_count.c b/src/libstddjb/bitarray_count.c index 8f4ab50..19ed09e 100644 --- a/src/libstddjb/bitarray_count.c +++ b/src/libstddjb/bitarray_count.c @@ -1,7 +1,6 @@ /* ISC license. */ #include -#include #include #define B0(n) n, n+1, n+1, n+2 @@ -9,11 +8,11 @@ #define B2(n) B1(n), B1(n+1), B1(n+1), B1(n+2) #define B3(n) B2(n), B2(n+1), B2(n+1), B2(n+2) -uint64_t bitarray_countones (unsigned char const *c, size_t n) +size_t bitarray_countones (unsigned char const *c, size_t n) { static unsigned char const table[256] = { B3(0) } ; size_t len = bitarray_div8(n) ; - uint64_t total = 0 ; + size_t total = 0 ; size_t i = 0 ; if (n & 7) len-- ; for (; i < len ; i++) total += table[c[i]] ; diff --git a/src/libstddjb/buffer_get.c b/src/libstddjb/buffer_get.c index 0d689ef..bf01012 100644 --- a/src/libstddjb/buffer_get.c +++ b/src/libstddjb/buffer_get.c @@ -8,6 +8,6 @@ ssize_t buffer_get (buffer *b, char *s, size_t len) { size_t w = 0 ; int r = buffer_getall(b, s, len, &w) ; - return r == -1 ? errno == EPIPE ? (errno = 0, (ssize_t)w) : -1 : + return r == -1 ? errno == EPIPE ? (errno = 0, w) : -1 : !r ? (errno = EWOULDBLOCK, -1) : w ; } diff --git a/src/libstddjb/selfpipe_read.c b/src/libstddjb/selfpipe_read.c index b31c6bd..92adf02 100644 --- a/src/libstddjb/selfpipe_read.c +++ b/src/libstddjb/selfpipe_read.c @@ -16,7 +16,7 @@ int selfpipe_read (void) { struct signalfd_siginfo buf ; ssize_t r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ; - return (r <= 0) ? r : (int)buf.ssi_signo ; + return (r <= 0) ? r : buf.ssi_signo ; } #else @@ -25,7 +25,7 @@ int selfpipe_read (void) { char c ; ssize_t r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ; - return (r <= 0) ? r : (int)c ; + return (r <= 0) ? r : c ; } #endif -- cgit v1.2.3