diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-17 22:30:53 +0000 |
commit | fdffefb8032922ce7ffe4c00816072a8ff2148fc (patch) | |
tree | bc7313151a429c45d8bab8ad8b9dd32f4e51335f /src/libunixonacid/unixmessage_sender_flush.c | |
parent | a896ca2a8c617e5e00ffd5fc9e69331ad754e5b3 (diff) | |
download | skalibs-fdffefb8032922ce7ffe4c00816072a8ff2148fc.tar.xz |
More types changes
New disize
Add size_t to the autotypes list
Delete redundant and replace-libc files
dev_t/ino_t pass
Big size_t pass
More things missing, still not operational yet
Diffstat (limited to 'src/libunixonacid/unixmessage_sender_flush.c')
-rw-r--r-- | src/libunixonacid/unixmessage_sender_flush.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index 57c5d6e..8cfb709 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -4,12 +4,13 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <sys/uio.h> +#include <stdint.h> #include <unistd.h> #include <errno.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> #include <skalibs/bytestr.h> -#include <skalibs/diuint.h> +#include <skalibs/disize.h> #include <skalibs/allreadwrite.h> #include <skalibs/genalloc.h> #include <skalibs/djbunix.h> @@ -27,28 +28,28 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) { - diuint last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; - diuint *offsets = genalloc_s(diuint, &b->offsets) ; - unsigned int n = genalloc_len(diuint, &b->offsets) ; - register int r ; + disize last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; + disize *offsets = genalloc_s(disize, &b->offsets) ; + size_t n = genalloc_len(disize, &b->offsets) ; + ssize_t r ; if (b->shorty) /* we had a short write, gotta send the remainder first */ { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; if (b->shorty <= len) r = fd_write(b->fd, b->data.s + offsets[b->head].left + (len - b->shorty), b->shorty) ; else { - unsigned int nfds = next->right - offsets[b->head].right ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { { .iov_base = pack + 6 - (b->shorty - len), .iov_len = b->shorty - len }, { .iov_base = b->data.s + offsets[b->head].left, .iov_len = len } } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; r = fd_writev(b->fd, v, 2) ; } if (r <= 0) return 0 ; @@ -58,9 +59,9 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) for (; b->head < n ; b->head++) { - diuint *next = b->head+1 < n ? offsets + b->head+1 : &last ; - unsigned int len = next->left - offsets[b->head].left ; - unsigned int nfds = next->right - offsets[b->head].right ; + disize *next = b->head+1 < n ? offsets + b->head+1 : &last ; + size_t len = next->left - offsets[b->head].left ; + size_t nfds = next->right - offsets[b->head].right ; char pack[6] ; struct iovec v[2] = { @@ -77,19 +78,19 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) .msg_control = nfds ? ancilbuf : 0, .msg_controllen = nfds ? sizeof(ancilbuf) : 0 } ; - uint32_pack_big(pack, (uint32)len) ; - uint16_pack_big(pack + 4, (uint16)nfds) ; + uint32_pack_big(pack, (uint32_t)len) ; + uint16_pack_big(pack + 4, (uint16_t)nfds) ; if (nfds) { struct cmsghdr *cp = CMSG_FIRSTHDR(&hdr) ; - register unsigned int i = 0 ; + size_t i = 0 ; byte_zero(ancilbuf, sizeof(ancilbuf)) ; cp->cmsg_level = SOL_SOCKET ; cp->cmsg_type = SCM_RIGHTS ; cp->cmsg_len = CMSG_LEN(nfds * sizeof(int)) ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; ((int *)CMSG_DATA(cp))[i] = fd < 0 ? -(fd+1) : fd ; } } @@ -99,15 +100,15 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) #ifndef SKALIBS_HASANCILAUTOCLOSE if (nfds) { - register unsigned int i = 0 ; + size_t i = 0 ; for (; i < nfds ; i++) { - register int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; + int fd = genalloc_s(int, &b->fds)[offsets[b->head].right + i] ; if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; } } #endif - if ((unsigned int)r < 6 + len) + if ((size_t)r < 6 + len) { b->shorty = 6 + len - r ; return (errno = EWOULDBLOCK, 0) ; @@ -115,7 +116,7 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) } b->data.len = 0 ; genalloc_setlen(int, &b->fds, 0) ; - genalloc_setlen(diuint, &b->offsets, 0) ; + genalloc_setlen(disize, &b->offsets, 0) ; b->head = 0 ; return 1 ; } |