From 49d8fa1058aaf23c29e074b2314492ae40d2f557 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 21 Feb 2017 12:05:07 +0000 Subject: Types change: big pass on libstddjb and libunixonacid libdatastruct still missing, library still not functional --- src/libstddjb/allreadv.c | 1 - src/libstddjb/allreadwritev.c | 1 - src/libstddjb/allwritev.c | 1 - src/libstddjb/bitarray_firstclear_skip.c | 6 ++--- src/libstddjb/bitarray_firstset_skip.c | 6 ++--- src/libstddjb/buffer_fill.c | 1 - src/libstddjb/buffer_flush.c | 1 - src/libstddjb/buffer_flush1read.c | 1 - src/libstddjb/buffer_getv.c | 1 - src/libstddjb/buffer_getvall.c | 1 - src/libstddjb/buffer_getvallnf.c | 1 - src/libstddjb/buffer_putv.c | 1 - src/libstddjb/buffer_putvall.c | 1 - src/libstddjb/buffer_putvallnf.c | 1 - src/libstddjb/buffer_putvflush.c | 1 - src/libstddjb/case_lowerb.c | 2 +- src/libstddjb/case_lowers.c | 4 +-- src/libstddjb/case_startb.c | 6 ++--- src/libstddjb/case_str.c | 4 +-- src/libstddjb/case_upperb.c | 1 + src/libstddjb/case_uppers.c | 4 +-- src/libstddjb/cbuffer_get.c | 1 - src/libstddjb/cbuffer_getv.c | 1 - src/libstddjb/cbuffer_put.c | 1 - src/libstddjb/cbuffer_putv.c | 1 - src/libstddjb/cbuffer_wpeek.c | 1 - src/libstddjb/cdb_findnext.c | 13 +++++----- src/libstddjb/cdb_hash.c | 8 +++--- src/libstddjb/cdb_init_map.c | 7 ++++++ src/libstddjb/cdb_make.c | 34 ++++++++++++++------------ src/libstddjb/cdb_mapfile.c | 2 +- src/libstddjb/cdb_nextkey.c | 5 ++-- src/libstddjb/cdb_read.c | 11 +++++---- src/libstddjb/cdb_successor.c | 5 ++-- src/libstddjb/dir_close.c | 2 +- src/libstddjb/djbtime-internal.h | 6 ++--- src/libstddjb/env_addmodif.c | 3 ++- src/libstddjb/env_get2.c | 7 +++--- src/libstddjb/env_len.c | 5 ++-- src/libstddjb/env_make.c | 6 ++--- src/libstddjb/env_merge.c | 17 +++++++------ src/libstddjb/env_string.c | 7 +++--- src/libstddjb/envalloc_make.c | 3 ++- src/libstddjb/envalloc_merge.c | 5 ++-- src/libstddjb/envalloc_uniq.c | 15 ++++++------ src/libstddjb/error_temp.c | 2 +- src/libstddjb/fd_cat.c | 2 +- src/libstddjb/fd_catn.c | 2 +- src/libstddjb/fd_chdir.c | 2 +- src/libstddjb/fd_chmod.c | 2 +- src/libstddjb/fd_chown.c | 2 +- src/libstddjb/fd_copy.c | 2 +- src/libstddjb/fd_ensure_open.c | 2 +- src/libstddjb/fd_move.c | 2 +- src/libstddjb/fd_move2.c | 6 ++--- src/libstddjb/fd_readv.c | 1 - src/libstddjb/fd_recv.c | 4 +-- src/libstddjb/fd_send.c | 4 +-- src/libstddjb/fd_sync.c | 2 +- src/libstddjb/fd_writev.c | 3 +-- src/libstddjb/fmtscan-internal.h | 32 ++++++++++++------------ src/libstddjb/fmtscan_num.c | 2 +- src/libstddjb/genalloc_deepfree.c | 2 +- src/libstddjb/genwrite_flush_bufalloc.c | 3 +-- src/libstddjb/genwrite_flush_buffer.c | 3 +-- src/libstddjb/genwrite_put_bufalloc.c | 3 +-- src/libstddjb/genwrite_put_buffer.c | 3 +-- src/libstddjb/genwrite_put_stralloc.c | 3 +-- src/libstddjb/getlnmax.c | 3 +-- src/libstddjb/getlnmaxsep.c | 1 - src/libstddjb/getpeereid.c | 2 +- src/libstddjb/hiercopy.c | 2 +- src/libstddjb/hiercopy_tmp.c | 3 +-- src/libstddjb/iobuffer_fill.c | 5 ++-- src/libstddjb/iobuffer_kfromu.c | 1 - src/libstddjb/iobuffer_ufromk.c | 3 ++- src/libstddjb/iobufferk_fill.c | 24 +++++++++++------- src/libstddjb/iobufferk_flush.c | 16 ++++++++---- src/libstddjb/iobufferk_init.c | 6 ++--- src/libstddjb/iobufferk_isworking.c | 3 +-- src/libstddjb/iobufferk_nosys.c | 10 -------- src/libstddjb/iobufferu_fill.c | 4 +-- src/libstddjb/iobufferu_flush.c | 2 +- src/libstddjb/iopause_poll.c | 2 +- src/libstddjb/iopause_select.c | 4 +-- src/libstddjb/iopause_stamp.c | 4 +-- src/libstddjb/ip46_scanlist.c | 9 +++---- src/libstddjb/ip4_scan.c | 4 +-- src/libstddjb/ip4_scanlist.c | 7 +++--- src/libstddjb/ip4_scanlist_u32.c | 8 +++--- src/libstddjb/ip6_scan.c | 2 +- src/libstddjb/ip6_scanlist.c | 9 +++---- src/libstddjb/ipc_accept.c | 11 +++++---- src/libstddjb/ipc_bind.c | 8 +++--- src/libstddjb/ipc_connect.c | 8 +++--- src/libstddjb/ipc_connected.c | 2 +- src/libstddjb/ipc_eid.c | 15 ------------ src/libstddjb/ipc_local.c | 7 +++--- src/libstddjb/ipc_recv.c | 12 ++++----- src/libstddjb/ipc_send.c | 10 ++++---- src/libstddjb/ipc_timed_connect.c | 2 +- src/libstddjb/leapsecs_add.c | 6 ++--- src/libstddjb/leapsecs_sub.c | 10 ++++---- src/libstddjb/leapsecs_table.c | 4 +-- src/libstddjb/localtm_from_ltm64.c | 3 +-- src/libstddjb/localtm_from_sysclock.c | 3 +-- src/libstddjb/localtm_from_tai.c | 3 +-- src/libstddjb/localtm_from_utc.c | 3 +-- src/libstddjb/localtm_scan.c | 2 +- src/libstddjb/localtmn_from_sysclock.c | 1 + src/libstddjb/localtmn_from_tain.c | 1 + src/libstddjb/localtmn_scan.c | 2 +- src/libstddjb/lock_ex.c | 7 ++---- src/libstddjb/lock_exnb.c | 7 ++---- src/libstddjb/lock_sh.c | 11 +++------ src/libstddjb/lock_shnb.c | 11 +++------ src/libstddjb/lock_un.c | 11 +++------ src/libstddjb/ltm64_from_localtm.c | 5 ++-- src/libstddjb/ltm64_from_sysclock.c | 6 ++--- src/libstddjb/ltm64_from_tai.c | 2 +- src/libstddjb/ltm64_from_utc.c | 2 +- src/libstddjb/mininetstring_read.c | 13 +++++----- src/libstddjb/mininetstring_write.c | 4 +-- src/libstddjb/netstring_append.c | 7 +++--- src/libstddjb/netstring_appendv.c | 8 +++--- src/libstddjb/netstring_decode.c | 4 +-- src/libstddjb/netstring_encode.c | 2 +- src/libstddjb/netstring_put.c | 6 ++--- src/libstddjb/ntp_from_tain.c | 4 +-- src/libstddjb/open2.c | 5 ++-- src/libstddjb/open3.c | 3 +-- src/libstddjb/open_readb.c | 6 ++--- src/libstddjb/pathexec0.c | 2 -- src/libstddjb/pipe_internal.c | 7 +++++- src/libstddjb/prot_readgroups.c | 8 +++--- src/libstddjb/realpath.c | 11 --------- src/libstddjb/realpath_tmp.c | 26 -------------------- src/libstddjb/sabasename.c | 2 +- src/libstddjb/sadirname.c | 2 +- src/libstddjb/sagetcwd.c | 6 ++--- src/libstddjb/sagethostname.c | 6 ++--- src/libstddjb/sareadlink.c | 6 ++--- src/libstddjb/sauniquename.c | 6 ++--- src/libstddjb/seek_cur.c | 10 -------- src/libstddjb/seek_set.c | 10 -------- src/libstddjb/selfpipe_finish.c | 2 +- src/libstddjb/selfpipe_read.c | 5 ++-- src/libstddjb/selfpipe_trapset.c | 2 +- src/libstddjb/selfpipe_untrap.c | 4 +-- src/libstddjb/sig_number.c | 6 ++--- src/libstddjb/sig_restoreto.c | 4 +-- src/libstddjb/siovec_bytechr.c | 1 - src/libstddjb/siovec_bytein.c | 1 - src/libstddjb/siovec_deal.c | 1 - src/libstddjb/siovec_gather.c | 1 - src/libstddjb/siovec_len.c | 1 - src/libstddjb/siovec_scatter.c | 1 - src/libstddjb/siovec_seek.c | 3 +-- src/libstddjb/siovec_trunc.c | 1 - src/libstddjb/skagetln_nofill.c | 1 - src/libstddjb/skagetlnsep.c | 1 - src/libstddjb/skalibs_tzisright.c | 1 - src/libstddjb/skasigaction.c | 2 +- src/libstddjb/slurp.c | 14 ++++++++--- src/libstddjb/socket_accept4.c | 11 +++++---- src/libstddjb/socket_accept4_u32.c | 10 ++++---- src/libstddjb/socket_accept6.c | 13 +++++----- src/libstddjb/socket_bind4.c | 9 ++++--- src/libstddjb/socket_bind4r.c | 6 ++--- src/libstddjb/socket_bind6.c | 11 +++++---- src/libstddjb/socket_bind6r.c | 6 ++--- src/libstddjb/socket_conn4.c | 11 +++++---- src/libstddjb/socket_conn4_u32.c | 4 +-- src/libstddjb/socket_conn6.c | 13 +++++----- src/libstddjb/socket_connected.c | 2 +- src/libstddjb/socket_deadlineconnstamp4.c | 4 +-- src/libstddjb/socket_deadlineconnstamp46.c | 4 +-- src/libstddjb/socket_deadlineconnstamp4_u32.c | 4 +-- src/libstddjb/socket_deadlineconnstamp6.c | 4 +-- src/libstddjb/socket_internal.c | 2 +- src/libstddjb/socket_ioloop.c | 7 +++--- src/libstddjb/socket_ioloop_send4.c | 4 ++- src/libstddjb/socket_ioloop_send6.c | 4 ++- src/libstddjb/socket_local4.c | 8 +++--- src/libstddjb/socket_local46.c | 13 +++++----- src/libstddjb/socket_local6.c | 10 ++++---- src/libstddjb/socket_recv4.c | 9 ++++--- src/libstddjb/socket_recv6.c | 11 +++++---- src/libstddjb/socket_remote4.c | 8 +++--- src/libstddjb/socket_remote46.c | 13 +++++----- src/libstddjb/socket_remote6.c | 10 ++++---- src/libstddjb/socket_send4.c | 11 +++++---- src/libstddjb/socket_send6.c | 13 +++++----- src/libstddjb/socket_tcp6.c | 2 +- src/libstddjb/socket_timeoutconn.c | 4 +-- src/libstddjb/socket_tryr.c | 2 +- src/libstddjb/socket_udp6.c | 2 +- src/libstddjb/socket_waitconn.c | 2 +- src/libstddjb/socketpair_internal.c | 2 +- src/libstddjb/str_chr.c | 1 - src/libstddjb/str_rchr.c | 5 ++-- src/libstddjb/str_start.c | 13 +++------- src/libstddjb/str_strn.c | 5 ++-- src/libstddjb/stralloc_catb.c | 1 - src/libstddjb/stralloc_catv.c | 1 - src/libstddjb/stralloc_copyb.c | 1 - src/libstddjb/stralloc_insertb.c | 2 +- src/libstddjb/stralloc_ready_tuned.c | 4 +-- src/libstddjb/stralloc_reverse.c | 4 +-- src/libstddjb/stralloc_reverse_blocks.c | 5 ++-- src/libstddjb/strerr_sys.c | 4 +-- src/libstddjb/string_format.c | 1 - src/libstddjb/string_quote.c | 2 +- src/libstddjb/string_quote_nodelim.c | 2 +- src/libstddjb/string_quote_nodelim_mustquote.c | 3 +-- src/libstddjb/string_unquote.c | 1 - src/libstddjb/strn_fmt.c | 4 +-- src/libstddjb/sysclock_from_localtm.c | 5 ++-- src/libstddjb/sysclock_from_ltm64.c | 4 +-- src/libstddjb/sysclock_from_tai.c | 5 ++-- src/libstddjb/sysclock_from_utc.c | 4 +-- src/libstddjb/tai_from_localtm.c | 3 +-- src/libstddjb/tai_from_ltm64.c | 2 +- src/libstddjb/tai_from_sysclock.c | 5 ++-- src/libstddjb/tai_from_utc.c | 2 +- src/libstddjb/tai_now.c | 2 +- src/libstddjb/tai_u64.c | 4 +-- src/libstddjb/tain_addsec.c | 4 +-- src/libstddjb/tain_fmt.c | 3 ++- src/libstddjb/tain_from_ntp.c | 4 +-- src/libstddjb/tain_scan.c | 5 ++-- src/libstddjb/tain_to_millisecs.c | 4 +-- src/libstddjb/time_from_tai.c | 7 +++--- src/libstddjb/time_from_tai_relative.c | 4 +-- src/libstddjb/time_sysclock_from_tai.c | 6 ++--- src/libstddjb/timestamp_fmt.c | 3 ++- src/libstddjb/timestamp_scan.c | 5 ++-- src/libstddjb/ucharn_findlen.c | 2 +- src/libstddjb/ucharn_fmt.c | 2 +- src/libstddjb/ucharn_fmt_little.c | 2 +- src/libstddjb/ucharn_scan.c | 2 +- src/libstddjb/ucharn_scan_little.c | 2 +- src/libstddjb/ucspi_get.c | 10 ++++---- src/libstddjb/unsanitize_read.c | 2 +- src/libstddjb/utc_from_localtm.c | 3 +-- src/libstddjb/utc_from_ltm64.c | 3 +-- src/libstddjb/utc_from_sysclock.c | 4 +-- src/libstddjb/vbaprintf.c | 7 +++--- src/libstddjb/vbprintf.c | 7 +++--- src/libstddjb/wait_nointr.c | 1 - src/libstddjb/wait_pid_nohang.c | 6 ++--- src/libstddjb/wait_pids_nohang.c | 6 ++--- src/libstddjb/wait_reap.c | 2 +- src/libstddjb/waitn.c | 6 ++--- src/libstddjb/waitn_reap.c | 6 ++--- src/libstddjb/waitpid_nointr.c | 6 ++--- 256 files changed, 595 insertions(+), 699 deletions(-) delete mode 100644 src/libstddjb/iobufferk_nosys.c delete mode 100644 src/libstddjb/ipc_eid.c delete mode 100644 src/libstddjb/realpath.c delete mode 100644 src/libstddjb/realpath_tmp.c delete mode 100644 src/libstddjb/seek_cur.c delete mode 100644 src/libstddjb/seek_set.c (limited to 'src/libstddjb') diff --git a/src/libstddjb/allreadv.c b/src/libstddjb/allreadv.c index 13514cc..da300fd 100644 --- a/src/libstddjb/allreadv.c +++ b/src/libstddjb/allreadv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/allreadwritev.c b/src/libstddjb/allreadwritev.c index 5ba3837..689bbf6 100644 --- a/src/libstddjb/allreadwritev.c +++ b/src/libstddjb/allreadwritev.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/allwritev.c b/src/libstddjb/allwritev.c index dc343a4..35b5d65 100644 --- a/src/libstddjb/allwritev.c +++ b/src/libstddjb/allwritev.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/bitarray_firstclear_skip.c b/src/libstddjb/bitarray_firstclear_skip.c index ef49ee0..0fa2944 100644 --- a/src/libstddjb/bitarray_firstclear_skip.c +++ b/src/libstddjb/bitarray_firstclear_skip.c @@ -3,10 +3,10 @@ #include #include -size_t bitarray_firstclear_skip (register unsigned char const *s, size_t max, size_t skip) +size_t bitarray_firstclear_skip (unsigned char const *s, size_t max, size_t skip) { - register size_t i = bitarray_div8(skip) ; - register size_t j = i << 3 > max ? max : i << 3 ; + size_t i = bitarray_div8(skip) ; + size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1] != 0xffU) { while ((skip < j) && bitarray_peek(s, skip)) skip++ ; diff --git a/src/libstddjb/bitarray_firstset_skip.c b/src/libstddjb/bitarray_firstset_skip.c index 3689375..0b11c3e 100644 --- a/src/libstddjb/bitarray_firstset_skip.c +++ b/src/libstddjb/bitarray_firstset_skip.c @@ -3,10 +3,10 @@ #include #include -size_t bitarray_firstset_skip (register unsigned char const *s, size_t max, size_t skip) +size_t bitarray_firstset_skip (unsigned char const *s, size_t max, size_t skip) { - register size_t i = bitarray_div8(skip) ; - register size_t j = i << 3 > max ? max : i << 3 ; + size_t i = bitarray_div8(skip) ; + size_t j = i << 3 > max ? max : i << 3 ; if (i && s[i-1]) { while ((skip < j) && !bitarray_peek(s, skip)) skip++ ; diff --git a/src/libstddjb/buffer_fill.c b/src/libstddjb/buffer_fill.c index b3a1bf2..cbdef3e 100644 --- a/src/libstddjb/buffer_fill.c +++ b/src/libstddjb/buffer_fill.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_flush.c b/src/libstddjb/buffer_flush.c index 3249a11..c40c31e 100644 --- a/src/libstddjb/buffer_flush.c +++ b/src/libstddjb/buffer_flush.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_flush1read.c b/src/libstddjb/buffer_flush1read.c index 0384602..49c919f 100644 --- a/src/libstddjb/buffer_flush1read.c +++ b/src/libstddjb/buffer_flush1read.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_getv.c b/src/libstddjb/buffer_getv.c index 358de01..280a3b4 100644 --- a/src/libstddjb/buffer_getv.c +++ b/src/libstddjb/buffer_getv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_getvall.c b/src/libstddjb/buffer_getvall.c index ba2dfae..3a90871 100644 --- a/src/libstddjb/buffer_getvall.c +++ b/src/libstddjb/buffer_getvall.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_getvallnf.c b/src/libstddjb/buffer_getvallnf.c index e0e2e5d..e0a2d0a 100644 --- a/src/libstddjb/buffer_getvallnf.c +++ b/src/libstddjb/buffer_getvallnf.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_putv.c b/src/libstddjb/buffer_putv.c index bd902ae..f8fac59 100644 --- a/src/libstddjb/buffer_putv.c +++ b/src/libstddjb/buffer_putv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/buffer_putvall.c b/src/libstddjb/buffer_putvall.c index b04ac36..5635aed 100644 --- a/src/libstddjb/buffer_putvall.c +++ b/src/libstddjb/buffer_putvall.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_putvallnf.c b/src/libstddjb/buffer_putvallnf.c index 6f87d13..3898a36 100644 --- a/src/libstddjb/buffer_putvallnf.c +++ b/src/libstddjb/buffer_putvallnf.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/buffer_putvflush.c b/src/libstddjb/buffer_putvflush.c index 4bbb329..86c5b5c 100644 --- a/src/libstddjb/buffer_putvflush.c +++ b/src/libstddjb/buffer_putvflush.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/case_lowerb.c b/src/libstddjb/case_lowerb.c index 1285b52..d2099fc 100644 --- a/src/libstddjb/case_lowerb.c +++ b/src/libstddjb/case_lowerb.c @@ -3,7 +3,7 @@ #include #include -void case_lowerb (register char *s, size_t len) +void case_lowerb (char *s, size_t len) { unsigned char const d = 'a' - 'A' ; while (len--) diff --git a/src/libstddjb/case_lowers.c b/src/libstddjb/case_lowers.c index 5999786..349eade 100644 --- a/src/libstddjb/case_lowers.c +++ b/src/libstddjb/case_lowers.c @@ -2,9 +2,9 @@ #include -void case_lowers (register char *s) +void case_lowers (char *s) { - register unsigned char const d = 'a' - 'A' ; + unsigned char const d = 'a' - 'A' ; while (*s) { if (('A' <= *s) && (*s <= 'Z')) *s += d ; diff --git a/src/libstddjb/case_startb.c b/src/libstddjb/case_startb.c index d69f461..42e12f2 100644 --- a/src/libstddjb/case_startb.c +++ b/src/libstddjb/case_startb.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include #include +#include #include -int case_startb (register char const *s, size_t slen, register char const *t) +int case_startb (char const *s, size_t slen, char const *t) { size_t tlen = strlen(t) ; - return slen < tlen ? 0 : !case_diffb(s, tlen, t) ; + return slen < tlen ? 0 : !strncasecmp(s, t, tlen) ; } diff --git a/src/libstddjb/case_str.c b/src/libstddjb/case_str.c index a6cd9b4..9c79019 100644 --- a/src/libstddjb/case_str.c +++ b/src/libstddjb/case_str.c @@ -16,8 +16,8 @@ size_t case_str (char const *haystack, char const *needle) #else -#include #include +#include #include size_t case_str (char const *haystack, char const *needle) @@ -26,7 +26,7 @@ size_t case_str (char const *haystack, char const *needle) char const *p = haystack ; if (!nlen) return 0 ; for (; *p ; p++) - if (!case_diffb(p, nlen, needle)) return p - haystack ; + if (!strncasecmp(p, needle, nlen)) return p - haystack ; return strlen(haystack) ; } diff --git a/src/libstddjb/case_upperb.c b/src/libstddjb/case_upperb.c index 78ece8f..e3fa47b 100644 --- a/src/libstddjb/case_upperb.c +++ b/src/libstddjb/case_upperb.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include void case_upperb (char *s, size_t len) diff --git a/src/libstddjb/case_uppers.c b/src/libstddjb/case_uppers.c index cf2875a..da0837c 100644 --- a/src/libstddjb/case_uppers.c +++ b/src/libstddjb/case_uppers.c @@ -2,9 +2,9 @@ #include -void case_uppers (register char *s) +void case_uppers (char *s) { - register unsigned char const d = 'a' - 'A' ; + unsigned char const d = 'a' - 'A' ; while (*s) { if (('a' <= *s) && (*s <= 'z')) *s -= d ; diff --git a/src/libstddjb/cbuffer_get.c b/src/libstddjb/cbuffer_get.c index c490c26..315751a 100644 --- a/src/libstddjb/cbuffer_get.c +++ b/src/libstddjb/cbuffer_get.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/cbuffer_getv.c b/src/libstddjb/cbuffer_getv.c index f27d054..afdf8f9 100644 --- a/src/libstddjb/cbuffer_getv.c +++ b/src/libstddjb/cbuffer_getv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/cbuffer_put.c b/src/libstddjb/cbuffer_put.c index 2a5fcf8..428a430 100644 --- a/src/libstddjb/cbuffer_put.c +++ b/src/libstddjb/cbuffer_put.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/cbuffer_putv.c b/src/libstddjb/cbuffer_putv.c index 2fcdee6..62af494 100644 --- a/src/libstddjb/cbuffer_putv.c +++ b/src/libstddjb/cbuffer_putv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/cbuffer_wpeek.c b/src/libstddjb/cbuffer_wpeek.c index a1e502e..8b6b586 100644 --- a/src/libstddjb/cbuffer_wpeek.c +++ b/src/libstddjb/cbuffer_wpeek.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/cdb_findnext.c b/src/libstddjb/cdb_findnext.c index 2559bc2..536013b 100644 --- a/src/libstddjb/cdb_findnext.c +++ b/src/libstddjb/cdb_findnext.c @@ -1,18 +1,19 @@ /* ISC license. */ -#include +#include +#include #include #include -static int match (struct cdb *c, char const *key, unsigned int len, uint32 pos) +static int match (struct cdb *c, char const *key, unsigned int len, uint32_t pos) { char buf[1024] ; while (len > 0) { - register unsigned int n = 1024 ; + unsigned int n = 1024 ; if (n > len) n = len ; if (cdb_read(c, buf, n, pos) < 0) return -1 ; - if (byte_diff(buf, n, key)) return 0 ; + if (memcmp(buf, key, n)) return 0 ; pos += n ; key += n ; len -= n ; } return 1 ; @@ -21,8 +22,8 @@ static int match (struct cdb *c, char const *key, unsigned int len, uint32 pos) int cdb_findnext (struct cdb *c, char const *key, unsigned int len) { char buf[8] ; - uint32 pos ; - uint32 u ; + uint32_t pos ; + uint32_t u ; if (!c->loop) { diff --git a/src/libstddjb/cdb_hash.c b/src/libstddjb/cdb_hash.c index 9eedf54..85a11c1 100644 --- a/src/libstddjb/cdb_hash.c +++ b/src/libstddjb/cdb_hash.c @@ -1,17 +1,17 @@ /* ISC license. */ -#include +#include #include -uint32 cdb_hashadd (uint32 h, unsigned char c) +uint32_t cdb_hashadd (uint32_t h, unsigned char c) { h += (h << 5) ; return h ^ c ; } -uint32 cdb_hash (char const *buf, unsigned int len) +uint32_t cdb_hash (char const *buf, unsigned int len) { - uint32 h = CDB_HASHSTART ; + uint32_t h = CDB_HASHSTART ; while (len--) h = cdb_hashadd(h, *buf++) ; return h ; } diff --git a/src/libstddjb/cdb_init_map.c b/src/libstddjb/cdb_init_map.c index bf8eb9d..de9aad0 100644 --- a/src/libstddjb/cdb_init_map.c +++ b/src/libstddjb/cdb_init_map.c @@ -1,8 +1,14 @@ /* ISC license. */ +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif + #include #include #include +#include +#include #include int cdb_init_map (struct cdb *c, int fd, int domap) @@ -12,6 +18,7 @@ int cdb_init_map (struct cdb *c, int fd, int domap) struct stat st ; char *map ; if (fstat(fd, &st) < 0) return 0 ; + if (st.st_size > UINT32_MAX) return (errno = EOVERFLOW, 0) ; map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (map == MAP_FAILED) return 0 ; c->fd = -fd-2 ; diff --git a/src/libstddjb/cdb_make.c b/src/libstddjb/cdb_make.c index c7e79d3..ce5e81e 100644 --- a/src/libstddjb/cdb_make.c +++ b/src/libstddjb/cdb_make.c @@ -1,6 +1,7 @@ /* ISC license. */ #include +#include #include #include #include @@ -16,28 +17,29 @@ int cdb_make_start (struct cdb_make *c, int fd) c->hplist = genalloc_zero ; c->pos = 2048 ; buffer_init(&c->b, &fd_writev, fd, c->buf, BUFFER_OUTSIZE) ; - return (int)lseek(fd, c->pos, SEEK_SET) ; + if (lseek(fd, c->pos, SEEK_SET) < 0) return -1 ; + return 0 ; } static int posplus (struct cdb_make *c, uint32 len) { - register uint32 newpos = c->pos + len ; + uint32_t newpos = c->pos + len ; if (newpos < len) return (errno = ENOMEM, 0) ; c->pos = newpos ; return 1 ; } -static inline int cdb_make_addend (struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32 h) +static inline int cdb_make_addend (struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32_t h) { diuint32 blah = { .left = h, .right = c->pos } ; return genalloc_append(diuint32, &c->hplist, &blah) && posplus(c, 8) && posplus(c, keylen) && posplus(c, datalen) ; } -static inline int cdb_make_addbegin (struct cdb_make *c, unsigned int keylen, unsigned int datalen) +static inline ssize_t cdb_make_addbegin (struct cdb_make *c, unsigned int keylen, unsigned int datalen) { char buf[8] ; - uint32_pack(buf, (uint32)keylen) ; - uint32_pack(buf + 4, (uint32)datalen) ; + uint32_pack(buf, (uint32_t)keylen) ; + uint32_pack(buf + 4, (uint32_t)datalen) ; return buffer_put(&c->b, buf, 8) ; } @@ -56,19 +58,19 @@ int cdb_make_add (struct cdb_make *c, char const *key, unsigned int keylen, char int cdb_make_finish (struct cdb_make *c) { - uint32 count[256] ; - uint32 start[256] ; + uint32_t count[256] ; + uint32_t start[256] ; char final[2048] ; unsigned int size = 1 ; unsigned int n = genalloc_len(diuint32, &c->hplist) ; - register unsigned int i = 0 ; - register diuint32 *hp = genalloc_s(diuint32, &c->hplist) ; + unsigned int i = 0 ; + diuint32 *hp = genalloc_s(diuint32, &c->hplist) ; for (; i < 256 ; i++) count[i] = 0 ; for (i = 0 ; i < n ; i++) ++count[hp[i].left & 255] ; { - register uint32 u = 0 ; + uint32_t u = 0 ; for (i = 0 ; i < 256 ; i++) start[i] = u += count[i] ; /* bounded by n */ for (i = 0 ; i < 256 ; i++) { @@ -89,10 +91,10 @@ int cdb_make_finish (struct cdb_make *c) for (i = 0 ; i < 256 ; ++i) { char buf[8] ; - register uint32 k = count[i] ; - register uint32 len = k << 1 ; /* no overflow possible */ - register diuint32 *p = split + start[i] ; - register unsigned int j = 0 ; + uint32_t k = count[i] ; + uint32_t len = k << 1 ; /* no overflow possible */ + diuint32 *p = split + start[i] ; + unsigned int j = 0 ; uint32_pack(final + (i << 3), c->pos) ; uint32_pack(final + (i << 3) + 4, len) ; @@ -100,7 +102,7 @@ int cdb_make_finish (struct cdb_make *c) for (; j < len ; j++) hp[j].left = hp[j].right = 0 ; for (j = 0 ; j < k ; j++) { - register uint32 where = (p->left >> 8) % len ; + uint32_t where = (p->left >> 8) % len ; while (hp[where].right) if (++where == len) where = 0 ; hp[where] = *p++ ; } diff --git a/src/libstddjb/cdb_mapfile.c b/src/libstddjb/cdb_mapfile.c index f26ad3c..1ffae19 100644 --- a/src/libstddjb/cdb_mapfile.c +++ b/src/libstddjb/cdb_mapfile.c @@ -10,7 +10,7 @@ int cdb_mapfile (struct cdb *c, char const *file) if (fd < 0) return 0 ; if (!cdb_init_map(c, fd, 1)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return 0 ; diff --git a/src/libstddjb/cdb_nextkey.c b/src/libstddjb/cdb_nextkey.c index 28925fe..51e927f 100644 --- a/src/libstddjb/cdb_nextkey.c +++ b/src/libstddjb/cdb_nextkey.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include #include #include -int cdb_nextkey (struct cdb *c, uint32 *kpos) +int cdb_nextkey (struct cdb *c, uint32_t *kpos) { char buf[8] ; - uint32 eod, klen ; + uint32_t eod, klen ; if (cdb_read(c, buf, 4, 0) < 0) return -1 ; uint32_unpack(buf, &eod) ; if (eod < 8 || eod - 8 < *kpos) return 0 ; diff --git a/src/libstddjb/cdb_read.c b/src/libstddjb/cdb_read.c index 76fbd63..e857511 100644 --- a/src/libstddjb/cdb_read.c +++ b/src/libstddjb/cdb_read.c @@ -1,23 +1,24 @@ /* ISC license. */ +#include +#include +#include #include #include -#include #include #include -#include #include -int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32 pos) +int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32_t pos) { if (c->map) { if ((pos > c->size) || (c->size - pos < len)) return (errno = EPROTO, -1) ; - byte_copy(buf, len, c->map + pos) ; + memcpy(buf, c->map + pos, len) ; } else { - if (seek_set(c->fd, pos) < 0) return -1 ; + if (lseek(c->fd, pos, SEEK_SET) < 0) return -1 ; if (allread(c->fd, buf, len) < len) return -1 ; } return 0 ; diff --git a/src/libstddjb/cdb_successor.c b/src/libstddjb/cdb_successor.c index 5660692..0d7e17f 100644 --- a/src/libstddjb/cdb_successor.c +++ b/src/libstddjb/cdb_successor.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include #include #include int cdb_successor (struct cdb *c, char const *key, unsigned int klen) { - uint32 kpos ; + uint32_t kpos ; if (key) { - register int r = cdb_find(c, key, klen) ; + int r = cdb_find(c, key, klen) ; if (r < 1) return r ; kpos = c->dpos + c->dlen ; } diff --git a/src/libstddjb/dir_close.c b/src/libstddjb/dir_close.c index 0af6f0e..1b7b16a 100644 --- a/src/libstddjb/dir_close.c +++ b/src/libstddjb/dir_close.c @@ -5,7 +5,7 @@ int dir_close (DIR *dir) { - register unsigned int done = 0 ; + unsigned int done = 0 ; doit: done++ ; if (!closedir(dir)) return 0 ; diff --git a/src/libstddjb/djbtime-internal.h b/src/libstddjb/djbtime-internal.h index eb4e676..a80b540 100644 --- a/src/libstddjb/djbtime-internal.h +++ b/src/libstddjb/djbtime-internal.h @@ -6,10 +6,10 @@ #include extern unsigned int const leapsecs_table_len ; -extern uint64 const *const leapsecs_table ; +extern uint64_t const *const leapsecs_table ; -extern void leapsecs_add (uint64 *, int) ; -extern int leapsecs_sub (uint64 *) ; +extern void leapsecs_add (uint64_t *, int) ; +extern int leapsecs_sub (uint64_t *) ; extern int skalibs_tzisright (void) ; #endif diff --git a/src/libstddjb/env_addmodif.c b/src/libstddjb/env_addmodif.c index 4c34479..ddd1be3 100644 --- a/src/libstddjb/env_addmodif.c +++ b/src/libstddjb/env_addmodif.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include #include #include int env_addmodif (stralloc *sa, char const *s, char const *t) { - unsigned int oldlen = sa->len ; + size_t oldlen = sa->len ; if (!s) return 1 ; if (!stralloc_cats(sa, s)) return 0 ; if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t))) diff --git a/src/libstddjb/env_get2.c b/src/libstddjb/env_get2.c index 612cf6a..5909ea6 100644 --- a/src/libstddjb/env_get2.c +++ b/src/libstddjb/env_get2.c @@ -1,15 +1,14 @@ /* ISC license. */ +#include #include #include char const *env_get2 (char const *const *envp, char const *s) { - unsigned int i ; - unsigned int len ; - + size_t len, i ; if (!s) return 0 ; - len = str_len(s) ; + len = strlen(s) ; for (i = 0 ; envp[i] ; ++i) if (str_start(envp[i], s) && (envp[i][len] == '=')) diff --git a/src/libstddjb/env_len.c b/src/libstddjb/env_len.c index 7e0bea8..f551ce1 100644 --- a/src/libstddjb/env_len.c +++ b/src/libstddjb/env_len.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include #include -unsigned int env_len (register char const *const *e) +size_t env_len (char const *const *e) { - register unsigned int i = 0 ; + size_t i = 0 ; while (*e++) i++ ; return i ; } diff --git a/src/libstddjb/env_make.c b/src/libstddjb/env_make.c index dd5139f..60148f8 100644 --- a/src/libstddjb/env_make.c +++ b/src/libstddjb/env_make.c @@ -1,14 +1,14 @@ /* ISC license. */ +#include #include -#include #include -int env_make (char const **v, unsigned int argc, char const *s, unsigned int len) +int env_make (char const **v, size_t argc, char const *s, size_t len) { while (argc--) { - register unsigned int n = str_len(s) + 1 ; + size_t n = strlen(s) + 1 ; if (n > len) return (errno = EINVAL, 0) ; *v++ = s ; s += n ; len -= n ; } diff --git a/src/libstddjb/env_merge.c b/src/libstddjb/env_merge.c index 2a0e5bd..f7ba335 100644 --- a/src/libstddjb/env_merge.c +++ b/src/libstddjb/env_merge.c @@ -1,22 +1,23 @@ /* ISC license. */ +#include #include #include #include -unsigned int env_merge (char const **v, unsigned int vmax, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) +size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { - unsigned int n = byte_count(modifs, modiflen, '\0') ; - unsigned int vlen = envlen ; - register unsigned int i = 0 ; + size_t n = byte_count(modifs, modiflen, '\0') ; + size_t vlen = envlen ; + size_t i = 0 ; if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ; for (; i < envlen ; i++) v[i] = envp[i] ; - for (i = 0 ; i < modiflen ; i += str_len(modifs + i) + 1) + for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1) { - unsigned int split = str_chr(modifs + i, '=') ; - register unsigned int j = 0 ; + size_t split = str_chr(modifs + i, '=') ; + size_t j = 0 ; for (; j < vlen ; j++) - if (!byte_diff(modifs + i, split, v[j]) && (v[j][split] == '=')) break ; + if (!memcmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ; if (j < vlen) v[j] = v[--vlen] ; if (modifs[i + split]) v[vlen++] = modifs + i ; } diff --git a/src/libstddjb/env_string.c b/src/libstddjb/env_string.c index 7f97859..d76e783 100644 --- a/src/libstddjb/env_string.c +++ b/src/libstddjb/env_string.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include #include #include -int env_string (stralloc *sa, char const *const *envp, unsigned int envlen) +int env_string (stralloc *sa, char const *const *envp, size_t envlen) { - unsigned int salen = sa->len ; - register unsigned int i = 0 ; + size_t salen = sa->len ; + size_t i = 0 ; for (; i < envlen ; i++) { if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa)) diff --git a/src/libstddjb/envalloc_make.c b/src/libstddjb/envalloc_make.c index 1cc44b9..2c2e553 100644 --- a/src/libstddjb/envalloc_make.c +++ b/src/libstddjb/envalloc_make.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include #include #include #include -int envalloc_make (genalloc *v, unsigned int argc, char const *s, unsigned int len) +int envalloc_make (genalloc *v, size_t argc, char const *s, size_t len) { int wasnull = !v->s ; if (!genalloc_readyplus(char const *, v, argc+1)) return 0 ; diff --git a/src/libstddjb/envalloc_merge.c b/src/libstddjb/envalloc_merge.c index 9134b84..84179f0 100644 --- a/src/libstddjb/envalloc_merge.c +++ b/src/libstddjb/envalloc_merge.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include #include #include #include #include -int envalloc_merge (genalloc *v, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) +int envalloc_merge (genalloc *v, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen) { - unsigned int n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; + size_t n = envlen + 1 + byte_count(modifs, modiflen, '\0') ; if (!genalloc_readyplus(char const *, v, n)) return 0 ; n = env_merge(genalloc_s(char const *, v) + genalloc_len(char const *, v), n, envp, envlen, modifs, modiflen) ; genalloc_setlen(char const *, v, genalloc_len(char const *, v) + n) ; diff --git a/src/libstddjb/envalloc_uniq.c b/src/libstddjb/envalloc_uniq.c index 181128a..cf60b44 100644 --- a/src/libstddjb/envalloc_uniq.c +++ b/src/libstddjb/envalloc_uniq.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,24 +9,24 @@ int envalloc_uniq (genalloc *v, char delim) { unsigned int m = 0 ; - register unsigned int i = 0 ; + size_t i = 0 ; for (; i < genalloc_len(char const *, v) ; i++) { - register unsigned int j = i+1 ; + size_t j = i+1 ; char const *s = genalloc_s(char const *, v)[i] ; - unsigned int n = str_chr(s, delim) ; + size_t n = str_chr(s, delim) ; if (delim && !s[n]) return (errno = EINVAL, -1) ; for (; j < genalloc_len(char const *, v) ; j++) { - register char const **p = genalloc_s(char const *, v) ; - if (!str_diffn(s, p[j], n)) + char const **p = genalloc_s(char const *, v) ; + if (!strncmp(s, p[j], n)) { - register unsigned int len = genalloc_len(char const *, v) - 1 ; + size_t len = genalloc_len(char const *, v) - 1 ; genalloc_setlen(char const *, v, len) ; p[j] = p[len] ; m++ ; } } } - return (int)m ; + return m ; } diff --git a/src/libstddjb/error_temp.c b/src/libstddjb/error_temp.c index 48a54f5..ce7576a 100644 --- a/src/libstddjb/error_temp.c +++ b/src/libstddjb/error_temp.c @@ -3,7 +3,7 @@ #include #include -int error_temp (register int e) +int error_temp (int e) { if (error_isagain(e)) return 1 ; switch (e) diff --git a/src/libstddjb/fd_cat.c b/src/libstddjb/fd_cat.c index 1853427..fdaf093 100644 --- a/src/libstddjb/fd_cat.c +++ b/src/libstddjb/fd_cat.c @@ -11,7 +11,7 @@ int fd_cat (int from, int to) if (!iobuffer_init(&b, from, to)) return -1 ; for (;;) { - register ssize_t r = iobuffer_fill(&b) ; + ssize_t r = iobuffer_fill(&b) ; if (r < 0) goto err ; else if (!r) break ; if (!iobuffer_flush(&b)) goto err ; diff --git a/src/libstddjb/fd_catn.c b/src/libstddjb/fd_catn.c index b757853..c2ddd7a 100644 --- a/src/libstddjb/fd_catn.c +++ b/src/libstddjb/fd_catn.c @@ -15,7 +15,7 @@ size_t fd_catn (int from, int to, size_t n) if (!iobuffer_init(&b, from, to)) return 0 ; while (n >= IOBUFFER_SIZE) { - register ssize_t r = iobuffer_fill(&b) ; + ssize_t r = iobuffer_fill(&b) ; if (r <= 0) { iobuffer_finish(&b) ; diff --git a/src/libstddjb/fd_chdir.c b/src/libstddjb/fd_chdir.c index e09656e..f506ccc 100644 --- a/src/libstddjb/fd_chdir.c +++ b/src/libstddjb/fd_chdir.c @@ -6,7 +6,7 @@ int fd_chdir (int d) { - register int r ; + int r ; do r = fchdir(d) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/fd_chmod.c b/src/libstddjb/fd_chmod.c index a70c537..109826e 100644 --- a/src/libstddjb/fd_chmod.c +++ b/src/libstddjb/fd_chmod.c @@ -9,7 +9,7 @@ int fd_chmod (int fd, unsigned int mode) { - register int r ; + int r ; do r = fchmod(fd, (mode_t)mode) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/fd_chown.c b/src/libstddjb/fd_chown.c index f4915ae..8b0028f 100644 --- a/src/libstddjb/fd_chown.c +++ b/src/libstddjb/fd_chown.c @@ -7,7 +7,7 @@ int fd_chown (int fd, uid_t uid, gid_t gid) { - register int r ; + int r ; do r = fchown(fd, uid, gid) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/fd_copy.c b/src/libstddjb/fd_copy.c index b051eaf..80b887e 100644 --- a/src/libstddjb/fd_copy.c +++ b/src/libstddjb/fd_copy.c @@ -6,7 +6,7 @@ int fd_copy (int to, int from) { - register int r ; + int r ; if (to == from) return (errno = EINVAL, -1) ; do r = dup2(from, to) ; diff --git a/src/libstddjb/fd_ensure_open.c b/src/libstddjb/fd_ensure_open.c index b399af2..40548c1 100644 --- a/src/libstddjb/fd_ensure_open.c +++ b/src/libstddjb/fd_ensure_open.c @@ -15,7 +15,7 @@ int fd_ensure_open (int fd, int w) if (newfd < 0) return 0 ; if (fd_move(fd, newfd) < 0) { - register int e = errno ; + int e = errno ; fd_close(newfd) ; errno = e ; return 0 ; diff --git a/src/libstddjb/fd_move.c b/src/libstddjb/fd_move.c index d79f8ac..d84db80 100644 --- a/src/libstddjb/fd_move.c +++ b/src/libstddjb/fd_move.c @@ -6,7 +6,7 @@ int fd_move (int to, int from) { - register int r ; + int r ; if (to == from) return 0 ; do r = dup2(from, to) ; diff --git a/src/libstddjb/fd_move2.c b/src/libstddjb/fd_move2.c index 7894e2f..e28c2cc 100644 --- a/src/libstddjb/fd_move2.c +++ b/src/libstddjb/fd_move2.c @@ -6,7 +6,7 @@ int fd_move2 (int to1, int from1, int to2, int from2) { - register int tmp = from2 ; + int tmp = from2 ; if (to1 == from1) return fd_move(to2, from2) ; if (to2 == from2) return fd_move(to1, from1) ; if (from1 == from2) return (to1 == to2) ? fd_move(to1, from1) : (errno = EINVAL, -1) ; @@ -18,14 +18,14 @@ int fd_move2 (int to1, int from1, int to2, int from2) } if (fd_copy(to1, from1) == -1) { - register int e = errno ; + int e = errno ; if (from2 != tmp) fd_close(tmp) ; errno = e ; return -1 ; } if (fd_copy(to2, tmp) == -1) { - register int e = errno ; + int e = errno ; fd_close(to1) ; if (from2 != tmp) fd_move(from2, tmp) ; errno = e ; diff --git a/src/libstddjb/fd_readv.c b/src/libstddjb/fd_readv.c index 11dda66..0d384a4 100644 --- a/src/libstddjb/fd_readv.c +++ b/src/libstddjb/fd_readv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/fd_recv.c b/src/libstddjb/fd_recv.c index 4eb8659..781daa5 100644 --- a/src/libstddjb/fd_recv.c +++ b/src/libstddjb/fd_recv.c @@ -7,8 +7,8 @@ ssize_t fd_recv (int fd, char *buf, size_t len, unsigned int flags) { - register ssize_t r ; - do r = recv(fd, buf, len, (int)flags) ; + ssize_t r ; + do r = recv(fd, buf, len, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/fd_send.c b/src/libstddjb/fd_send.c index 1d37bd5..b7ed939 100644 --- a/src/libstddjb/fd_send.c +++ b/src/libstddjb/fd_send.c @@ -7,8 +7,8 @@ ssize_t fd_send (int fd, char const *buf, size_t len, unsigned int flags) { - register ssize_t r ; - do r = send(fd, buf, len, (int)flags) ; + ssize_t r ; + do r = send(fd, buf, len, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/fd_sync.c b/src/libstddjb/fd_sync.c index db54136..e978151 100644 --- a/src/libstddjb/fd_sync.c +++ b/src/libstddjb/fd_sync.c @@ -6,7 +6,7 @@ int fd_sync (int fd) { - register int r ; + int r ; do r = fsync(fd) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/fd_writev.c b/src/libstddjb/fd_writev.c index c54a20e..61f7132 100644 --- a/src/libstddjb/fd_writev.c +++ b/src/libstddjb/fd_writev.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include #include #include #include ssize_t fd_writev (int fd, struct iovec const *v, unsigned int vlen) { - register ssize_t r ; + ssize_t r ; do r = writev(fd, v, vlen) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/fmtscan-internal.h b/src/libstddjb/fmtscan-internal.h index 3c9f214..24e5774 100644 --- a/src/libstddjb/fmtscan-internal.h +++ b/src/libstddjb/fmtscan-internal.h @@ -5,9 +5,9 @@ #include #include +#include #include #include -#include #include #define SCANB(bits) \ @@ -18,7 +18,7 @@ size_t uint##bits##_scan_base (char const *s, uint##bits##_t *u, unsigned int ba size_t pos = 0 ; \ for (;; pos++) \ { \ - register unsigned char c = fmtscan_num(s[pos], base) ; \ + unsigned char c = fmtscan_num(s[pos], base) ; \ if ((c >= base) || (result > ((max - c) / base))) break ; \ result = result * base + c ; \ } \ @@ -29,7 +29,7 @@ size_t uint##bits##_scan_base (char const *s, uint##bits##_t *u, unsigned int ba #define SCANB0(bits) \ size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, unsigned int base) \ { \ - register size_t pos = uint##bits##_scan_base(s, u, base) ; \ + size_t pos = uint##bits##_scan_base(s, u, base) ; \ if (!pos) return (errno = EINVAL, 0) ; \ if (!s[pos]) return pos ; \ errno = (fmtscan_num(s[pos], base) < base) ? EDOM : EINVAL ; \ @@ -40,8 +40,8 @@ size_t uint##bits##0_scan_base (char const *s, uint##bits##_t *u, unsigned int b size_t int##bits##_scan (char const *s, int##bits##_t *n) \ { \ uint##bits##_t tmp ; \ - register size_t r = 0 ; \ - register unsigned int sign = 0 ; \ + size_t r = 0 ; \ + unsigned int sign = 0 ; \ if (*s == '-') \ { \ r = 1 + uint##bits##_scan(s+1, &tmp) ; \ @@ -74,7 +74,7 @@ size_t int##bits##_scan (char const *s, int##bits##_t *n) \ #define SCANS0(bits) \ size_t int##bits##0_scan (char const *s, int##bits##_t *u) \ { \ - register size_t pos = int##bits##_scan(s, u) ; \ + size_t pos = int##bits##_scan(s, u) ; \ if (!pos) return (errno = EINVAL, 0) ; \ if (!s[pos]) return pos ; \ errno = (fmtscan_num(s[pos], 10) < 10) ? EDOM : EINVAL ; \ @@ -87,10 +87,10 @@ size_t uint##bits##_scanlist (uint##bits##_t *tab, size_t max, char const *s, si size_t i = 0, len = 0 ; \ for (; s[len] && (i < max) ; i++) \ { \ - register size_t w = uint##bits##_scan(s + len, tab + i) ; \ + size_t w = uint##bits##_scan(s + len, tab + i) ; \ if (!w) break ; \ len += w ; \ - while (byte_chr(",:; \t\r\n", 7, s[len]) < 7) len++ ; \ + while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \ } \ *num = i ; \ return len ; \ @@ -102,10 +102,10 @@ size_t int##bits##_scanlist (int##bits##_t *tab, size_t max, char const *s, size size_t i = 0, len = 0 ; \ for (; s[len] && (i < max) ; i++) \ { \ - register size_t w = int##bits##_scan(s + len, tab + i) ; \ + size_t w = int##bits##_scan(s + len, tab + i) ; \ if (!w) break ; \ len += w ; \ - while (byte_chr(",:; \t\r\n", 7, s[len]) < 7) len++ ; \ + while (memchr(",:; \t\r\n", s[len], 7)) len++ ; \ } \ *num = i ; \ return len ; \ @@ -117,7 +117,7 @@ size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \ size_t i = 0, len = 0 ; \ for (; i < n ; i++) \ { \ - register size_t w = uint##bits##_fmt(s, tab[i]) ; \ + size_t w = uint##bits##_fmt(s, tab[i]) ; \ len += w ; \ if (s) \ { \ @@ -131,9 +131,9 @@ size_t uint##bits##_fmtlist (char *s, uint##bits##_t const *tab, size_t n) \ #define FMTB(bits) \ size_t uint##bits##_fmt_base (char *s, uint##bits##_t x, unsigned int base) \ { \ - register size_t len = 1 ; \ + size_t len = 1 ; \ { \ - register uint##bits##_t q = x ; \ + uint##bits##_t q = x ; \ while (q >= base) { len++ ; q /= base ; } \ } \ if (s) \ @@ -145,9 +145,9 @@ size_t uint##bits##_fmt_base (char *s, uint##bits##_t x, unsigned int base) \ } \ #define FMTB0(bits) \ -size_t uint##bits##0_fmt_base (char *s, uint##bits##_t x, register size_t n, unsigned int base) \ +size_t uint##bits##0_fmt_base (char *s, uint##bits##_t x, size_t n, unsigned int base) \ { \ - register size_t len = uint##bits##_fmt_base(0, x, base) ; \ + size_t len = uint##bits##_fmt_base(0, x, base) ; \ while (n-- > len) *s++ = '0' ; \ return uint##bits##_fmt_base(s, x, base) ; \ } \ @@ -166,7 +166,7 @@ size_t int##bits##_fmtlist (char *s, int##bits##_t const *tab, size_t n) \ size_t i = 0, len = 0 ; \ for (; i < n ; i++) \ { \ - register size_t w = int##bits##_fmt(s, tab[i]) ; \ + size_t w = int##bits##_fmt(s, tab[i]) ; \ len += w ; \ if (s) \ { \ diff --git a/src/libstddjb/fmtscan_num.c b/src/libstddjb/fmtscan_num.c index 094eb2a..d9fea33 100644 --- a/src/libstddjb/fmtscan_num.c +++ b/src/libstddjb/fmtscan_num.c @@ -2,7 +2,7 @@ #include -unsigned char fmtscan_num (register unsigned char c, unsigned char n) +unsigned char fmtscan_num (unsigned char c, unsigned char n) { return ((c < '0') || (n > 36)) ? n : diff --git a/src/libstddjb/genalloc_deepfree.c b/src/libstddjb/genalloc_deepfree.c index 29f1527..1684374 100644 --- a/src/libstddjb/genalloc_deepfree.c +++ b/src/libstddjb/genalloc_deepfree.c @@ -7,7 +7,7 @@ void genalloc_deepfree_size (genalloc *g, freefunc_t_ref f, size_t size) { size_t len = g->len / size ; - register size_t i = 0 ; + size_t i = 0 ; for (; i < len ; i++) (*f)(g->s + i * size) ; stralloc_free(g) ; } diff --git a/src/libstddjb/genwrite_flush_bufalloc.c b/src/libstddjb/genwrite_flush_bufalloc.c index 6383246..44832c7 100644 --- a/src/libstddjb/genwrite_flush_bufalloc.c +++ b/src/libstddjb/genwrite_flush_bufalloc.c @@ -5,6 +5,5 @@ int genwrite_flush_bufalloc (void *target) { - register bufalloc *ba = target ; - return bufalloc_flush(ba) ; + return bufalloc_flush((bufalloc *)target) ; } diff --git a/src/libstddjb/genwrite_flush_buffer.c b/src/libstddjb/genwrite_flush_buffer.c index d30f3e6..092ffb4 100644 --- a/src/libstddjb/genwrite_flush_buffer.c +++ b/src/libstddjb/genwrite_flush_buffer.c @@ -5,6 +5,5 @@ int genwrite_flush_buffer (void *target) { - register buffer *b = target ; - return buffer_flush(b) ; + return buffer_flush((buffer *)target) ; } diff --git a/src/libstddjb/genwrite_put_bufalloc.c b/src/libstddjb/genwrite_put_bufalloc.c index 4b5830d..98a5919 100644 --- a/src/libstddjb/genwrite_put_bufalloc.c +++ b/src/libstddjb/genwrite_put_bufalloc.c @@ -6,6 +6,5 @@ ssize_t genwrite_put_bufalloc (void *target, char const *s, size_t len) { - register bufalloc *ba = target ; - return bufalloc_put(ba, s, len) ? (ssize_t)len : -1 ; + return bufalloc_put((bufalloc *)target, s, len) ? (ssize_t)len : -1 ; } diff --git a/src/libstddjb/genwrite_put_buffer.c b/src/libstddjb/genwrite_put_buffer.c index e5d7843..8a710b9 100644 --- a/src/libstddjb/genwrite_put_buffer.c +++ b/src/libstddjb/genwrite_put_buffer.c @@ -6,6 +6,5 @@ ssize_t genwrite_put_buffer (void *target, char const *s, size_t len) { - register buffer *b = target ; - return buffer_put(b, s, len) ; + return buffer_put((buffer *)target, s, len) ; } diff --git a/src/libstddjb/genwrite_put_stralloc.c b/src/libstddjb/genwrite_put_stralloc.c index 6f1e2b7..14583fb 100644 --- a/src/libstddjb/genwrite_put_stralloc.c +++ b/src/libstddjb/genwrite_put_stralloc.c @@ -6,6 +6,5 @@ ssize_t genwrite_put_stralloc (void *target, char const *s, size_t len) { - register stralloc *sa = target ; - return stralloc_catb(sa, s, len) ? (ssize_t)len : -1 ; + return stralloc_catb((stralloc *)target, s, len) ? (ssize_t)len : -1 ; } diff --git a/src/libstddjb/getlnmax.c b/src/libstddjb/getlnmax.c index 6f6783a..7f7d679 100644 --- a/src/libstddjb/getlnmax.c +++ b/src/libstddjb/getlnmax.c @@ -1,10 +1,9 @@ /* ISC license. */ -#include #include #include -#include #include +#include #include int getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep) diff --git a/src/libstddjb/getlnmaxsep.c b/src/libstddjb/getlnmaxsep.c index 8505417..7b7dc0e 100644 --- a/src/libstddjb/getlnmaxsep.c +++ b/src/libstddjb/getlnmaxsep.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/getpeereid.c b/src/libstddjb/getpeereid.c index bf70aca..581aac1 100644 --- a/src/libstddjb/getpeereid.c +++ b/src/libstddjb/getpeereid.c @@ -19,7 +19,7 @@ int getpeereid (int s, uid_t *u, gid_t *g) { struct ucred blah ; - unsigned int len = sizeof(blah) ; + socklen_t len = sizeof(blah) ; if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &blah, &len) == -1) return -1 ; diff --git a/src/libstddjb/hiercopy.c b/src/libstddjb/hiercopy.c index 34f027e..3fc4d2f 100644 --- a/src/libstddjb/hiercopy.c +++ b/src/libstddjb/hiercopy.c @@ -1,7 +1,7 @@ /* ISC license. */ -#include #include +#include int hiercopy (char const *src, char const *dst) { diff --git a/src/libstddjb/hiercopy_tmp.c b/src/libstddjb/hiercopy_tmp.c index ef76b57..79b7b46 100644 --- a/src/libstddjb/hiercopy_tmp.c +++ b/src/libstddjb/hiercopy_tmp.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include -#include #include #include +#include #include #include #include diff --git a/src/libstddjb/iobuffer_fill.c b/src/libstddjb/iobuffer_fill.c index 991dffc..a122090 100644 --- a/src/libstddjb/iobuffer_fill.c +++ b/src/libstddjb/iobuffer_fill.c @@ -1,13 +1,14 @@ /* ISC license. */ +#include #include #include -int iobuffer_fill (iobuffer_ref b) +ssize_t iobuffer_fill (iobuffer_ref b) { if (b->isk) { - register int r = iobufferk_fill(&b->x.k) ; + ssize_t r = iobufferk_fill(&b->x.k) ; if (r >= 0 || errno != ENOSYS || !iobuffer_salvage(b)) return r ; } return iobufferu_fill(&b->x.u) ; diff --git a/src/libstddjb/iobuffer_kfromu.c b/src/libstddjb/iobuffer_kfromu.c index 7942541..91525a5 100644 --- a/src/libstddjb/iobuffer_kfromu.c +++ b/src/libstddjb/iobuffer_kfromu.c @@ -9,7 +9,6 @@ #include #include #include -#include int iobuffer_kfromu (iobufferk *k, iobufferu *u) { diff --git a/src/libstddjb/iobuffer_ufromk.c b/src/libstddjb/iobuffer_ufromk.c index 778ddf2..940818d 100644 --- a/src/libstddjb/iobuffer_ufromk.c +++ b/src/libstddjb/iobuffer_ufromk.c @@ -4,6 +4,7 @@ #ifdef SKALIBS_HASSPLICE +#include #include int iobuffer_ufromk (iobufferu *u, iobufferk *k) @@ -12,7 +13,7 @@ int iobuffer_ufromk (iobufferu *u, iobufferk *k) u->b[0].fd = k->p[0] ; while (k->n) { - register int r = iobufferu_fill(u) ; + ssize_t r = iobufferu_fill(u) ; if (r <= 0) goto err ; k->n -= r ; } diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c index c811c24..0ae8763 100644 --- a/src/libstddjb/iobufferk_fill.c +++ b/src/libstddjb/iobufferk_fill.c @@ -9,30 +9,30 @@ #include #include -static int iobufferk_tee (iobufferk *k) +static ssize_t iobufferk_tee (iobufferk *k) { - register int r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; + ssize_t r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; return r ; } -static int iobufferk_splice (iobufferk *k) +static ssize_t iobufferk_splice (iobufferk *k) { - register int r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ; + ssize_t r = splice(k->fd[0], 0, k->fd[1], 0, IOBUFFERK_SIZE, k->nb ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ; return r ; } -static int iobufferk_fill_3 (iobufferk *k) +static ssize_t iobufferk_fill_3 (iobufferk *k) { - register int r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; + ssize_t r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ; if (r > 0) k->n += r ; if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ; return r ; } -iobufferk_io_func_t_ref const iobufferk_fill_f[4] = +iobufferk_input_func_t_ref const iobufferk_fill_f[4] = { &iobufferk_tee, &iobufferk_splice, &iobufferk_splice, &iobufferk_fill_3 } ; @@ -41,9 +41,15 @@ iobufferk_io_func_t_ref const iobufferk_fill_f[4] = #include -iobufferk_io_func_t_ref const iobufferk_fill_f[4] = +static ssize_t iobufferk_inosys (iobufferk *k) { - &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys + (void)k ; + return (errno = ENOSYS, -1) ; +} + +iobufferk_input_func_t_ref const iobufferk_fill_f[4] = +{ + &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys, &iobufferk_inosys } ; #endif diff --git a/src/libstddjb/iobufferk_flush.c b/src/libstddjb/iobufferk_flush.c index 674ffec..9bbff7d 100644 --- a/src/libstddjb/iobufferk_flush.c +++ b/src/libstddjb/iobufferk_flush.c @@ -13,7 +13,7 @@ static int iobufferk_flush_0 (iobufferk *k) { while (k->n) { - register int r = splice(k->fd[0], 0, k->p[1], 0, k->n, 0) ; + ssize_t r = splice(k->fd[0], 0, k->p[1], 0, k->n, 0) ; if (r < 0) return 0 ; else if (!r) break ; k->n -= r ; @@ -31,7 +31,7 @@ static int iobufferk_flush_3 (iobufferk *k) { while (k->n) { - register int r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ; + ssize_t r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ; if (r < 0) { if (errno == EINVAL) errno = ENOSYS ; @@ -43,7 +43,7 @@ static int iobufferk_flush_3 (iobufferk *k) return 1 ; } -iobufferk_io_func_t_ref const iobufferk_flush_f[4] = +iobufferk_output_func_t_ref const iobufferk_flush_f[4] = { &iobufferk_flush_0, &fakeflush, &fakeflush, &iobufferk_flush_3 } ; @@ -53,9 +53,15 @@ iobufferk_io_func_t_ref const iobufferk_flush_f[4] = #include #include -iobufferk_io_func_t_ref const iobufferk_flush_f[4] = +static int iobufferk_onosys (iobuffer_k *k) { - &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys, &iobufferk_nosys + (void)k ; + return (errno = ENOSYS, -1) ; +} + +iobufferk_output_func_t_ref const iobufferk_flush_f[4] = +{ + &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys, &iobufferk_onosys } ; #endif diff --git a/src/libstddjb/iobufferk_init.c b/src/libstddjb/iobufferk_init.c index 7affabd..93cd615 100644 --- a/src/libstddjb/iobufferk_init.c +++ b/src/libstddjb/iobufferk_init.c @@ -11,7 +11,7 @@ static int iobufferk_init_0 (iobufferk *k) { - register int fd = open_write("/dev/null") ; + int fd = open_write("/dev/null") ; if (fd < 0) return 0 ; if (coe(fd) < 0) { @@ -34,7 +34,7 @@ static int iobufferk_init_3 (iobufferk *k) return (pipenbcoe(k->p) >= 0) ; } -static iobufferk_io_func_t_ref iobufferk_init_f[4] = +static iobufferk_output_func_t_ref iobufferk_init_f[4] = { &iobufferk_init_0, &iobufferk_nofd, &iobufferk_nofd, &iobufferk_init_3 } ; @@ -43,7 +43,7 @@ int iobufferk_init (iobufferk *k, int fdin, int fdout) { iobufferk tmp ; struct stat st ; - register int r ; + int r ; if (fstat(fdin, &st) < 0) return 0 ; r = fcntl(fdin, F_GETFL) ; if (r < 0) return 0 ; diff --git a/src/libstddjb/iobufferk_isworking.c b/src/libstddjb/iobufferk_isworking.c index f671f81..119d130 100644 --- a/src/libstddjb/iobufferk_isworking.c +++ b/src/libstddjb/iobufferk_isworking.c @@ -17,7 +17,7 @@ int iobufferk_isworking (iobufferk *k) # if 0 - register int e = errno ; + int e = errno ; if (splice(k->fd[0], 0, k->p[1], 0, 0, 0) < 0) goto no ; if (splice(k->p[0], 0, k->fd[1], 0, 0, 0) < 0) goto no ; errno = e ; @@ -45,4 +45,3 @@ int iobufferk_isworking (iobufferk *k) } #endif - diff --git a/src/libstddjb/iobufferk_nosys.c b/src/libstddjb/iobufferk_nosys.c deleted file mode 100644 index 363e400..0000000 --- a/src/libstddjb/iobufferk_nosys.c +++ /dev/null @@ -1,10 +0,0 @@ -/* ISC license. */ - -#include -#include - -int iobufferk_nosys (iobufferk *k) -{ - (void)k ; - return (errno = ENOSYS, -1) ; -} diff --git a/src/libstddjb/iobufferu_fill.c b/src/libstddjb/iobufferu_fill.c index de1a56c..7867444 100644 --- a/src/libstddjb/iobufferu_fill.c +++ b/src/libstddjb/iobufferu_fill.c @@ -3,9 +3,9 @@ #include #include -int iobufferu_fill (iobufferu *b) +ssize_t iobufferu_fill (iobufferu *b) { - register int r = buffer_fill(&b->b[0]) ; + ssize_t r = buffer_fill(&b->b[0]) ; b->b[1].c.n = b->b[0].c.n ; return r ; } diff --git a/src/libstddjb/iobufferu_flush.c b/src/libstddjb/iobufferu_flush.c index 8830599..ad0fd9e 100644 --- a/src/libstddjb/iobufferu_flush.c +++ b/src/libstddjb/iobufferu_flush.c @@ -5,7 +5,7 @@ int iobufferu_flush (iobufferu *b) { - register int r = buffer_flush(&b->b[1]) ; + int r = buffer_flush(&b->b[1]) ; b->b[0].c.p = b->b[1].c.p ; return r ; } diff --git a/src/libstddjb/iopause_poll.c b/src/libstddjb/iopause_poll.c index e4e4da1..396122b 100644 --- a/src/libstddjb/iopause_poll.c +++ b/src/libstddjb/iopause_poll.c @@ -7,7 +7,7 @@ int iopause_poll (iopause_fd *x, unsigned int len, tain_t const *deadline, tain_t const *stamp) { - register int millisecs = 0 ; + int millisecs = 0 ; if (!deadline) millisecs = -1 ; else if (tain_less(stamp, deadline)) { diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c index dd433b7..3e56705 100644 --- a/src/libstddjb/iopause_select.c +++ b/src/libstddjb/iopause_select.c @@ -34,7 +34,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai } { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < len ; i++) { x[i].revents = 0 ; @@ -52,7 +52,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai if (r > 0) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < len ; i++) if (x[i].fd >= 0) { if ((x[i].events & IOPAUSE_READ) && FD_ISSET(x[i].fd, &rfds)) diff --git a/src/libstddjb/iopause_stamp.c b/src/libstddjb/iopause_stamp.c index d9a7e31..81056f4 100644 --- a/src/libstddjb/iopause_stamp.c +++ b/src/libstddjb/iopause_stamp.c @@ -4,9 +4,9 @@ #include #include -extern int iopause_stamp (iopause_fd *x, unsigned int n, tain_t const *deadline, tain_t *stamp) +int iopause_stamp (iopause_fd *x, unsigned int n, tain_t const *deadline, tain_t *stamp) { - register int r ; + int r ; do { r = iopause(x, n, deadline, stamp) ; diff --git a/src/libstddjb/ip46_scanlist.c b/src/libstddjb/ip46_scanlist.c index 7ee2b68..d6d5cbc 100644 --- a/src/libstddjb/ip46_scanlist.c +++ b/src/libstddjb/ip46_scanlist.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include -#include -#include +#include #include +#include size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *num) { @@ -11,7 +10,7 @@ size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *nu for (; s[w] && (n < max) ; n++) { ip46full_t z ; - register size_t i = ip6_scan(s + w, z.ip) ; + size_t i = ip6_scan(s + w, z.ip) ; if (i) z.is6 = 1 ; else { @@ -21,7 +20,7 @@ size_t ip46full_scanlist (ip46full_t *out, size_t max, char const *s, size_t *nu } out[n] = z ; w += i ; - while (byte_chr(",; \t\r\n", 6, s[w]) < 6) w++ ; + while (memchr(",; \t\r\n", s[w], 6)) w++ ; } *num = n ; return w ; diff --git a/src/libstddjb/ip4_scan.c b/src/libstddjb/ip4_scan.c index 749a176..19c2cec 100644 --- a/src/libstddjb/ip4_scan.c +++ b/src/libstddjb/ip4_scan.c @@ -6,11 +6,11 @@ size_t ip4_scan (char const *s, char *ip) { size_t len = 0 ; - register unsigned int j = 0 ; + unsigned int j = 0 ; for (; j < 4 ; j++) { unsigned int u ; - register size_t i = uint_scan(s, &u) ; + size_t i = uint_scan(s, &u) ; if (!i) return 0 ; ip[j] = (char)u ; s += i ; diff --git a/src/libstddjb/ip4_scanlist.c b/src/libstddjb/ip4_scanlist.c index edc2949..21985bd 100644 --- a/src/libstddjb/ip4_scanlist.c +++ b/src/libstddjb/ip4_scanlist.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include -#include +#include #include size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num) @@ -9,10 +8,10 @@ size_t ip4_scanlist (char *out, size_t max, char const *s, size_t *num) size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { - register size_t i = ip4_scan(s + w, out + (n << 2)) ; + size_t i = ip4_scan(s + w, out + (n << 2)) ; if (!i) break ; w += i ; - while (byte_chr(",:; \t\r\n", 7, s[w]) < 7) w++ ; + while (memchr(",:; \t\r\n", s[w], 7)) w++ ; } *num = n ; return w ; diff --git a/src/libstddjb/ip4_scanlist_u32.c b/src/libstddjb/ip4_scanlist_u32.c index 10c24cf..5515bca 100644 --- a/src/libstddjb/ip4_scanlist_u32.c +++ b/src/libstddjb/ip4_scanlist_u32.c @@ -1,9 +1,7 @@ /* ISC license. */ -#include #include -#include -#include +#include #include size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num) @@ -11,10 +9,10 @@ size_t ip4_scanlist_u32 (uint32_t *out, size_t max, char const *s, size_t *num) size_t n = 0, w = 0 ; for (; s[w] && (n < max) ; n++) { - register size_t i = ip4_scanu32(s + w, out + n) ; + size_t i = ip4_scanu32(s + w, out + n) ; if (!i) break ; w += i ; - while (byte_chr(",:; \t\r\n", 7, s[w]) < 7) w++ ; + while (memchr(",:; \t\r\n", s[w], 7)) w++ ; } *num = n ; return w ; diff --git a/src/libstddjb/ip6_scan.c b/src/libstddjb/ip6_scan.c index 1e34051..1837d3d 100644 --- a/src/libstddjb/ip6_scan.c +++ b/src/libstddjb/ip6_scan.c @@ -16,7 +16,7 @@ size_t ip6_scan (char const *s, char *ip6) while (state < 5) { - register unsigned char c = table[state][class[(unsigned char)s[i]] - '0'] ; + unsigned char c = table[state][class[(unsigned char)s[i]] - '0'] ; state = c & 7 ; if (c & 0x20) { if (pos < 8) state = 5 ; else pos = j ; } if (c & 0x10) diff --git a/src/libstddjb/ip6_scanlist.c b/src/libstddjb/ip6_scanlist.c index cf1c7fd..33eb055 100644 --- a/src/libstddjb/ip6_scanlist.c +++ b/src/libstddjb/ip6_scanlist.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include -#include +#include #include size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num) @@ -10,11 +9,11 @@ size_t ip6_scanlist (char *out, size_t max, char const *s, size_t *num) for (; s[w] && (n < max) ; n++) { char ip[16] ; - register size_t i = ip6_scan(s + w, ip) ; + size_t i = ip6_scan(s + w, ip) ; if (!i) break ; - byte_copy(out + (n << 4), 16, ip) ; + memcpy(out + (n << 4), ip, 16) ; w += i ; - while (byte_chr(",; \t\r\n", 6, s[w]) < 6) w++ ; + while (memchr(",; \t\r\n", s[w], 6)) w++ ; } *num = n ; return w ; diff --git a/src/libstddjb/ipc_accept.c b/src/libstddjb/ipc_accept.c index dc3eae7..5ff82d8 100644 --- a/src/libstddjb/ipc_accept.c +++ b/src/libstddjb/ipc_accept.c @@ -5,16 +5,17 @@ #include #include #include +#include #include #include #include -int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned int options) +int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int options) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; - register int fd ; - byte_zero((char*)&sa, (unsigned int)dummy) ; + int fd ; + memset(&sa, 0, dummy) ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; @@ -27,7 +28,7 @@ int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned in if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return -1 ; @@ -41,7 +42,7 @@ int ipc_accept_internal (int s, char *p, unsigned int l, int *trunc, unsigned in if (!l) return fd ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; - byte_copy(p, dummy, sa.sun_path) ; + memcpy(p, sa.sun_path, dummy) ; p[dummy] = 0 ; } return fd ; diff --git a/src/libstddjb/ipc_bind.c b/src/libstddjb/ipc_bind.c index 2bb8678..8686591 100644 --- a/src/libstddjb/ipc_bind.c +++ b/src/libstddjb/ipc_bind.c @@ -3,18 +3,18 @@ #include #include #include +#include #include -#include #include #include int ipc_bind (int s, char const *p) { struct sockaddr_un sa ; - register unsigned int l = str_len(p) ; + size_t l = strlen(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; - byte_zero((char *)&sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; - byte_copy(sa.sun_path, l+1, p) ; + memcpy(sa.sun_path, p, l+1) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/ipc_connect.c b/src/libstddjb/ipc_connect.c index 6c5eac2..9aa4dd9 100644 --- a/src/libstddjb/ipc_connect.c +++ b/src/libstddjb/ipc_connect.c @@ -4,18 +4,18 @@ #include #include #include -#include +#include #include #include int ipc_connect (int s, char const *p) { struct sockaddr_un sa ; - unsigned int l = str_len(p) ; + size_t l = strlen(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, 0) ; - byte_zero((char *) &sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; - byte_copy(sa.sun_path, l+1, p) ; + memcpy(sa.sun_path, p, l+1) ; if (connect(s, (struct sockaddr *)&sa, sizeof sa) == -1) { if (errno == EINTR) errno = EINPROGRESS ; diff --git a/src/libstddjb/ipc_connected.c b/src/libstddjb/ipc_connected.c index 4965c9f..a079fd5 100644 --- a/src/libstddjb/ipc_connected.c +++ b/src/libstddjb/ipc_connected.c @@ -13,7 +13,7 @@ int ipc_connected (int s) if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) { char ch ; - fd_read(s, &ch, 1) ; /* sets errno */ + fd_read(s, &ch, 1) ; return 0 ; } return 1 ; diff --git a/src/libstddjb/ipc_eid.c b/src/libstddjb/ipc_eid.c deleted file mode 100644 index 81f608a..0000000 --- a/src/libstddjb/ipc_eid.c +++ /dev/null @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include -#include -#include - -int ipc_eid (int s, unsigned int *u, unsigned int *g) -{ - uid_t dummyu ; - gid_t dummyg ; - if (getpeereid(s, &dummyu, &dummyg) < 0) return -1 ; - *u = (unsigned int)dummyu ; - *g = (unsigned int)dummyg ; - return 0 ; -} diff --git a/src/libstddjb/ipc_local.c b/src/libstddjb/ipc_local.c index 57ffb37..e617264 100644 --- a/src/libstddjb/ipc_local.c +++ b/src/libstddjb/ipc_local.c @@ -3,21 +3,22 @@ #include #include #include +#include #include #include -int ipc_local (int s, char *p, unsigned int l, int *trunc) +int ipc_local (int s, char *p, size_t l, int *trunc) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; - byte_zero((char *)&sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; dummy = byte_chr(sa.sun_path, dummy, 0) ; *trunc = 1 ; if (!l) return 0 ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; - byte_copy(p, dummy, sa.sun_path) ; + memcpy(p, sa.sun_path, dummy) ; p[dummy] = 0 ; return 0 ; } diff --git a/src/libstddjb/ipc_recv.c b/src/libstddjb/ipc_recv.c index 599bad8..5aa1c2b 100644 --- a/src/libstddjb/ipc_recv.c +++ b/src/libstddjb/ipc_recv.c @@ -4,16 +4,16 @@ #include #include #include -#include +#include #include #include -int ipc_recv (int fd, char *s, unsigned int len, char *path) +ssize_t ipc_recv (int fd, char *s, size_t len, char *path) { struct sockaddr_un sa = { .sun_family = AF_UNIX } ; socklen_t total = sizeof sa ; char tmp[len] ; - register int r ; + ssize_t r ; do r = recvfrom(fd, tmp, len, 0, (struct sockaddr *)&sa, &total) ; while ((r == -1) && (errno == EINTR)) ; if (r < 0) return r ; @@ -23,11 +23,11 @@ int ipc_recv (int fd, char *s, unsigned int len, char *path) if (total == sizeof(sa_family_t)) path[0] = 0 ; else { - unsigned int l = str_len(sa.sun_path) ; + size_t l = strlen(sa.sun_path) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; - byte_copy(path, l+1, sa.sun_path) ; + memcpy(path, sa.sun_path, l+1) ; } } - byte_copy(s, r, tmp) ; + memcpy(s, tmp, r) ; return r ; } diff --git a/src/libstddjb/ipc_send.c b/src/libstddjb/ipc_send.c index 0e71d98..967a64f 100644 --- a/src/libstddjb/ipc_send.c +++ b/src/libstddjb/ipc_send.c @@ -4,17 +4,17 @@ #include #include #include -#include +#include #include #include -int ipc_send (int fd, char const *s, unsigned int len, char const *path) +ssize_t ipc_send (int fd, char const *s, size_t len, char const *path) { struct sockaddr_un sa ; - register unsigned int l = str_len(path) ; + size_t l = strlen(path) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; - byte_zero(&sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; sa.sun_family = AF_UNIX ; - byte_copy(sa.sun_path, l+1, path) ; + memcpy(sa.sun_path, path, l+1) ; return sendto(fd, s, len, 0, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/ipc_timed_connect.c b/src/libstddjb/ipc_timed_connect.c index 4f8e73d..32e496e 100644 --- a/src/libstddjb/ipc_timed_connect.c +++ b/src/libstddjb/ipc_timed_connect.c @@ -14,7 +14,7 @@ int ipc_timed_connect (int s, char const *path, tain_t const *deadline, tain_t * if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; for (;;) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; else if (!r) return (errno = ETIMEDOUT, 0) ; else if (x.revents & IOPAUSE_EXCEPT) return 0 ; diff --git a/src/libstddjb/leapsecs_add.c b/src/libstddjb/leapsecs_add.c index 4b75f7d..7473693 100644 --- a/src/libstddjb/leapsecs_add.c +++ b/src/libstddjb/leapsecs_add.c @@ -3,10 +3,10 @@ #include #include "djbtime-internal.h" -void leapsecs_add (uint64 *t, int hit) +void leapsecs_add (uint64_t *t, int hit) { - uint64 u = *t ; - register unsigned int i = 0 ; + uint64_t u = *t ; + unsigned int i = 0 ; for (; i < leapsecs_table_len ; i++) { if (u < leapsecs_table[i]) break ; diff --git a/src/libstddjb/leapsecs_sub.c b/src/libstddjb/leapsecs_sub.c index f466fac..f5c1c9b 100644 --- a/src/libstddjb/leapsecs_sub.c +++ b/src/libstddjb/leapsecs_sub.c @@ -3,12 +3,12 @@ #include #include "djbtime-internal.h" -int leapsecs_sub (uint64 *t) +int leapsecs_sub (uint64_t *t) { - uint64 u = *t ; - uint64 d = 0 ; - register unsigned int i = 0 ; - register int hit = 0 ; + uint64_t u = *t ; + uint64_t d = 0 ; + unsigned int i = 0 ; + int hit = 0 ; for (; i < leapsecs_table_len ; i++) { if (u < leapsecs_table[i]) break ; diff --git a/src/libstddjb/leapsecs_table.c b/src/libstddjb/leapsecs_table.c index fcf17fa..5fd538b 100644 --- a/src/libstddjb/leapsecs_table.c +++ b/src/libstddjb/leapsecs_table.c @@ -7,7 +7,7 @@ #include "djbtime-internal.h" unsigned int const leapsecs_table_len = 27 ; -static uint64 const leapsecs_table_[27] = +static uint64_t const leapsecs_table_[27] = { TAI_MAGIC + 78796809, TAI_MAGIC + 94694410, @@ -37,4 +37,4 @@ static uint64 const leapsecs_table_[27] = TAI_MAGIC + 1435708834, TAI_MAGIC + 1483228835 } ; -uint64 const *const leapsecs_table = leapsecs_table_ ; +uint64_t const *const leapsecs_table = leapsecs_table_ ; diff --git a/src/libstddjb/localtm_from_ltm64.c b/src/libstddjb/localtm_from_ltm64.c index d549df9..e2cc382 100644 --- a/src/libstddjb/localtm_from_ltm64.c +++ b/src/libstddjb/localtm_from_ltm64.c @@ -5,14 +5,13 @@ #define _BSD_SOURCE #endif -#include #include #include #include #include #include -int localtm_from_ltm64 (struct tm *l, uint64 uu, int tz) +int localtm_from_ltm64 (struct tm *l, uint64_t uu, int tz) { if (uu < TAI_MAGIC) return (errno = EINVAL, 0) ; uu -= TAI_MAGIC ; diff --git a/src/libstddjb/localtm_from_sysclock.c b/src/libstddjb/localtm_from_sysclock.c index 939bb21..d63a6d8 100644 --- a/src/libstddjb/localtm_from_sysclock.c +++ b/src/libstddjb/localtm_from_sysclock.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include #include #include #include -int localtm_from_sysclock (struct tm *l, uint64 u, int tz) +int localtm_from_sysclock (struct tm *l, uint64_t u, int tz) { if (!ltm64_from_sysclock(&u)) return 0 ; return localtm_from_ltm64(l, u, tz) ; diff --git a/src/libstddjb/localtm_from_tai.c b/src/libstddjb/localtm_from_tai.c index ad12cf2..b6ddf47 100644 --- a/src/libstddjb/localtm_from_tai.c +++ b/src/libstddjb/localtm_from_tai.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include @@ -8,7 +7,7 @@ int localtm_from_tai (struct tm *l, tai_t const *t, int tz) { - uint64 u ; + uint64_t u ; if (!ltm64_from_tai(&u, t)) return 0 ; return localtm_from_ltm64(l, u, tz) ; } diff --git a/src/libstddjb/localtm_from_utc.c b/src/libstddjb/localtm_from_utc.c index 697621c..cbf6f31 100644 --- a/src/libstddjb/localtm_from_utc.c +++ b/src/libstddjb/localtm_from_utc.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include #include #include #include -int localtm_from_utc (struct tm *l, uint64 u, int tz) +int localtm_from_utc (struct tm *l, uint64_t u, int tz) { if (!ltm64_from_utc(&u)) return 0 ; return localtm_from_ltm64(l, u, tz) ; diff --git a/src/libstddjb/localtm_scan.c b/src/libstddjb/localtm_scan.c index 62bf4c3..60bf61b 100644 --- a/src/libstddjb/localtm_scan.c +++ b/src/libstddjb/localtm_scan.c @@ -11,7 +11,7 @@ size_t localtm_scan (char const *s, struct tm *l) struct tm ll = { .tm_isdst = -1 } ; size_t n = 0 ; unsigned int u ; - register size_t i = uint_scan(s+n, &u) ; + size_t i = uint_scan(s+n, &u) ; if (!i) goto fail ; n += i ; if (u < 1900) goto fail ; diff --git a/src/libstddjb/localtmn_from_sysclock.c b/src/libstddjb/localtmn_from_sysclock.c index 08e64b7..c52bca0 100644 --- a/src/libstddjb/localtmn_from_sysclock.c +++ b/src/libstddjb/localtmn_from_sysclock.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include diff --git a/src/libstddjb/localtmn_from_tain.c b/src/libstddjb/localtmn_from_tain.c index 78cc051..f4858b7 100644 --- a/src/libstddjb/localtmn_from_tain.c +++ b/src/libstddjb/localtmn_from_tain.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include diff --git a/src/libstddjb/localtmn_scan.c b/src/libstddjb/localtmn_scan.c index c9d4d19..d7fffe2 100644 --- a/src/libstddjb/localtmn_scan.c +++ b/src/libstddjb/localtmn_scan.c @@ -13,7 +13,7 @@ size_t localtmn_scan (char const *s, localtmn_t *l) if (*s++ != '.') m.nano = 0 ; else { - register size_t b = uint32_scan(s, &m.nano) ; + size_t b = uint32_scan(s, &m.nano) ; if (!b) return 0 ; n += b ; } diff --git a/src/libstddjb/lock_ex.c b/src/libstddjb/lock_ex.c index 19b9a9c..2645fab 100644 --- a/src/libstddjb/lock_ex.c +++ b/src/libstddjb/lock_ex.c @@ -12,15 +12,13 @@ int lock_ex (int fd) { int r ; - do - r = flock(fd, LOCK_EX) ; + do r = flock(fd, LOCK_EX) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else -#include #include #include #include @@ -28,8 +26,7 @@ int lock_ex (int fd) int lock_ex (int fd) { int r ; - do - r = lockf(fd, F_LOCK, 0) ; + do r = lockf(fd, F_LOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/lock_exnb.c b/src/libstddjb/lock_exnb.c index a1785a9..7d5302f 100644 --- a/src/libstddjb/lock_exnb.c +++ b/src/libstddjb/lock_exnb.c @@ -12,15 +12,13 @@ int lock_exnb (int fd) { int r ; - do - r = flock(fd, LOCK_EX | LOCK_NB) ; + do r = flock(fd, LOCK_EX | LOCK_NB) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else -#include #include #include #include @@ -28,8 +26,7 @@ int lock_exnb (int fd) int lock_exnb (int fd) { int r ; - do - r = lockf(fd, F_TLOCK, 0) ; + do r = lockf(fd, F_TLOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EACCES)) errno = EAGAIN ; return r ; diff --git a/src/libstddjb/lock_sh.c b/src/libstddjb/lock_sh.c index 4a42dc1..c942d0d 100644 --- a/src/libstddjb/lock_sh.c +++ b/src/libstddjb/lock_sh.c @@ -11,25 +11,22 @@ int lock_sh (int fd) { - register int r ; - do - r = flock(fd, LOCK_SH) ; + int r ; + do r = flock(fd, LOCK_SH) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else -#include #include #include #include int lock_sh (int fd) { - register int r ; - do - r = lockf(fd, F_LOCK, 0) ; + int r ; + do r = lockf(fd, F_LOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/lock_shnb.c b/src/libstddjb/lock_shnb.c index 6a8fd42..40c988d 100644 --- a/src/libstddjb/lock_shnb.c +++ b/src/libstddjb/lock_shnb.c @@ -11,25 +11,22 @@ int lock_shnb (int fd) { - register int r ; - do - r = flock(fd, LOCK_SH | LOCK_NB) ; + int r ; + do r = flock(fd, LOCK_SH | LOCK_NB) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else -#include #include #include #include int lock_shnb (int fd) { - register int r ; - do - r = lockf(fd, F_TLOCK, 0) ; + int r ; + do r = lockf(fd, F_TLOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EACCES)) errno = EAGAIN ; return r ; diff --git a/src/libstddjb/lock_un.c b/src/libstddjb/lock_un.c index 099716a..a029a7c 100644 --- a/src/libstddjb/lock_un.c +++ b/src/libstddjb/lock_un.c @@ -11,25 +11,22 @@ int lock_un (int fd) { - register int r ; - do - r = flock(fd, LOCK_UN) ; + int r ; + do r = flock(fd, LOCK_UN) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else -#include #include #include #include int lock_un (int fd) { - register int r ; - do - r = lockf(fd, F_ULOCK, 0) ; + int r ; + do r = lockf(fd, F_ULOCK, 0) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/ltm64_from_localtm.c b/src/libstddjb/ltm64_from_localtm.c index 6169f04..78e59a4 100644 --- a/src/libstddjb/ltm64_from_localtm.c +++ b/src/libstddjb/ltm64_from_localtm.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include #include #include -#include #include +#include #include -int ltm64_from_localtm (uint64 *uu, struct tm const *l) +int ltm64_from_localtm (uint64_t *uu, struct tm const *l) { struct tm ll = *l ; time_t u = mktime(&ll) ; diff --git a/src/libstddjb/ltm64_from_sysclock.c b/src/libstddjb/ltm64_from_sysclock.c index 54aca39..f169c59 100644 --- a/src/libstddjb/ltm64_from_sysclock.c +++ b/src/libstddjb/ltm64_from_sysclock.c @@ -8,15 +8,15 @@ #include -int ltm64_from_sysclock (uint64 *u) +int ltm64_from_sysclock (uint64_t *u) { - tai_t t = { *u + 10U } ; + tai_t t = { .x = *u + 10U } ; return ltm64_from_tai(u, &t) ; } #else -int ltm64_from_sysclock (uint64 *u) +int ltm64_from_sysclock (uint64_t *u) { return ltm64_from_utc(u) ; } diff --git a/src/libstddjb/ltm64_from_tai.c b/src/libstddjb/ltm64_from_tai.c index 9161a79..115c2cf 100644 --- a/src/libstddjb/ltm64_from_tai.c +++ b/src/libstddjb/ltm64_from_tai.c @@ -5,7 +5,7 @@ #include #include "djbtime-internal.h" -int ltm64_from_tai (uint64 *u, tai_t const *t) +int ltm64_from_tai (uint64_t *u, tai_t const *t) { switch (skalibs_tzisright()) { diff --git a/src/libstddjb/ltm64_from_utc.c b/src/libstddjb/ltm64_from_utc.c index 7e08eb1..cc96841 100644 --- a/src/libstddjb/ltm64_from_utc.c +++ b/src/libstddjb/ltm64_from_utc.c @@ -4,7 +4,7 @@ #include #include "djbtime-internal.h" -int ltm64_from_utc (uint64 *u) +int ltm64_from_utc (uint64_t *u) { switch (skalibs_tzisright()) { diff --git a/src/libstddjb/mininetstring_read.c b/src/libstddjb/mininetstring_read.c index f7c7a55..eaaaf99 100644 --- a/src/libstddjb/mininetstring_read.c +++ b/src/libstddjb/mininetstring_read.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include +#include #include #include -#include #include #include -int mininetstring_read (int fd, stralloc *sa, uint32 *w) +int mininetstring_read (int fd, stralloc *sa, uint32_t *w) { if (!*w) { @@ -15,8 +16,8 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w) { case -1 : return -1 ; case 0 : return 0 ; - case 1 : *w = ((uint32)pack[0] << 8) | (1U << 31) ; break ; - case 2 : *w = ((uint32)pack[0] << 8) | (uint32)pack[1] | (1U << 30) ; break ; + case 1 : *w = ((uint32_t)pack[0] << 8) | (1U << 31) ; break ; + case 2 : *w = ((uint32_t)pack[0] << 8) | (uint32_t)pack[1] | (1U << 30) ; break ; default : return (errno = EDOM, -1) ; } } @@ -27,7 +28,7 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w) { case -1 : return -1 ; case 0 : return (errno = EPIPE, -1) ; - case 1 : *w |= (uint32)c | (1U << 30) ; *w &= ~(1U << 31) ; break ; + case 1 : *w |= (uint32_t)c | (1U << 30) ; *w &= ~(1U << 31) ; break ; default : return (errno = EDOM, -1) ; } } @@ -37,7 +38,7 @@ int mininetstring_read (int fd, stralloc *sa, uint32 *w) *w &= ~(1U << 30) ; } { - register unsigned int r = allread(fd, sa->s + sa->len, *w) ; + size_t r = allread(fd, sa->s + sa->len, *w) ; sa->len += r ; *w -= r ; } return *w ? -1 : 1 ; diff --git a/src/libstddjb/mininetstring_write.c b/src/libstddjb/mininetstring_write.c index 5eddc7b..09833e2 100644 --- a/src/libstddjb/mininetstring_write.c +++ b/src/libstddjb/mininetstring_write.c @@ -1,12 +1,12 @@ /* ISC license. */ +#include #include #include -#include #include #include -int mininetstring_write (int fd, char const *s, uint16 len, uint32 *w) +int mininetstring_write (int fd, char const *s, uint16_t len, uint32_t *w) { if (!*w) { diff --git a/src/libstddjb/netstring_append.c b/src/libstddjb/netstring_append.c index 88098a4..8a10d64 100644 --- a/src/libstddjb/netstring_append.c +++ b/src/libstddjb/netstring_append.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include +#include #include -#include #include #include @@ -12,8 +11,8 @@ int netstring_appendb (stralloc *sa, char const *s, size_t len) size_t n = uint64_fmt(fmt, len) ; if (!stralloc_readyplus(sa, len + n + 2)) return 0 ; fmt[n] = ':' ; - byte_copy(sa->s + sa->len, n+1, fmt) ; - byte_copy(sa->s + sa->len + n+1, len, s) ; + memcpy(sa->s + sa->len, fmt, n+1) ; + memcpy(sa->s + sa->len + n+1, s, len) ; sa->s[sa->len + n+1 + len] = ',' ; sa->len += n + 2 + len ; return 1 ; diff --git a/src/libstddjb/netstring_appendv.c b/src/libstddjb/netstring_appendv.c index 1d9c290..652bd05 100644 --- a/src/libstddjb/netstring_appendv.c +++ b/src/libstddjb/netstring_appendv.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include @@ -11,16 +11,16 @@ int netstring_appendv (stralloc *sa, struct iovec const *v, unsigned int n) { char fmt[UINT64_FMT] ; size_t len = 0, pos ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) len += v[i].iov_len ; pos = uint64_fmt(fmt, len) ; if (!stralloc_readyplus(sa, len + pos + 2)) return 0 ; fmt[pos] = ':' ; - byte_copy(sa->s + sa->len, pos+1, fmt) ; + memcpy(sa->s + sa->len, fmt, pos+1) ; sa->len += pos+1 ; for (i = 0 ; i < n ; i++) { - byte_copy(sa->s + sa->len, v[i].iov_len, (char const *)v[i].iov_base) ; + memmove(sa->s + sa->len, v[i].iov_base, v[i].iov_len) ; sa->len += v[i].iov_len ; } sa->s[sa->len++] = ',' ; diff --git a/src/libstddjb/netstring_decode.c b/src/libstddjb/netstring_decode.c index d129ea8..68c68e1 100644 --- a/src/libstddjb/netstring_decode.c +++ b/src/libstddjb/netstring_decode.c @@ -3,13 +3,13 @@ #include #include #include -#include #include +#include ssize_t netstring_decode (stralloc *sa, char const *s, size_t len) { uint64_t nlen ; - register size_t pos ; + size_t pos ; if (!len) return 0 ; pos = uint64_scan(s, &nlen) ; if (pos >= len) return (errno = EINVAL, -1) ; diff --git a/src/libstddjb/netstring_encode.c b/src/libstddjb/netstring_encode.c index 6b2d0ea..786a4b1 100644 --- a/src/libstddjb/netstring_encode.c +++ b/src/libstddjb/netstring_encode.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include diff --git a/src/libstddjb/netstring_put.c b/src/libstddjb/netstring_put.c index 692d2fc..13aa7e0 100644 --- a/src/libstddjb/netstring_put.c +++ b/src/libstddjb/netstring_put.c @@ -15,21 +15,21 @@ int netstring_put (buffer *b, char const *s, size_t len, size_t *written) if (*written < n + 1) { size_t w = *written ; - ssize_t r = buffer_putall(b, fmt, n+1, &w) ; + int r = buffer_putall(b, fmt, n+1, &w) ; if (r < 0) return (*written = w, 0) ; *written = n+1 ; } if (*written < n+1 + len) { size_t w = *written - (n+1) ; - ssize_t r = buffer_putall(b, s, len, &w) ; + int r = buffer_putall(b, s, len, &w) ; *written = w + (n+1) ; if (r < 0) return (*written = n+1 + w, 0) ; *written = n+1 + len ; } { size_t w = 0 ; - ssize_t r = buffer_putall(b, ",", 1, &w) ; + int r = buffer_putall(b, ",", 1, &w) ; if (r < 0) return 0 ; } *written = 0 ; diff --git a/src/libstddjb/ntp_from_tain.c b/src/libstddjb/ntp_from_tain.c index 43d5a42..276a775 100644 --- a/src/libstddjb/ntp_from_tain.c +++ b/src/libstddjb/ntp_from_tain.c @@ -5,9 +5,9 @@ #include #include -int ntp_from_tain (uint64 *u, tain_t const *a) +int ntp_from_tain (uint64_t *u, tain_t const *a) { - uint64 secs, frac ; + uint64_t secs, frac ; if (!utc_from_tai(&secs, tain_secp(a))) return 0 ; secs += NTP_OFFSET ; if (secs < TAI_MAGIC + 2147483648UL) goto ifail ; diff --git a/src/libstddjb/open2.c b/src/libstddjb/open2.c index 780f345..1d2682e 100644 --- a/src/libstddjb/open2.c +++ b/src/libstddjb/open2.c @@ -7,9 +7,8 @@ int open2 (char const *s, unsigned int flags) { - register int r ; - do - r = open(s, (int)flags) ; + int r ; + do r = open(s, flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/open3.c b/src/libstddjb/open3.c index f990d63..f52b8cd 100644 --- a/src/libstddjb/open3.c +++ b/src/libstddjb/open3.c @@ -8,8 +8,7 @@ int open3 (char const *s, unsigned int flags, unsigned int mode) { register int r ; - do - r = open(s, (int)flags, (mode_t)mode) ; + do r = open(s, flags, mode) ; while ((r == -1) && (errno == EINTR)) ; return r ; } diff --git a/src/libstddjb/open_readb.c b/src/libstddjb/open_readb.c index a8b0518..6fcede1 100644 --- a/src/libstddjb/open_readb.c +++ b/src/libstddjb/open_readb.c @@ -4,9 +4,9 @@ int open_readb (char const *fn) { - register int fd = open_read(fn) ; - if (fd == -1) return -1 ; - if (ndelay_off(fd) == -1) + int fd = open_read(fn) ; + if (fd < 0) return -1 ; + if (ndelay_off(fd) < 0) { fd_close(fd) ; return -1 ; diff --git a/src/libstddjb/pathexec0.c b/src/libstddjb/pathexec0.c index 5241452..bfddfdf 100644 --- a/src/libstddjb/pathexec0.c +++ b/src/libstddjb/pathexec0.c @@ -1,7 +1,5 @@ /* ISC license. */ -/* MT-unsafe */ - #include #include diff --git a/src/libstddjb/pipe_internal.c b/src/libstddjb/pipe_internal.c index d5354de..a1e8a8f 100644 --- a/src/libstddjb/pipe_internal.c +++ b/src/libstddjb/pipe_internal.c @@ -4,8 +4,13 @@ #ifdef SKALIBS_HASPIPE2 +#ifndef _NETBSD_SOURCE #define _NETBSD_SOURCE +#endif + +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include @@ -34,7 +39,7 @@ int pipe_internal (int *p, unsigned int flags) return 0 ; err: { - register int e = errno ; + int e = errno ; fd_close(pi[1]) ; fd_close(pi[0]) ; errno = e ; diff --git a/src/libstddjb/prot_readgroups.c b/src/libstddjb/prot_readgroups.c index 5559882..47cbfc7 100644 --- a/src/libstddjb/prot_readgroups.c +++ b/src/libstddjb/prot_readgroups.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include int prot_readgroups (char const *name, gid_t *tab, unsigned int max) @@ -14,15 +14,15 @@ int prot_readgroups (char const *name, gid_t *tab, unsigned int max) for (;;) { struct group *gr ; - register char **member ; + char **member ; errno = 0 ; if (n >= max) break ; gr = getgrent() ; if (!gr) break ; for (member = gr->gr_mem ; *member ; member++) - if (!str_diff(name, *member)) break ; + if (!strcmp(name, *member)) break ; if (*member) tab[n++] = gr->gr_gid ; } endgrent() ; - return errno ? -1 : (int)n ; + return errno ? -1 : n ; } diff --git a/src/libstddjb/realpath.c b/src/libstddjb/realpath.c deleted file mode 100644 index f286137..0000000 --- a/src/libstddjb/realpath.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -/* MT-unsafe */ - -#include -#include - -char *realpath (char const *name, char *buf) -{ - return realpath_tmp(name, buf, &satmp) ; -} diff --git a/src/libstddjb/realpath_tmp.c b/src/libstddjb/realpath_tmp.c deleted file mode 100644 index 8f877dd..0000000 --- a/src/libstddjb/realpath_tmp.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ISC license. */ - -#include -#include -#include -#include -#include - -#ifndef PATH_MAX -# define PATH_MAX 4095 -#endif - -char *realpath_tmp (char const *name, char *buf, stralloc *tmp) -{ - unsigned int tmpbase = tmp->len ; - if (sarealpath(tmp, name) == -1) return (char *)0 ; - if (tmp->len - tmpbase > PATH_MAX) - { - tmp->len = tmpbase ; - return (errno = ENAMETOOLONG, (char *)0) ; - } - byte_copy(buf, tmp->len - tmpbase, tmp->s + tmpbase) ; - buf[tmp->len - tmpbase] = 0 ; - tmp->len = tmpbase ; - return buf ; -} diff --git a/src/libstddjb/sabasename.c b/src/libstddjb/sabasename.c index 8d9b6fc..dff30a5 100644 --- a/src/libstddjb/sabasename.c +++ b/src/libstddjb/sabasename.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include diff --git a/src/libstddjb/sadirname.c b/src/libstddjb/sadirname.c index ac818e8..176f26a 100644 --- a/src/libstddjb/sadirname.c +++ b/src/libstddjb/sadirname.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include #include diff --git a/src/libstddjb/sagetcwd.c b/src/libstddjb/sagetcwd.c index d8c5dea..90f9aae 100644 --- a/src/libstddjb/sagetcwd.c +++ b/src/libstddjb/sagetcwd.c @@ -2,13 +2,13 @@ #include #include -#include +#include #include #include int sagetcwd (stralloc *sa) { - unsigned int n = 128 ; + size_t n = 128 ; int wasnull = !sa->s ; for (;;) @@ -18,7 +18,7 @@ int sagetcwd (stralloc *sa) if (errno != ERANGE) goto err ; n += 128 ; } - sa->len += str_len(sa->s + sa->len) ; + sa->len += strlen(sa->s + sa->len) ; return 0 ; err: diff --git a/src/libstddjb/sagethostname.c b/src/libstddjb/sagethostname.c index 500a95c..b20db39 100644 --- a/src/libstddjb/sagethostname.c +++ b/src/libstddjb/sagethostname.c @@ -1,13 +1,13 @@ /* ISC license. */ #include -#include +#include #include #include int sagethostname (stralloc *sa) { - unsigned int n = 128 ; + size_t n = 128 ; int wasnull = !sa->s ; for (;;) @@ -18,7 +18,7 @@ int sagethostname (stralloc *sa) if (!sa->s[sa->len + n - 2]) break ; n += 128 ; } - sa->len += str_len(sa->s + sa->len) ; + sa->len += strlen(sa->s + sa->len) ; return 0 ; err: diff --git a/src/libstddjb/sareadlink.c b/src/libstddjb/sareadlink.c index d6c2a4e..90810e9 100644 --- a/src/libstddjb/sareadlink.c +++ b/src/libstddjb/sareadlink.c @@ -6,16 +6,16 @@ int sareadlink (stralloc *sa, char const *path) { - unsigned int n = 128 ; + size_t n = 128 ; int wasnull = !sa->s ; - register int r ; + ssize_t r ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; r = readlink(path, sa->s + sa->len, n) ; if (r < 0) goto err ; - if ((unsigned int)r < n) break ; + if ((size_t)r < n) break ; n += 128 ; } sa->len += r ; diff --git a/src/libstddjb/sauniquename.c b/src/libstddjb/sauniquename.c index ff102fa..c015dc3 100644 --- a/src/libstddjb/sauniquename.c +++ b/src/libstddjb/sauniquename.c @@ -9,17 +9,17 @@ int sauniquename (stralloc *sa) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; - if (!stralloc_readyplus(sa, TIMESTAMP + UINT_FMT + 131)) return 0 ; + if (!stralloc_readyplus(sa, TIMESTAMP + PID_FMT + 131)) return 0 ; sa->s[base] = ':' ; timestamp(sa->s + base + 1) ; sa->s[base + 1 + TIMESTAMP] = ':' ; sa->len = base + 2 + TIMESTAMP ; sa->len += pid_fmt(sa->s + sa->len, getpid()) ; sa->s[sa->len++] = ':' ; - if (sagethostname(sa) == -1) goto err ; + if (sagethostname(sa) < 0) goto err ; return 1 ; err: diff --git a/src/libstddjb/seek_cur.c b/src/libstddjb/seek_cur.c deleted file mode 100644 index cdfdac7..0000000 --- a/src/libstddjb/seek_cur.c +++ /dev/null @@ -1,10 +0,0 @@ -/* ISC license. */ - -#include -#include -#include - -long seek_cur (int fd) -{ - return (long)lseek(fd, 0, SEEK_CUR) ; -} diff --git a/src/libstddjb/seek_set.c b/src/libstddjb/seek_set.c deleted file mode 100644 index 70f6b0d..0000000 --- a/src/libstddjb/seek_set.c +++ /dev/null @@ -1,10 +0,0 @@ -/* ISC license. */ - -#include -#include -#include - -int seek_set (int fd, long pos) -{ - return lseek(fd, (off_t) pos, SEEK_SET) ; -} diff --git a/src/libstddjb/selfpipe_finish.c b/src/libstddjb/selfpipe_finish.c index 47a889f..5d9b3fd 100644 --- a/src/libstddjb/selfpipe_finish.c +++ b/src/libstddjb/selfpipe_finish.c @@ -2,8 +2,8 @@ /* MT-unsafe */ -#include #include +#include #include #include "selfpipe-internal.h" #include diff --git a/src/libstddjb/selfpipe_read.c b/src/libstddjb/selfpipe_read.c index b68e67d..b31c6bd 100644 --- a/src/libstddjb/selfpipe_read.c +++ b/src/libstddjb/selfpipe_read.c @@ -3,6 +3,7 @@ /* MT-unsafe */ #include +#include #include #include "selfpipe-internal.h" #include @@ -14,7 +15,7 @@ int selfpipe_read (void) { struct signalfd_siginfo buf ; - register int r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ; + ssize_t r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ; return (r <= 0) ? r : (int)buf.ssi_signo ; } @@ -23,7 +24,7 @@ int selfpipe_read (void) int selfpipe_read (void) { char c ; - register int r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ; + ssize_t r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ; return (r <= 0) ? r : (int)c ; } diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c index f8c35ee..ed09b50 100644 --- a/src/libstddjb/selfpipe_trapset.c +++ b/src/libstddjb/selfpipe_trapset.c @@ -39,7 +39,7 @@ int selfpipe_trapset (sigset_t const *set) if (selfpipe_fd < 0) return (errno = EBADF, -1) ; for (; i <= NSIG ; i++) { - register int h = sigismember(set, i) ; + int h = sigismember(set, i) ; if (h < 0) continue ; if (h) { diff --git a/src/libstddjb/selfpipe_untrap.c b/src/libstddjb/selfpipe_untrap.c index 776f2d7..7d82cf4 100644 --- a/src/libstddjb/selfpipe_untrap.c +++ b/src/libstddjb/selfpipe_untrap.c @@ -16,7 +16,7 @@ int selfpipe_untrap (int sig) { sigset_t ss = selfpipe_caught ; sigset_t blah ; - register int r = sigismember(&selfpipe_caught, sig) ; + int r = sigismember(&selfpipe_caught, sig) ; if (selfpipe_fd < 0) return (errno = EBADF, -1) ; if (r < 0) return -1 ; if (!r) return (errno = EINVAL, -1) ; @@ -42,7 +42,7 @@ int selfpipe_untrap (int sig) int selfpipe_untrap (int sig) { - register int r = sigismember(&selfpipe_caught, sig) ; + int r = sigismember(&selfpipe_caught, sig) ; if (selfpipe_fd < 0) return (errno = EBADF, -1) ; if (r < 0) return -1 ; if (!r) return (errno = EINVAL, -1) ; diff --git a/src/libstddjb/sig_number.c b/src/libstddjb/sig_number.c index cbd897d..a588abd 100644 --- a/src/libstddjb/sig_number.c +++ b/src/libstddjb/sig_number.c @@ -1,12 +1,12 @@ /* ISC license. */ -#include +#include #include #include "sig-internal.h" int sig_number (char const *name) { - register sigtable_t const *p = skalibs_sigtable ; - for (; p->name ; p++) if (!case_diffs(name, p->name)) break ; + sigtable_t const *p = skalibs_sigtable ; + for (; p->name ; p++) if (!strcasecmp(name, p->name)) break ; return p->number ; } diff --git a/src/libstddjb/sig_restoreto.c b/src/libstddjb/sig_restoreto.c index 523b14a..580ba32 100644 --- a/src/libstddjb/sig_restoreto.c +++ b/src/libstddjb/sig_restoreto.c @@ -7,10 +7,10 @@ void sig_restoreto (sigset_t const *set, unsigned int n) { - register unsigned int i = 1 ; + unsigned int i = 1 ; for (; i <= n ; i++) { - register int h = sigismember(set, i) ; + int h = sigismember(set, i) ; if (h < 0) continue ; if (h) sig_restore(i) ; } diff --git a/src/libstddjb/siovec_bytechr.c b/src/libstddjb/siovec_bytechr.c index 8c7e78c..295b949 100644 --- a/src/libstddjb/siovec_bytechr.c +++ b/src/libstddjb/siovec_bytechr.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/siovec_bytein.c b/src/libstddjb/siovec_bytein.c index bcf6e59..1d4200b 100644 --- a/src/libstddjb/siovec_bytein.c +++ b/src/libstddjb/siovec_bytein.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/siovec_deal.c b/src/libstddjb/siovec_deal.c index 3f802b9..9333358 100644 --- a/src/libstddjb/siovec_deal.c +++ b/src/libstddjb/siovec_deal.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/siovec_gather.c b/src/libstddjb/siovec_gather.c index b5fcbb7..c4138b6 100644 --- a/src/libstddjb/siovec_gather.c +++ b/src/libstddjb/siovec_gather.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/siovec_len.c b/src/libstddjb/siovec_len.c index 5465fd7..2f4f556 100644 --- a/src/libstddjb/siovec_len.c +++ b/src/libstddjb/siovec_len.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/siovec_scatter.c b/src/libstddjb/siovec_scatter.c index 3a583f3..d5ff1b2 100644 --- a/src/libstddjb/siovec_scatter.c +++ b/src/libstddjb/siovec_scatter.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/siovec_seek.c b/src/libstddjb/siovec_seek.c index f03b20a..44f8279 100644 --- a/src/libstddjb/siovec_seek.c +++ b/src/libstddjb/siovec_seek.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include @@ -8,7 +7,7 @@ size_t siovec_seek (struct iovec *v, unsigned int n, size_t len) { size_t w = 0 ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) { if (len < v[i].iov_len) break ; diff --git a/src/libstddjb/siovec_trunc.c b/src/libstddjb/siovec_trunc.c index ca40922..d71f9d9 100644 --- a/src/libstddjb/siovec_trunc.c +++ b/src/libstddjb/siovec_trunc.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/skagetln_nofill.c b/src/libstddjb/skagetln_nofill.c index ce28921..cbb4a31 100644 --- a/src/libstddjb/skagetln_nofill.c +++ b/src/libstddjb/skagetln_nofill.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/skagetlnsep.c b/src/libstddjb/skagetlnsep.c index f9813f3..dc6d520 100644 --- a/src/libstddjb/skagetlnsep.c +++ b/src/libstddjb/skagetlnsep.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/skalibs_tzisright.c b/src/libstddjb/skalibs_tzisright.c index f8414a6..ed24cc1 100644 --- a/src/libstddjb/skalibs_tzisright.c +++ b/src/libstddjb/skalibs_tzisright.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include "djbtime-internal.h" diff --git a/src/libstddjb/skasigaction.c b/src/libstddjb/skasigaction.c index bb55642..4b1ea8b 100644 --- a/src/libstddjb/skasigaction.c +++ b/src/libstddjb/skasigaction.c @@ -12,7 +12,7 @@ int skasigaction (int sig, struct skasigaction const *new, struct skasigaction * if (sigaction(sig, &sanew, &saold) < 0) return -1 ; if (old) { - register int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ; + int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ; if (r < 0) return -1 ; old->flags = 0 ; if (r) old->flags |= SKASA_MASKALL ; diff --git a/src/libstddjb/slurp.c b/src/libstddjb/slurp.c index 553b29e..d5b3b43 100644 --- a/src/libstddjb/slurp.c +++ b/src/libstddjb/slurp.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,10 +9,11 @@ int slurp (stralloc *sa, int fd) { - register unsigned int salen = sa->len ; + size_t salen = sa->len ; + int wasnull = !sa->s ; for (;;) { - int r ; + ssize_t r ; if (!stralloc_readyplus(sa, N)) break ; r = fd_read(fd, sa->s + sa->len, N) ; switch (r) @@ -25,7 +27,11 @@ int slurp (stralloc *sa, int fd) } } err: - sa->len = salen ; - stralloc_shrink(sa) ; + if (wasnull) stralloc_free(sa) ; + else + { + sa->len = salen ; + stralloc_shrink(sa) ; + } return 0 ; } diff --git a/src/libstddjb/socket_accept4.c b/src/libstddjb/socket_accept4.c index e504375..a50ade0 100644 --- a/src/libstddjb/socket_accept4.c +++ b/src/libstddjb/socket_accept4.c @@ -4,17 +4,18 @@ #include #include #include +#include +#include #include #include -#include #include #include -int socket_accept4_internal (int s, char *ip, uint16 *port, unsigned int options) +int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int options) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - register int fd ; + int fd ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; @@ -27,13 +28,13 @@ int socket_accept4_internal (int s, char *ip, uint16 *port, unsigned int options if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return -1 ; } #endif - byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ; + memcpy(ip, &sa.sin_addr.s_addr, 4) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return fd ; } diff --git a/src/libstddjb/socket_accept4_u32.c b/src/libstddjb/socket_accept4_u32.c index 18455fc..1817ec3 100644 --- a/src/libstddjb/socket_accept4_u32.c +++ b/src/libstddjb/socket_accept4_u32.c @@ -1,13 +1,13 @@ /* ISC license. */ -#include +#include #include #include -int socket_accept4_internal_u32 (int s, uint32 *ip, uint16 *port, unsigned int options) +int socket_accept4_internal_u32 (int s, uint32_t *ip, uint16_t *port, unsigned int options) { char pack[4] ; - register int r = socket_accept4_internal(s, pack, port, options) ; - if (r >= 0) uint32_unpack_big(pack, ip) ; - return r ; + int fd = socket_accept4_internal(s, pack, port, options) ; + if (fd >= 0) uint32_unpack_big(pack, ip) ; + return fd ; } diff --git a/src/libstddjb/socket_accept6.c b/src/libstddjb/socket_accept6.c index f52efbb..ff11bce 100644 --- a/src/libstddjb/socket_accept6.c +++ b/src/libstddjb/socket_accept6.c @@ -4,20 +4,21 @@ #include #include #include +#include +#include #include #include -#include #include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int options) +int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - register int fd ; + int fd ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; @@ -30,20 +31,20 @@ int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int option if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return -1 ; } #endif - byte_copy(ip6, 16, (char const *)sa.sin6_addr.s6_addr) ; + memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return fd ; } #else -int socket_accept6_internal (int s, char *ip6, uint16 *port, unsigned int options) +int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options) { (void)s ; (void)ip6 ; diff --git a/src/libstddjb/socket_bind4.c b/src/libstddjb/socket_bind4.c index 1078fbc..6700b1e 100644 --- a/src/libstddjb/socket_bind4.c +++ b/src/libstddjb/socket_bind4.c @@ -2,18 +2,19 @@ #include #include +#include +#include #include #include -#include #include -int socket_bind4 (int s, char const *ip, uint16 port) +int socket_bind4 (int s, char const *ip, uint16_t port) { struct sockaddr_in sa ; - byte_zero(&sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; uint16_big_endian((char *)&port, 1) ; sa.sin_port = port ; - byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ; + memcpy(&sa.sin_addr.s_addr, ip, 4) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/socket_bind4r.c b/src/libstddjb/socket_bind4r.c index 55f0903..2c43d9a 100644 --- a/src/libstddjb/socket_bind4r.c +++ b/src/libstddjb/socket_bind4r.c @@ -2,12 +2,12 @@ #include #include -#include +#include #include -int socket_bind4_reuse (int s, char const *ip, uint16 port) +int socket_bind4_reuse (int s, char const *ip, uint16_t port) { - unsigned int opt = 1 ; + static unsigned int const opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return socket_bind4(s, ip, port) ; } diff --git a/src/libstddjb/socket_bind6.c b/src/libstddjb/socket_bind6.c index 63fa412..e6c08fe 100644 --- a/src/libstddjb/socket_bind6.c +++ b/src/libstddjb/socket_bind6.c @@ -4,26 +4,27 @@ #include #include #include +#include +#include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_bind6 (int s, char const *ip6, uint16 port) +int socket_bind6 (int s, char const *ip6, uint16_t port) { struct sockaddr_in6 sa ; - byte_zero(&sa, sizeof sa) ; + memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port, port) ; - byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; + memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } #else -int socket_bind6 (int s, char const *ip6, uint16 port) +int socket_bind6 (int s, char const *ip6, uint16_t port) { (void)s ; (void)ip6 ; diff --git a/src/libstddjb/socket_bind6r.c b/src/libstddjb/socket_bind6r.c index 6bf5e0d..de24c61 100644 --- a/src/libstddjb/socket_bind6r.c +++ b/src/libstddjb/socket_bind6r.c @@ -2,12 +2,12 @@ #include #include -#include +#include #include -int socket_bind6_reuse (int s, char const *ip6, uint16 port) +int socket_bind6_reuse (int s, char const *ip6, uint16_t port) { - unsigned int opt = 1 ; + static unsigned int const opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return socket_bind6(s, ip6, port) ; } diff --git a/src/libstddjb/socket_conn4.c b/src/libstddjb/socket_conn4.c index 12459a8..78a10b9 100644 --- a/src/libstddjb/socket_conn4.c +++ b/src/libstddjb/socket_conn4.c @@ -3,20 +3,21 @@ #include #include #include +#include +#include #include #include -#include #include -int socket_connect4 (int s, char const *ip, uint16 port) +int socket_connect4 (int s, char const *ip, uint16_t port) { struct sockaddr_in sa ; - register int r ; - byte_zero(&sa, sizeof sa) ; + int r ; + memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; uint16_big_endian((char *)&port, 1) ; sa.sin_port = port ; - byte_copy((char *)&sa.sin_addr.s_addr, 4, ip) ; + memcpy(&sa.sin_addr.s_addr, ip, 4) ; 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_conn4_u32.c b/src/libstddjb/socket_conn4_u32.c index 20887ce..162bf72 100644 --- a/src/libstddjb/socket_conn4_u32.c +++ b/src/libstddjb/socket_conn4_u32.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include +#include #include #include -int socket_connect4_u32 (int s, uint32 ip, uint16 port) +int socket_connect4_u32 (int s, uint32_t ip, uint16_t port) { char pack[4] ; uint32_pack_big(pack, ip) ; diff --git a/src/libstddjb/socket_conn6.c b/src/libstddjb/socket_conn6.c index 57bb3f8..9b0316b 100644 --- a/src/libstddjb/socket_conn6.c +++ b/src/libstddjb/socket_conn6.c @@ -3,22 +3,23 @@ #include #include #include +#include +#include #include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_connect6 (int s, char const *ip6, uint16 port) +int socket_connect6 (int s, char const *ip6, uint16_t port) { struct sockaddr_in6 sa ; - register int r ; - byte_zero(&sa, sizeof sa) ; + int r ; + memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port,port) ; - byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; + memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ; @@ -27,7 +28,7 @@ int socket_connect6 (int s, char const *ip6, uint16 port) #else -int socket_connect6 (int s, char const *ip6, uint16 port) +int socket_connect6 (int s, char const *ip6, uint16_t port) { (void)s ; (void)ip6 ; diff --git a/src/libstddjb/socket_connected.c b/src/libstddjb/socket_connected.c index 895eaf3..58ca463 100644 --- a/src/libstddjb/socket_connected.c +++ b/src/libstddjb/socket_connected.c @@ -13,7 +13,7 @@ int socket_connected (int s) if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) { char ch ; - fd_read(s, &ch, 1) ; /* sets errno */ + fd_read(s, &ch, 1) ; return 0 ; } return 1 ; diff --git a/src/libstddjb/socket_deadlineconnstamp4.c b/src/libstddjb/socket_deadlineconnstamp4.c index 618852f..a57718d 100644 --- a/src/libstddjb/socket_deadlineconnstamp4.c +++ b/src/libstddjb/socket_deadlineconnstamp4.c @@ -1,12 +1,12 @@ /* ISC license. */ #include -#include +#include #include #include #include -int socket_deadlineconnstamp (int s, char const *ip, uint16 port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp) { if (socket_connect4(s, ip, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; diff --git a/src/libstddjb/socket_deadlineconnstamp46.c b/src/libstddjb/socket_deadlineconnstamp46.c index 4ab2c9a..774e840 100644 --- a/src/libstddjb/socket_deadlineconnstamp46.c +++ b/src/libstddjb/socket_deadlineconnstamp46.c @@ -1,13 +1,13 @@ /* ISC license. */ #include -#include +#include #include #include #include #include -int socket_deadlineconnstamp46 (int s, ip46_t const *i, uint16 port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp46 (int s, ip46_t const *i, uint16_t port, tain_t const *deadline, tain_t *stamp) { if (socket_connect46(s, i, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; diff --git a/src/libstddjb/socket_deadlineconnstamp4_u32.c b/src/libstddjb/socket_deadlineconnstamp4_u32.c index 4a82e50..296f26d 100644 --- a/src/libstddjb/socket_deadlineconnstamp4_u32.c +++ b/src/libstddjb/socket_deadlineconnstamp4_u32.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include +#include #include #include #include -int socket_deadlineconnstamp4_u32 (int s, uint32 ip, uint16 port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp4_u32 (int s, uint32_t ip, uint16_t port, tain_t const *deadline, tain_t *stamp) { char pack[4] ; uint32_pack_big(pack, ip) ; diff --git a/src/libstddjb/socket_deadlineconnstamp6.c b/src/libstddjb/socket_deadlineconnstamp6.c index a797d1e..7d7bcab 100644 --- a/src/libstddjb/socket_deadlineconnstamp6.c +++ b/src/libstddjb/socket_deadlineconnstamp6.c @@ -1,12 +1,12 @@ /* ISC license. */ #include -#include +#include #include #include #include -int socket_deadlineconnstamp6 (int s, char const *ip, uint16 port, tain_t const *deadline, tain_t *stamp) +int socket_deadlineconnstamp6 (int s, char const *ip, uint16_t port, tain_t const *deadline, tain_t *stamp) { if (socket_connect6(s, ip, port) >= 0) return 1 ; if (!error_isagain(errno) && !error_isalready(errno)) return 0 ; diff --git a/src/libstddjb/socket_internal.c b/src/libstddjb/socket_internal.c index ae57e06..f8b0a1f 100644 --- a/src/libstddjb/socket_internal.c +++ b/src/libstddjb/socket_internal.c @@ -22,7 +22,7 @@ int socket_internal (int domain, int type, int protocol, unsigned int flags) if ((((flags & DJBUNIX_FLAG_NB) ? ndelay_on(s) : ndelay_off(s)) < 0) || (((flags & DJBUNIX_FLAG_COE) ? coe(s) : uncoe(s)) < 0)) { - register int e = errno ; + int e = errno ; fd_close(s) ; errno = e ; return -1 ; diff --git a/src/libstddjb/socket_ioloop.c b/src/libstddjb/socket_ioloop.c index a158f01..0a3a5ae 100644 --- a/src/libstddjb/socket_ioloop.c +++ b/src/libstddjb/socket_ioloop.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include +#include #include #include -#include #include #include #include -int socket_ioloop (int s, char *buf, unsigned int len, char *ip, uint16 *port, socket_io_func_t_ref f, int w, tain_t const *deadline, tain_t *stamp) +ssize_t socket_ioloop (int s, char *buf, size_t len, char *ip, uint16_t *port, socket_io_func_t_ref f, int w, tain_t const *deadline, tain_t *stamp) { iopause_fd x = { .fd = s, .events = w ? IOPAUSE_WRITE : IOPAUSE_READ, .revents = 0 } ; for (;;) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + ssize_t r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return -1 ; if (!r) return (errno = ETIMEDOUT, -1) ; if (x.revents & IOPAUSE_EXCEPT) return (errno = EIO, -1) ; diff --git a/src/libstddjb/socket_ioloop_send4.c b/src/libstddjb/socket_ioloop_send4.c index aff251d..94eb311 100644 --- a/src/libstddjb/socket_ioloop_send4.c +++ b/src/libstddjb/socket_ioloop_send4.c @@ -1,8 +1,10 @@ /* ISC license. */ +#include +#include #include -int socket_ioloop_send4 (int fd, char *s, unsigned int len, char *ip, uint16 *port) +ssize_t socket_ioloop_send4 (int fd, char *s, size_t len, char *ip, uint16_t *port) { return socket_send4(fd, s, len, ip, *port) ; } diff --git a/src/libstddjb/socket_ioloop_send6.c b/src/libstddjb/socket_ioloop_send6.c index 151a58c..f201437 100644 --- a/src/libstddjb/socket_ioloop_send6.c +++ b/src/libstddjb/socket_ioloop_send6.c @@ -1,8 +1,10 @@ /* ISC license. */ +#include +#include #include -int socket_ioloop_send6 (int fd, char *s, unsigned int len, char *ip, uint16 *port) +ssize_t socket_ioloop_send6 (int fd, char *s, size_t len, char *ip, uint16_t *port) { return socket_send6(fd, s, len, ip, *port) ; } diff --git a/src/libstddjb/socket_local4.c b/src/libstddjb/socket_local4.c index 90ae93a..60dcd9d 100644 --- a/src/libstddjb/socket_local4.c +++ b/src/libstddjb/socket_local4.c @@ -3,18 +3,18 @@ #include #include #include +#include +#include #include -#include #include -int socket_local4 (int s, char *ip, uint16 *port) +int socket_local4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ; + memcpy(ip, &sa.sin_addr.s_addr, 4) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return 0 ; } diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c index 0eeed8c..2483996 100644 --- a/src/libstddjb/socket_local46.c +++ b/src/libstddjb/socket_local46.c @@ -4,28 +4,29 @@ #include #include #include +#include +#include #include -#include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_local46 (int s, ip46_t *ip, uint16 *port) +int socket_local46 (int s, ip46_t *ip, uint16_t *port) { struct sockaddr_storage sa ; socklen_t dummy = sizeof sa ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) < 0) return -1 ; if (sa.ss_family == AF_INET6) { - register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; - byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ; + struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; + memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; uint16_unpack_big((char *)&sa6->sin6_port, port) ; ip->is6 = 1 ; } else if (sa.ss_family == AF_INET) { - register struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; - byte_copy(ip->ip, 4, (char const *)&sa4->sin_addr.s_addr) ; + struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; + memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; 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 b7025fc..6c2a0e5 100644 --- a/src/libstddjb/socket_local6.c +++ b/src/libstddjb/socket_local6.c @@ -3,21 +3,21 @@ #include #include #include +#include +#include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_local6 (int s, char *ip, uint16 *port) +int socket_local6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ; + memcpy(ip, sa.sin6_addr.s6_addr, 16) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return 0 ; } @@ -26,7 +26,7 @@ int socket_local6 (int s, char *ip, uint16 *port) #include -int socket_local6 (int s, char *ip, uint16 *port) +int socket_local6 (int s, char *ip, uint16_t *port) { (void)s ; (void)ip ; diff --git a/src/libstddjb/socket_recv4.c b/src/libstddjb/socket_recv4.c index 02354e9..09572d9 100644 --- a/src/libstddjb/socket_recv4.c +++ b/src/libstddjb/socket_recv4.c @@ -3,20 +3,21 @@ #include #include #include +#include +#include #include #include -#include #include -int socket_recv4 (int s, char *buf, unsigned int len, char *ip, uint16 *port) +ssize_t socket_recv4 (int s, char *buf, size_t len, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - register int r ; + ssize_t r ; do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; - byte_copy(ip, 4, (char *)&sa.sin_addr) ; + memcpy(ip, &sa.sin_addr, 4) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return r ; } diff --git a/src/libstddjb/socket_recv6.c b/src/libstddjb/socket_recv6.c index 6b2b4fc..be6ce3f 100644 --- a/src/libstddjb/socket_recv6.c +++ b/src/libstddjb/socket_recv6.c @@ -4,29 +4,30 @@ #include #include #include +#include +#include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_recv6 (int s, char *buf, unsigned int len, char *ip6, uint16 *port) +ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - register int r ; + ssize_t r ; 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, (char const *)sa.sin6_addr.s6_addr) ; + memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return r ; } #else -int socket_recv6 (int s, char *buf, unsigned int len, char *ip6, uint16 *port) +ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port) { (void)s ; (void)buf ; diff --git a/src/libstddjb/socket_remote4.c b/src/libstddjb/socket_remote4.c index 767a694..57058d5 100644 --- a/src/libstddjb/socket_remote4.c +++ b/src/libstddjb/socket_remote4.c @@ -3,18 +3,18 @@ #include #include #include +#include +#include #include -#include #include -int socket_remote4 (int s, char *ip, uint16 *port) +int socket_remote4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 4, (char *)&sa.sin_addr.s_addr) ; + memcpy(ip, &sa.sin_addr.s_addr, 4) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return 0 ; } diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c index da91417..6bd24a9 100644 --- a/src/libstddjb/socket_remote46.c +++ b/src/libstddjb/socket_remote46.c @@ -4,28 +4,29 @@ #include #include #include +#include +#include #include -#include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_remote46 (int s, ip46_t *ip, uint16 *port) +int socket_remote46 (int s, ip46_t *ip, uint16_t *port) { struct sockaddr sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, &sa, &dummy) < 0) return -1 ; if (sa.sa_family == AF_INET6) { - register struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; - byte_copy(ip->ip, 16, (char const *)sa6->sin6_addr.s6_addr) ; + struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; + memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; 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, (char const *)&sa4->sin_addr.s_addr) ; + struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; + memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; 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 4c642e1..6b282ef 100644 --- a/src/libstddjb/socket_remote6.c +++ b/src/libstddjb/socket_remote6.c @@ -4,28 +4,28 @@ #include #include #include +#include +#include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_remote6 (int s, char *ip, uint16 *port) +int socket_remote6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; - byte_copy(ip, 16, (char const *)sa.sin6_addr.s6_addr) ; + memcpy(ip, sa.sin6_addr.s6_addr, 16) ; uint16_unpack_big((char *)&sa.sin6_port, port) ; return 0 ; } #else -int socket_remote6 (int s, char *ip, uint16 *port) +int socket_remote6 (int s, char *ip, uint16_t *port) { (void)s ; (void)ip ; diff --git a/src/libstddjb/socket_send4.c b/src/libstddjb/socket_send4.c index 6078dff..0431aa5 100644 --- a/src/libstddjb/socket_send4.c +++ b/src/libstddjb/socket_send4.c @@ -3,19 +3,20 @@ #include #include #include +#include +#include #include #include -#include #include -int socket_send4 (int s, char const *buf, unsigned int len, char const *ip, uint16 port) +ssize_t socket_send4 (int s, char const *buf, size_t len, char const *ip, uint16_t port) { struct sockaddr_in sa ; - register int r ; - byte_zero((char *)&sa, sizeof sa) ; + ssize_t r ; + memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; uint16_pack_big((char *)&sa.sin_port, port) ; - byte_copy((char *)&sa.sin_addr, 4, ip) ; + memcpy(&sa.sin_addr, ip, 4) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; diff --git a/src/libstddjb/socket_send6.c b/src/libstddjb/socket_send6.c index 6349cdb..82a0357 100644 --- a/src/libstddjb/socket_send6.c +++ b/src/libstddjb/socket_send6.c @@ -1,24 +1,25 @@ /* ISC license. */ #include +#include +#include #include #include #include #include -#include #include #include #ifdef SKALIBS_IPV6_ENABLED -int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uint16 port) +ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port) { struct sockaddr_in6 sa ; - register int r ; - byte_zero((char *)&sa, sizeof sa) ; + ssize_t r ; + memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; uint16_pack_big((char *)&sa.sin6_port, port) ; - byte_copy((char *)sa.sin6_addr.s6_addr, 16, ip6) ; + memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; @@ -26,7 +27,7 @@ int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uin #else -int socket_send6 (int s, char const *buf, unsigned int len, char const *ip6, uint16 port) +ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port) { (void)s ; (void)buf ; diff --git a/src/libstddjb/socket_tcp6.c b/src/libstddjb/socket_tcp6.c index fd282fc..df6dd86 100644 --- a/src/libstddjb/socket_tcp6.c +++ b/src/libstddjb/socket_tcp6.c @@ -18,7 +18,7 @@ int socket_tcp6_internal (unsigned int flags) int option = 1 ; if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return -1 ; diff --git a/src/libstddjb/socket_timeoutconn.c b/src/libstddjb/socket_timeoutconn.c index ec7e251..3288426 100644 --- a/src/libstddjb/socket_timeoutconn.c +++ b/src/libstddjb/socket_timeoutconn.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include +#include #include #include -int socket_timeoutconn (int s, char const *ip, uint16 port, unsigned int timeout) +int socket_timeoutconn (int s, char const *ip, uint16_t port, unsigned int timeout) { tain_t stamp, deadline ; tain_now(&stamp) ; diff --git a/src/libstddjb/socket_tryr.c b/src/libstddjb/socket_tryr.c index 6544c9d..26c04b2 100644 --- a/src/libstddjb/socket_tryr.c +++ b/src/libstddjb/socket_tryr.c @@ -8,7 +8,7 @@ void socket_tryreservein (int s, unsigned int size) { while (size >= 1024) { - if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size) == 0) return ; + if (!setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size)) return ; size -= (size >> 5) ; } } diff --git a/src/libstddjb/socket_udp6.c b/src/libstddjb/socket_udp6.c index 41d395a..c8f5928 100644 --- a/src/libstddjb/socket_udp6.c +++ b/src/libstddjb/socket_udp6.c @@ -18,7 +18,7 @@ int socket_udp6_internal (unsigned int flags) int option = 1 ; if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &option, sizeof(option)) < 0) { - register int e = errno ; + int e = errno ; fd_close(fd) ; errno = e ; return -1 ; diff --git a/src/libstddjb/socket_waitconn.c b/src/libstddjb/socket_waitconn.c index 6e5c352..aca0bbf 100644 --- a/src/libstddjb/socket_waitconn.c +++ b/src/libstddjb/socket_waitconn.c @@ -11,7 +11,7 @@ int socket_waitconn (int s, tain_t const *deadline, tain_t *stamp) iopause_fd x = { s, IOPAUSE_WRITE, 0 } ; for (;;) { - register int r = iopause_stamp(&x, 1, deadline, stamp) ; + int r = iopause_stamp(&x, 1, deadline, stamp) ; if (r < 0) return 0 ; if (!r) return (errno = ETIMEDOUT, 0) ; if (x.revents & IOPAUSE_WRITE) break ; diff --git a/src/libstddjb/socketpair_internal.c b/src/libstddjb/socketpair_internal.c index 8e62bdf..a1e64c5 100644 --- a/src/libstddjb/socketpair_internal.c +++ b/src/libstddjb/socketpair_internal.c @@ -45,7 +45,7 @@ int socketpair_internal (int domain, int type, int protocol, unsigned int flags, err: { - register int e = errno ; + int e = errno ; fd_close(fd[1]) ; fd_close(fd[0]) ; errno = e ; diff --git a/src/libstddjb/str_chr.c b/src/libstddjb/str_chr.c index a415de6..bbb67f9 100644 --- a/src/libstddjb/str_chr.c +++ b/src/libstddjb/str_chr.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/str_rchr.c b/src/libstddjb/str_rchr.c index c82ee69..76e8e4e 100644 --- a/src/libstddjb/str_rchr.c +++ b/src/libstddjb/str_rchr.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include #include #include -size_t str_rchr (register char const *s, int c) +size_t str_rchr (char const *s, int c) { - register char *p = strrchr(s, c) ; + char *p = strrchr(s, c) ; return p ? p - s : strlen(s) ; } diff --git a/src/libstddjb/str_start.c b/src/libstddjb/str_start.c index 30396bd..a254a9a 100644 --- a/src/libstddjb/str_start.c +++ b/src/libstddjb/str_start.c @@ -1,16 +1,9 @@ /* ISC license. */ +#include #include -int str_start (register char const *s, register char const *t) +int str_start (char const *s, char const *t) { - register char x ; - - for (;;) - { - x = *t++; if (!x) return 1; if (x != *s++) return 0; - x = *t++; if (!x) return 1; if (x != *s++) return 0; - x = *t++; if (!x) return 1; if (x != *s++) return 0; - x = *t++; if (!x) return 1; if (x != *s++) return 0; - } + return !strncmp(s, t, strlen(t)) ; } diff --git a/src/libstddjb/str_strn.c b/src/libstddjb/str_strn.c index fef219b..b7c3090 100644 --- a/src/libstddjb/str_strn.c +++ b/src/libstddjb/str_strn.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include @@ -9,8 +8,8 @@ size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t n char haystack2[hlen+1] ; char needle2[nlen+1] ; char *p ; - byte_copy(haystack2, hlen, haystack) ; haystack2[hlen] = 0 ; - byte_copy(needle2, nlen, needle) ; needle2[nlen] = 0 ; + memcpy(haystack2, haystack, hlen) ; haystack2[hlen] = 0 ; + memcpy(needle2, needle, nlen) ; needle2[nlen] = 0 ; p = strstr(haystack2, needle2) ; return p ? p - haystack2 : hlen ; } diff --git a/src/libstddjb/stralloc_catb.c b/src/libstddjb/stralloc_catb.c index f1bdc0a..dac5075 100644 --- a/src/libstddjb/stralloc_catb.c +++ b/src/libstddjb/stralloc_catb.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/stralloc_catv.c b/src/libstddjb/stralloc_catv.c index a0c50aa..df1432e 100644 --- a/src/libstddjb/stralloc_catv.c +++ b/src/libstddjb/stralloc_catv.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/stralloc_copyb.c b/src/libstddjb/stralloc_copyb.c index 31fc31e..26c3a4c 100644 --- a/src/libstddjb/stralloc_copyb.c +++ b/src/libstddjb/stralloc_copyb.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include diff --git a/src/libstddjb/stralloc_insertb.c b/src/libstddjb/stralloc_insertb.c index f964ea5..1f0a99d 100644 --- a/src/libstddjb/stralloc_insertb.c +++ b/src/libstddjb/stralloc_insertb.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include diff --git a/src/libstddjb/stralloc_ready_tuned.c b/src/libstddjb/stralloc_ready_tuned.c index 53a47cd..d365d6e 100644 --- a/src/libstddjb/stralloc_ready_tuned.c +++ b/src/libstddjb/stralloc_ready_tuned.c @@ -1,13 +1,13 @@ /* ISC license. */ -#include +#include #include #include #include int stralloc_ready_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) { - register size_t t ; + size_t t ; if (!b) return (errno = EINVAL, 0) ; t = n + base + a * n / b ; if (t < n) return (errno = ERANGE, 0) ; diff --git a/src/libstddjb/stralloc_reverse.c b/src/libstddjb/stralloc_reverse.c index 46d22cb..38e22bb 100644 --- a/src/libstddjb/stralloc_reverse.c +++ b/src/libstddjb/stralloc_reverse.c @@ -1,11 +1,11 @@ /* ISC license. */ -#include +#include #include void stralloc_reverse (stralloc *sa) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < sa->len >> 1 ; i++) { char tmp = sa->s[i] ; diff --git a/src/libstddjb/stralloc_reverse_blocks.c b/src/libstddjb/stralloc_reverse_blocks.c index 67a18de..86b7fc4 100644 --- a/src/libstddjb/stralloc_reverse_blocks.c +++ b/src/libstddjb/stralloc_reverse_blocks.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include #include #include void stralloc_reverse_blocks (stralloc *sa, size_t size) { - register size_t n = sa->len / (size << 1) ; - register size_t i = 0 ; + size_t n = sa->len / (size << 1) ; + size_t i = 0 ; char tmp[size] ; for (; i < n ; i++) { diff --git a/src/libstddjb/strerr_sys.c b/src/libstddjb/strerr_sys.c index 46789d8..e388f5a 100644 --- a/src/libstddjb/strerr_sys.c +++ b/src/libstddjb/strerr_sys.c @@ -3,13 +3,13 @@ /* MT-unsafe */ #include +#include #include -#include #include void strerr_warnsys (char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10) { - strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, error_str(errno)) ; + strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, strerror(errno)) ; } void strerr_diesys (int e, char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10) diff --git a/src/libstddjb/string_format.c b/src/libstddjb/string_format.c index 73c2572..b4a1bfa 100644 --- a/src/libstddjb/string_format.c +++ b/src/libstddjb/string_format.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/string_quote.c b/src/libstddjb/string_quote.c index 37258c5..e648af4 100644 --- a/src/libstddjb/string_quote.c +++ b/src/libstddjb/string_quote.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include diff --git a/src/libstddjb/string_quote_nodelim.c b/src/libstddjb/string_quote_nodelim.c index 26b612f..a25a4e6 100644 --- a/src/libstddjb/string_quote_nodelim.c +++ b/src/libstddjb/string_quote_nodelim.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include #include diff --git a/src/libstddjb/string_quote_nodelim_mustquote.c b/src/libstddjb/string_quote_nodelim_mustquote.c index a978921..535628d 100644 --- a/src/libstddjb/string_quote_nodelim_mustquote.c +++ b/src/libstddjb/string_quote_nodelim_mustquote.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include +#include #include -#include #include #include #include diff --git a/src/libstddjb/string_unquote.c b/src/libstddjb/string_unquote.c index 4245014..d22f46d 100644 --- a/src/libstddjb/string_unquote.c +++ b/src/libstddjb/string_unquote.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/strn_fmt.c b/src/libstddjb/strn_fmt.c index 0c6ffb7..d8cf58f 100644 --- a/src/libstddjb/strn_fmt.c +++ b/src/libstddjb/strn_fmt.c @@ -4,9 +4,9 @@ #include #include -size_t strn_fmt (char *blah, register char const *s, size_t len) +size_t strn_fmt (char *blah, char const *s, size_t len) { - register char *d = blah ; + char *d = blah ; size_t i ; for (i = 0 ; i < len ; i++) if ((s[i] >= 32) && ((unsigned char)s[i] < 127)) *d++ = s[i] ; diff --git a/src/libstddjb/sysclock_from_localtm.c b/src/libstddjb/sysclock_from_localtm.c index 6408fc8..3bce55a 100644 --- a/src/libstddjb/sysclock_from_localtm.c +++ b/src/libstddjb/sysclock_from_localtm.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include #include #include #include -int sysclock_from_localtm (uint64 *uu, struct tm const *l) +int sysclock_from_localtm (uint64_t *uu, struct tm const *l) { - uint64 u ; + uint64_t u ; if (!ltm64_from_localtm(&u, l)) return 0 ; if (!sysclock_from_ltm64(&u)) return 0 ; *uu = u ; diff --git a/src/libstddjb/sysclock_from_ltm64.c b/src/libstddjb/sysclock_from_ltm64.c index a7e7a36..abdd31d 100644 --- a/src/libstddjb/sysclock_from_ltm64.c +++ b/src/libstddjb/sysclock_from_ltm64.c @@ -8,7 +8,7 @@ #include -int sysclock_from_ltm64 (uint64 *u) +int sysclock_from_ltm64 (uint64_t *u) { tai_t t ; if (!tai_from_ltm64(&t, *u)) return 0 ; @@ -18,7 +18,7 @@ int sysclock_from_ltm64 (uint64 *u) #else -int sysclock_from_ltm64 (uint64 *u) +int sysclock_from_ltm64 (uint64_t *u) { return utc_from_sysclock(u) ; } diff --git a/src/libstddjb/sysclock_from_tai.c b/src/libstddjb/sysclock_from_tai.c index 3814bf2..02e5e2a 100644 --- a/src/libstddjb/sysclock_from_tai.c +++ b/src/libstddjb/sysclock_from_tai.c @@ -2,11 +2,12 @@ #include #include +#include #include #ifdef SKALIBS_FLAG_CLOCKISTAI -int sysclock_from_tai (uint64 *u, tai_t const *t) +int sysclock_from_tai (uint64_t *u, tai_t const *t) { if (t->x < 10U) return (errno = EINVAL, 0) ; *u = t->x - 10U ; @@ -17,7 +18,7 @@ int sysclock_from_tai (uint64 *u, tai_t const *t) #include -int sysclock_from_tai (uint64 *u, tai_t const *t) +int sysclock_from_tai (uint64_t *u, tai_t const *t) { return utc_from_tai(u, t) ; } diff --git a/src/libstddjb/sysclock_from_utc.c b/src/libstddjb/sysclock_from_utc.c index 49228a7..3f862aa 100644 --- a/src/libstddjb/sysclock_from_utc.c +++ b/src/libstddjb/sysclock_from_utc.c @@ -9,7 +9,7 @@ #include -int sysclock_from_utc (uint64 *u) +int sysclock_from_utc (uint64_t *u) { tai_t t ; if (!tai_from_utc(&t, *u)) return 0 ; @@ -20,7 +20,7 @@ int sysclock_from_utc (uint64 *u) #else -int sysclock_from_utc (uint64 *u) +int sysclock_from_utc (uint64_t *u) { (void)u ; return 1 ; diff --git a/src/libstddjb/tai_from_localtm.c b/src/libstddjb/tai_from_localtm.c index 1f43070..b372bf5 100644 --- a/src/libstddjb/tai_from_localtm.c +++ b/src/libstddjb/tai_from_localtm.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include @@ -8,7 +7,7 @@ int tai_from_localtm (tai_t *t, struct tm const *l) { - uint64 u ; + uint64_t u ; if (!ltm64_from_localtm(&u, l)) return 0 ; return tai_from_ltm64(t, u) ; } diff --git a/src/libstddjb/tai_from_ltm64.c b/src/libstddjb/tai_from_ltm64.c index 0ecb49a..a2a4e4c 100644 --- a/src/libstddjb/tai_from_ltm64.c +++ b/src/libstddjb/tai_from_ltm64.c @@ -5,7 +5,7 @@ #include #include "djbtime-internal.h" -int tai_from_ltm64 (tai_t *t, uint64 u) +int tai_from_ltm64 (tai_t *t, uint64_t u) { switch (skalibs_tzisright()) { diff --git a/src/libstddjb/tai_from_sysclock.c b/src/libstddjb/tai_from_sysclock.c index 087f353..b813108 100644 --- a/src/libstddjb/tai_from_sysclock.c +++ b/src/libstddjb/tai_from_sysclock.c @@ -1,11 +1,12 @@ /* ISC license. */ #include +#include #include #ifdef SKALIBS_FLAG_CLOCKISTAI -int tai_from_sysclock (tai_t *t, uint64 u) +int tai_from_sysclock (tai_t *t, uint64_t u) { return tai_u64(t, u + 10U) ; } @@ -14,7 +15,7 @@ int tai_from_sysclock (tai_t *t, uint64 u) #include -int tai_from_sysclock (tai_t *t, uint64 u) +int tai_from_sysclock (tai_t *t, uint64_t u) { return tai_from_utc(t, u) ; } diff --git a/src/libstddjb/tai_from_utc.c b/src/libstddjb/tai_from_utc.c index 3f4d5ec..1b9762b 100644 --- a/src/libstddjb/tai_from_utc.c +++ b/src/libstddjb/tai_from_utc.c @@ -5,7 +5,7 @@ #include #include "djbtime-internal.h" -int tai_from_utc (tai_t *t, uint64 u) +int tai_from_utc (tai_t *t, uint64_t u) { leapsecs_add(&u, 0) ; return tai_u64(t, u + 10) ; diff --git a/src/libstddjb/tai_now.c b/src/libstddjb/tai_now.c index aaf388a..a9710d4 100644 --- a/src/libstddjb/tai_now.c +++ b/src/libstddjb/tai_now.c @@ -7,7 +7,7 @@ int tai_now (tai_t *t) { - register time_t u = time(0) ; + time_t u = time(0) ; if (u == (time_t)-1) return 0 ; return tai_from_time_sysclock(t, u) ; } diff --git a/src/libstddjb/tai_u64.c b/src/libstddjb/tai_u64.c index 9132ff3..624f2cb 100644 --- a/src/libstddjb/tai_u64.c +++ b/src/libstddjb/tai_u64.c @@ -9,9 +9,9 @@ #include #include -int tai_u64 (tai_t *t, uint64 u) +int tai_u64 (tai_t *t, uint64_t u) { - if (u & ((uint64)1 << 63)) return (errno = EOVERFLOW, 0) ; + if (u & ((uint64_t)1 << 63)) return (errno = EOVERFLOW, 0) ; t->x = u ; return 1 ; } diff --git a/src/libstddjb/tain_addsec.c b/src/libstddjb/tain_addsec.c index b0d19e2..cd22b18 100644 --- a/src/libstddjb/tain_addsec.c +++ b/src/libstddjb/tain_addsec.c @@ -7,12 +7,12 @@ int tain_addsec (tain_t *b, tain_t const *a, int c) { if (c >= 0) { - tai_t t = { .x = (uint64)c } ; + tai_t t = { .x = (uint64_t)c } ; tai_add(&b->sec, &a->sec, &t) ; } else { - tai_t t = { .x = (uint64)-c } ; + tai_t t = { .x = (uint64_t)-c } ; tai_sub(&b->sec, &a->sec, &t) ; } b->nano = a->nano ; diff --git a/src/libstddjb/tain_fmt.c b/src/libstddjb/tain_fmt.c index 1fa04e3..ce64832 100644 --- a/src/libstddjb/tain_fmt.c +++ b/src/libstddjb/tain_fmt.c @@ -1,9 +1,10 @@ /* ISC license. */ +#include #include #include -unsigned int tain_fmt (char *s, tain_t const *a) +size_t tain_fmt (char *s, tain_t const *a) { char pack[TAIN_PACK] ; tain_pack(pack, a) ; diff --git a/src/libstddjb/tain_from_ntp.c b/src/libstddjb/tain_from_ntp.c index 5314a38..68fa699 100644 --- a/src/libstddjb/tain_from_ntp.c +++ b/src/libstddjb/tain_from_ntp.c @@ -4,10 +4,10 @@ #include #include -int tain_from_ntp (tain_t *a, uint64 u) +int tain_from_ntp (tain_t *a, uint64_t u) { tai_t secs = { .x = u >> 32 } ; - if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64)1 << 32) ; + if (secs.x <= 0x7FFFFFFFUL) secs.x |= ((uint64_t)1 << 32) ; secs.x += TAI_MAGIC ; secs.x -= NTP_OFFSET ; if (!tai_from_utc(&secs, secs.x)) return 0 ; diff --git a/src/libstddjb/tain_scan.c b/src/libstddjb/tain_scan.c index 84a0cab..6ab181d 100644 --- a/src/libstddjb/tain_scan.c +++ b/src/libstddjb/tain_scan.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include #include #include -unsigned int tain_scan (char const *s, tain_t *a) +size_t tain_scan (char const *s, tain_t *a) { char pack[TAIN_PACK] ; - register unsigned int r = ucharn_scan(s, pack, TAIN_PACK) ; + size_t r = ucharn_scan(s, pack, TAIN_PACK) ; if (r) tain_unpack(pack, a) ; return r ; } diff --git a/src/libstddjb/tain_to_millisecs.c b/src/libstddjb/tain_to_millisecs.c index 0fa9395..0854c49 100644 --- a/src/libstddjb/tain_to_millisecs.c +++ b/src/libstddjb/tain_to_millisecs.c @@ -5,7 +5,7 @@ int tain_to_millisecs (tain_t const *a) { - if (a->sec.x > (uint64)2147483) return -1 ; - if ((a->sec.x == (uint64)2147483) && (a->nano > 646000000U)) return -1 ; + if (a->sec.x > (uint64_t)2147483) return -1 ; + if ((a->sec.x == (uint64_t)2147483) && (a->nano > 646000000U)) return -1 ; return a->sec.x * 1000 + (a->nano + 999999) / 1000000U ; } diff --git a/src/libstddjb/time_from_tai.c b/src/libstddjb/time_from_tai.c index cdf1357..406fcfb 100644 --- a/src/libstddjb/time_from_tai.c +++ b/src/libstddjb/time_from_tai.c @@ -5,14 +5,15 @@ #define _BSD_SOURCE #endif -#include -#include #include +#include +#include +#include #include int time_from_tai (time_t *u, tai_t const *t) { - register uint64 uu = t->x - TAI_MAGIC ; + register uint64_t uu = t->x - TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 if ((uu >> 32) && (uu >> 32) != 0xffffffffUL) return (errno = EOVERFLOW, 0) ; diff --git a/src/libstddjb/time_from_tai_relative.c b/src/libstddjb/time_from_tai_relative.c index 52e8c2a..1d11e2e 100644 --- a/src/libstddjb/time_from_tai_relative.c +++ b/src/libstddjb/time_from_tai_relative.c @@ -5,9 +5,9 @@ #define _BSD_SOURCE #endif -#include -#include #include +#include +#include #include int time_from_tai_relative (time_t *u, tai_t const *t) diff --git a/src/libstddjb/time_sysclock_from_tai.c b/src/libstddjb/time_sysclock_from_tai.c index 4faa70a..3e8322b 100644 --- a/src/libstddjb/time_sysclock_from_tai.c +++ b/src/libstddjb/time_sysclock_from_tai.c @@ -5,15 +5,15 @@ #define _BSD_SOURCE #endif -#include -#include #include +#include +#include #include #include int time_sysclock_from_tai (time_t *u, tai_t const *t) { - uint64 uu ; + uint64_t uu ; if (!sysclock_from_tai(&uu, t)) return 0 ; uu -= TAI_MAGIC ; #if SKALIBS_SIZEOFTIME < 8 diff --git a/src/libstddjb/timestamp_fmt.c b/src/libstddjb/timestamp_fmt.c index 1956723..816e523 100644 --- a/src/libstddjb/timestamp_fmt.c +++ b/src/libstddjb/timestamp_fmt.c @@ -1,8 +1,9 @@ /* ISC license. */ +#include #include -unsigned int timestamp_fmt (char *s, tain_t const *a) +size_t timestamp_fmt (char *s, tain_t const *a) { *s = '@' ; return 1 + tain_fmt(s+1, a) ; diff --git a/src/libstddjb/timestamp_scan.c b/src/libstddjb/timestamp_scan.c index 1d48612..95671ee 100644 --- a/src/libstddjb/timestamp_scan.c +++ b/src/libstddjb/timestamp_scan.c @@ -1,10 +1,11 @@ /* ISC license. */ +#include #include -unsigned int timestamp_scan (char const *s, tain_t *a) +size_t timestamp_scan (char const *s, tain_t *a) { - register unsigned int r ; + size_t r ; if (*s != '@') return 0 ; r = tain_scan(s+1, a) ; return r ? r+1 : 0 ; diff --git a/src/libstddjb/ucharn_findlen.c b/src/libstddjb/ucharn_findlen.c index 59b5577..b770035 100644 --- a/src/libstddjb/ucharn_findlen.c +++ b/src/libstddjb/ucharn_findlen.c @@ -5,7 +5,7 @@ size_t ucharn_findlen (char const *s) { - register size_t i = 0 ; + size_t i = 0 ; while (fmtscan_num(s[i], 16) <= 0xF) i++ ; return i ; } diff --git a/src/libstddjb/ucharn_fmt.c b/src/libstddjb/ucharn_fmt.c index 5eec54f..cf2b2af 100644 --- a/src/libstddjb/ucharn_fmt.c +++ b/src/libstddjb/ucharn_fmt.c @@ -5,7 +5,7 @@ size_t ucharn_fmt (char *s, char const *key, size_t n) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] >> 4) ; diff --git a/src/libstddjb/ucharn_fmt_little.c b/src/libstddjb/ucharn_fmt_little.c index d033096..3848082 100644 --- a/src/libstddjb/ucharn_fmt_little.c +++ b/src/libstddjb/ucharn_fmt_little.c @@ -5,7 +5,7 @@ size_t ucharn_fmt_little (char *s, char const *key, size_t n) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] & 0xF) ; diff --git a/src/libstddjb/ucharn_scan.c b/src/libstddjb/ucharn_scan.c index b544d0d..6a9b1fd 100644 --- a/src/libstddjb/ucharn_scan.c +++ b/src/libstddjb/ucharn_scan.c @@ -5,7 +5,7 @@ size_t ucharn_scan (char const *s, char *key, size_t n) { - register unsigned int i = 0 ; + size_t i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[2*i], 16) ; diff --git a/src/libstddjb/ucharn_scan_little.c b/src/libstddjb/ucharn_scan_little.c index b278dff..52fdd62 100644 --- a/src/libstddjb/ucharn_scan_little.c +++ b/src/libstddjb/ucharn_scan_little.c @@ -5,7 +5,7 @@ size_t ucharn_scan_little (char const *s, char *key, size_t n) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ; diff --git a/src/libstddjb/ucspi_get.c b/src/libstddjb/ucspi_get.c index 916ae2a..b4572d1 100644 --- a/src/libstddjb/ucspi_get.c +++ b/src/libstddjb/ucspi_get.c @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include #include char const *ucspi_get (char const *s) @@ -9,11 +9,11 @@ char const *ucspi_get (char const *s) char const *x = env_get("PROTO") ; if (x) { - unsigned int len = str_len(s) ; - unsigned int xlen = str_len(x) ; + size_t len = strlen(s) ; + size_t xlen = strlen(x) ; char tmp[len + xlen + 1] ; - byte_copy(tmp, xlen, x) ; - byte_copy(tmp + xlen, len + 1, s) ; + memcpy(tmp, x, xlen) ; + memcpy(tmp + xlen, s, len + 1) ; x = env_get(tmp) ; if (!x) errno = ENOENT ; } diff --git a/src/libstddjb/unsanitize_read.c b/src/libstddjb/unsanitize_read.c index 4d9e99d..d21cacd 100644 --- a/src/libstddjb/unsanitize_read.c +++ b/src/libstddjb/unsanitize_read.c @@ -2,8 +2,8 @@ #include #include -#include #include +#include ssize_t unsanitize_read (ssize_t r) { diff --git a/src/libstddjb/utc_from_localtm.c b/src/libstddjb/utc_from_localtm.c index a5886f3..99b4470 100644 --- a/src/libstddjb/utc_from_localtm.c +++ b/src/libstddjb/utc_from_localtm.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include #include #include #include -int utc_from_localtm (uint64 *uu, struct tm const *l) +int utc_from_localtm (uint64_t *uu, struct tm const *l) { if (!ltm64_from_localtm(uu, l)) return 0 ; utc_from_ltm64(uu) ; diff --git a/src/libstddjb/utc_from_ltm64.c b/src/libstddjb/utc_from_ltm64.c index 788a539..ab2d153 100644 --- a/src/libstddjb/utc_from_ltm64.c +++ b/src/libstddjb/utc_from_ltm64.c @@ -5,8 +5,7 @@ #include #include "djbtime-internal.h" - -int utc_from_ltm64 (uint64 *u) +int utc_from_ltm64 (uint64_t *u) { #ifdef SKALIBS_FLAG_CLOCKISTAI leapsecs_sub(u) ; diff --git a/src/libstddjb/utc_from_sysclock.c b/src/libstddjb/utc_from_sysclock.c index 979bb04..7310a10 100644 --- a/src/libstddjb/utc_from_sysclock.c +++ b/src/libstddjb/utc_from_sysclock.c @@ -8,7 +8,7 @@ #include -int utc_from_sysclock (uint64 *u) +int utc_from_sysclock (uint64_t *u) { tai_t t = { .x = *u + 10U } ; return utc_from_tai(u, &t) ; @@ -16,7 +16,7 @@ int utc_from_sysclock (uint64 *u) #else -int utc_from_sysclock (uint64 *u) +int utc_from_sysclock (uint64_t *u) { (void)u ; return 1 ; diff --git a/src/libstddjb/vbaprintf.c b/src/libstddjb/vbaprintf.c index 1c23e8c..38bd331 100644 --- a/src/libstddjb/vbaprintf.c +++ b/src/libstddjb/vbaprintf.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include -#include #include +#include #include #include #include @@ -17,8 +16,8 @@ int vbaprintf (bufalloc *ba, char const *format, va_list args) va_end(ugly) ; } if (r < 0) return r ; - if (!stralloc_readyplus(&ba->x, (size_t)r + 1)) return -1 ; - r = vsnprintf(ba->x.s + ba->x.len, (size_t)r + 1, format, args) ; + if (!stralloc_readyplus(&ba->x, r + 1)) return -1 ; + r = vsnprintf(ba->x.s + ba->x.len, r + 1, format, args) ; if (r > 0) ba->x.len += r ; return r ; } diff --git a/src/libstddjb/vbprintf.c b/src/libstddjb/vbprintf.c index 2f8c13b..52dfb9b 100644 --- a/src/libstddjb/vbprintf.c +++ b/src/libstddjb/vbprintf.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include -#include #include +#include #include #include @@ -17,8 +16,8 @@ int vbprintf (buffer *b, char const *format, va_list args) } if (r < 0) return r ; { - char buf[(size_t)r + 1] ; - r = vsnprintf(buf, (size_t)r + 1, format, args) ; + char buf[r+1] ; + r = vsnprintf(buf, r + 1, format, args) ; if (r < 0) return r ; if (buffer_put(b, buf, r) < r) return -1 ; } diff --git a/src/libstddjb/wait_nointr.c b/src/libstddjb/wait_nointr.c index 90d6412..4e7a17a 100644 --- a/src/libstddjb/wait_nointr.c +++ b/src/libstddjb/wait_nointr.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include #include #include #include diff --git a/src/libstddjb/wait_pid_nohang.c b/src/libstddjb/wait_pid_nohang.c index 11beed6..7b27bbe 100644 --- a/src/libstddjb/wait_pid_nohang.c +++ b/src/libstddjb/wait_pid_nohang.c @@ -1,16 +1,16 @@ /* ISC license. */ -#include +#include #include pid_t wait_pid_nohang (pid_t pid, int *wstat) { int w = 0 ; - register pid_t r = 0 ; + pid_t r = 0 ; while (r != pid) { r = wait_nohang(&w) ; - if (!r || (r == (pid_t)-1)) return (int)r ; + if (!r || (r == (pid_t)-1)) return r ; } *wstat = w ; return r ; diff --git a/src/libstddjb/wait_pids_nohang.c b/src/libstddjb/wait_pids_nohang.c index 3c52e6b..c13ddec 100644 --- a/src/libstddjb/wait_pids_nohang.c +++ b/src/libstddjb/wait_pids_nohang.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat) @@ -8,10 +8,10 @@ int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat) for (;;) { int w ; - register pid_t r = wait_nohang(&w) ; + pid_t r = wait_nohang(&w) ; if (!r || (r == (pid_t)-1)) return (int)r ; { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < len ; i++) if (r == pids[i]) break ; if (i < len) { diff --git a/src/libstddjb/wait_reap.c b/src/libstddjb/wait_reap.c index 7049b27..051b11e 100644 --- a/src/libstddjb/wait_reap.c +++ b/src/libstddjb/wait_reap.c @@ -4,7 +4,7 @@ unsigned int wait_reap () { - register unsigned int n = 0 ; + unsigned int n = 0 ; int wstat ; while (wait_nohang(&wstat) > 0) n++ ; return n ; diff --git a/src/libstddjb/waitn.c b/src/libstddjb/waitn.c index 0d01cd1..05d7f37 100644 --- a/src/libstddjb/waitn.c +++ b/src/libstddjb/waitn.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include int waitn (pid_t *pids, unsigned int n) @@ -8,8 +8,8 @@ int waitn (pid_t *pids, unsigned int n) while (n) { int wstat ; - register unsigned int i = 0 ; - register pid_t pid = wait_nointr(&wstat) ; + unsigned int i = 0 ; + pid_t pid = wait_nointr(&wstat) ; if (pid < 0) return 0 ; for (; i < n ; i++) if (pid == pids[i]) break ; if (i < n) pids[i] = pids[--n] ; diff --git a/src/libstddjb/waitn_reap.c b/src/libstddjb/waitn_reap.c index 96a0c61..9f26b5d 100644 --- a/src/libstddjb/waitn_reap.c +++ b/src/libstddjb/waitn_reap.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include +#include #include int waitn_reap (pid_t *pids, unsigned int len) @@ -9,11 +9,11 @@ int waitn_reap (pid_t *pids, unsigned int len) while (len) { int w ; - register int r = wait_pids_nohang(pids, len, &w) ; + int r = wait_pids_nohang(pids, len, &w) ; if (r < 0) return r ; else if (!r) break ; pids[r-1] = pids[--len] ; n++ ; } - return (int)n ; + return n ; } diff --git a/src/libstddjb/waitpid_nointr.c b/src/libstddjb/waitpid_nointr.c index 8c6a65e..838359f 100644 --- a/src/libstddjb/waitpid_nointr.c +++ b/src/libstddjb/waitpid_nointr.c @@ -1,15 +1,13 @@ /* ISC license. */ -#include #include #include #include pid_t waitpid_nointr (pid_t pid, int *wstat, int flags) { - register pid_t r ; - do - r = waitpid(pid, wstat, flags) ; + pid_t r ; + do r = waitpid(pid, wstat, flags) ; while ((r == (pid_t)-1) && (errno == EINTR)) ; return r ; } -- cgit 1.4.1