diff options
Diffstat (limited to 'src/libstddjb')
-rw-r--r-- | src/libstddjb/byte_chr.c | 13 | ||||
-rw-r--r-- | src/libstddjb/socket_accept6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_bind4.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_bind6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_conn4.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_conn6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_local46.c | 4 | ||||
-rw-r--r-- | src/libstddjb/socket_local6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_recv6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_remote46.c | 4 | ||||
-rw-r--r-- | src/libstddjb/socket_remote6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/socket_send6.c | 2 | ||||
-rw-r--r-- | src/libstddjb/str_len.c | 11 |
13 files changed, 19 insertions, 31 deletions
diff --git a/src/libstddjb/byte_chr.c b/src/libstddjb/byte_chr.c index e9caef5..45ad543 100644 --- a/src/libstddjb/byte_chr.c +++ b/src/libstddjb/byte_chr.c @@ -17,17 +17,10 @@ unsigned int byte_chr (char const *s, unsigned int n, int c) unsigned int byte_chr (char const *s, unsigned int n, int c) { + register unsigned int i = 0 ; register char ch = c ; - register char const *t = s ; - - for (;;) - { - if (!n) break; if (*t == ch) break; ++t; --n; - if (!n) break; if (*t == ch) break; ++t; --n; - if (!n) break; if (*t == ch) break; ++t; --n; - if (!n) break; if (*t == ch) break; ++t; --n; - } - return t - s ; + for (; i < n && *s++ != ch ; i++) ; + return i ; } #endif diff --git a/src/libstddjb/socket_accept6.c b/src/libstddjb/socket_accept6.c index 8e87e46..f52efbb 100644 --- a/src/libstddjb/socket_accept6.c +++ b/src/libstddjb/socket_accept6.c @@ -36,7 +36,7 @@ int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int option return -1 ; } #endif - byte_copy(ip6, 16, sa.sin6_addr.s6_addr) ; + byte_copy(ip6, 16, (char const *)sa.sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return fd ; } diff --git a/src/libstddjb/socket_bind4.c b/src/libstddjb/socket_bind4.c index e9c9593..1078fbc 100644 --- a/src/libstddjb/socket_bind4.c +++ b/src/libstddjb/socket_bind4.c @@ -14,6 +14,6 @@ int socket_bind4 (int s, char const *ip, uint16 port) sa.sin_family = AF_INET ; uint16_big_endian((char *)&port, 1) ; sa.sin_port = port ; - byte_copy(&sa.sin_addr.s_addr, 4, ip) ; + byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/socket_bind6.c b/src/libstddjb/socket_bind6.c index fa4cae1..63fa412 100644 --- a/src/libstddjb/socket_bind6.c +++ b/src/libstddjb/socket_bind6.c @@ -17,7 +17,7 @@ int socket_bind6 (int s, char const *ip6, uint16 port) byte_zero(&sa, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port, port) ; - byte_copy(sa.sin6_addr.s6_addr, 16, ip6) ; + byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/socket_conn4.c b/src/libstddjb/socket_conn4.c index 0180378..12459a8 100644 --- a/src/libstddjb/socket_conn4.c +++ b/src/libstddjb/socket_conn4.c @@ -16,7 +16,7 @@ int socket_connect4 (int s, char const *ip, uint16 port) sa.sin_family = AF_INET ; uint16_big_endian((char *)&port, 1) ; sa.sin_port = port ; - byte_copy(&sa.sin_addr.s_addr, 4, ip) ; + byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; diff --git a/src/libstddjb/socket_conn6.c b/src/libstddjb/socket_conn6.c index 49a64d1..57bb3f8 100644 --- a/src/libstddjb/socket_conn6.c +++ b/src/libstddjb/socket_conn6.c @@ -18,7 +18,7 @@ int socket_connect6 (int s, char const *ip6, uint16 port) byte_zero(&sa, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port,port) ; - byte_copy(sa.sin6_addr.s6_addr, 16, ip6) ; + byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c index 6235527..448160c 100644 --- a/src/libstddjb/socket_local46.c +++ b/src/libstddjb/socket_local46.c @@ -18,14 +18,14 @@ int socket_local46 (int s, ip46_t *ip, uint16 *port) if (sa.sa_family == AF_INET6) { register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; - byte_copy(ip->ip, 16, sa6->sin6_addr.s6_addr) ; + byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa6->sin6_port, port) ; ip->is6 = 1 ; } else if (sa.sa_family == AF_INET) { register struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; - byte_copy(ip->ip, 4, &sa4->sin_addr.s_addr) ; + byte_copy(ip->ip, 4, (char const *)&sa4->sin_addr.s_addr) ; uint16_unpack_big((char *)&sa4->sin_port, port) ; ip->is6 = 0 ; } diff --git a/src/libstddjb/socket_local6.c b/src/libstddjb/socket_local6.c index 31ee1f0..b7025fc 100644 --- a/src/libstddjb/socket_local6.c +++ b/src/libstddjb/socket_local6.c @@ -17,7 +17,7 @@ int socket_local6 (int s, char *ip, uint16 *port) if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 16, sa.sin6_addr.s6_addr) ; + byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return 0 ; } diff --git a/src/libstddjb/socket_recv6.c b/src/libstddjb/socket_recv6.c index d745604..6b2b4fc 100644 --- a/src/libstddjb/socket_recv6.c +++ b/src/libstddjb/socket_recv6.c @@ -19,7 +19,7 @@ int socket_recv6 (int s, char *buf, unsigned int len, char *ip6, uint16 *port) do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; - byte_copy(ip6, 16, sa.sin6_addr.s6_addr) ; + byte_copy(ip6, 16, (char const *)sa.sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return r ; } diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c index bf6b934..da91417 100644 --- a/src/libstddjb/socket_remote46.c +++ b/src/libstddjb/socket_remote46.c @@ -18,14 +18,14 @@ int socket_remote46 (int s, ip46_t *ip, uint16 *port) if (sa.sa_family == AF_INET6) { register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; - byte_copy(ip->ip, 16, sa6->sin6_addr.s6_addr) ; + byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa6->sin6_port, port) ; ip->is6 = 1 ; } else if (sa.sa_family == AF_INET) { register struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; - byte_copy(ip->ip, 4, &sa4->sin_addr.s_addr) ; + byte_copy(ip->ip, 4, (char const *)&sa4->sin_addr.s_addr) ; uint16_unpack_big((char *)&sa4->sin_port, port) ; ip->is6 = 0 ; } diff --git a/src/libstddjb/socket_remote6.c b/src/libstddjb/socket_remote6.c index 9d40d70..4c642e1 100644 --- a/src/libstddjb/socket_remote6.c +++ b/src/libstddjb/socket_remote6.c @@ -18,7 +18,7 @@ int socket_remote6 (int s, char *ip, uint16 *port) if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 16, sa.sin6_addr.s6_addr) ; + byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return 0 ; } diff --git a/src/libstddjb/socket_send6.c b/src/libstddjb/socket_send6.c index 01319a1..6349cdb 100644 --- a/src/libstddjb/socket_send6.c +++ b/src/libstddjb/socket_send6.c @@ -18,7 +18,7 @@ int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uin byte_zero((char *)&sa, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port, port) ; - byte_copy(sa.sin6_addr.s6_addr, 16, ip6) ; + byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/str_len.c b/src/libstddjb/str_len.c index 4db2f4c..75bd1f2 100644 --- a/src/libstddjb/str_len.c +++ b/src/libstddjb/str_len.c @@ -8,14 +8,9 @@ unsigned int str_len (char const *s) { - register char const *t = s ; - for (;;) - { - if (!*t) return t - s; ++t; - if (!*t) return t - s; ++t; - if (!*t) return t - s; ++t; - if (!*t) return t - s; ++t; - } + register unsigned int len = 0 ; + while (*s++) len++ ; + return len ; } #endif |