diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-10-13 19:44:36 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-10-13 19:44:36 +0000 |
| commit | becbad1f6e18fec7c3bf286778a766ffca4457be (patch) | |
| tree | e5218cae2f48913719be46210d8d92085cb2511f /lib/libc | |
| parent | 23a32822d2a98273412f5b7d5e4b0ea925d637a0 (diff) | |
| parent | b0c041f88747fad7ef1680da932748352efbf77e (diff) | |
Notes
Diffstat (limited to 'lib/libc')
281 files changed, 1555 insertions, 2054 deletions
diff --git a/lib/libc/Makefile.depend b/lib/libc/Makefile.depend index 05b44c8aa6228..02168e8f06d13 100644 --- a/lib/libc/Makefile.depend +++ b/lib/libc/Makefile.depend @@ -126,6 +126,9 @@ jemalloc_mb.po: jemalloc_mb.c jemalloc_mutex.So: jemalloc_mutex.c jemalloc_mutex.o: jemalloc_mutex.c jemalloc_mutex.po: jemalloc_mutex.c +jemalloc_pages.So: jemalloc_pages.c +jemalloc_pages.o: jemalloc_pages.c +jemalloc_pages.po: jemalloc_pages.c jemalloc_prof.So: jemalloc_prof.c jemalloc_prof.o: jemalloc_prof.c jemalloc_prof.po: jemalloc_prof.c diff --git a/lib/libc/aarch64/gen/_set_tp.c b/lib/libc/aarch64/gen/_set_tp.c index a587b2ed7e6be..871acb3001a35 100644 --- a/lib/libc/aarch64/gen/_set_tp.c +++ b/lib/libc/aarch64/gen/_set_tp.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <machine/sysarch.h> #include <stdlib.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/amd64/gen/_set_tp.c b/lib/libc/amd64/gen/_set_tp.c index 02e5e14603025..d5526fa51c018 100644 --- a/lib/libc/amd64/gen/_set_tp.c +++ b/lib/libc/amd64/gen/_set_tp.c @@ -29,6 +29,7 @@ #include <string.h> #include <stdint.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S index c26f52f5b70bc..826220e8bb55f 100644 --- a/lib/libc/amd64/gen/setjmp.S +++ b/lib/libc/amd64/gen/setjmp.S @@ -55,7 +55,7 @@ ENTRY(setjmp) movq $0,%rsi /* (sigset_t*)set */ leaq 72(%rcx),%rdx /* 9,10; (sigset_t*)oset */ /* stack is 16-byte aligned */ - call PIC_PLT(CNAME(_sigprocmask)) + call __libc_sigprocmask popq %rdi movq %rdi,%rcx movq 0(%rsp),%rdx /* retval */ @@ -82,7 +82,7 @@ ENTRY(__longjmp) leaq 72(%rdx),%rsi /* (sigset_t*)set */ movq $0,%rdx /* (sigset_t*)oset */ subq $0x8,%rsp /* make the stack 16-byte aligned */ - call PIC_PLT(CNAME(_sigprocmask)) + call __libc_sigprocmask addq $0x8,%rsp popq %rsi popq %rdi /* jmpbuf */ diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S index 9a205567c3b74..1e8e77cbde3b1 100644 --- a/lib/libc/amd64/gen/sigsetjmp.S +++ b/lib/libc/amd64/gen/sigsetjmp.S @@ -63,7 +63,7 @@ ENTRY(sigsetjmp) movq $0,%rsi /* (sigset_t*)set */ leaq 72(%rcx),%rdx /* 9,10 (sigset_t*)oset */ /* stack is 16-byte aligned */ - call PIC_PLT(CNAME(_sigprocmask)) + call __libc_sigprocmask popq %rdi 2: movq %rdi,%rcx movq 0(%rsp),%rdx /* retval */ @@ -91,7 +91,7 @@ ENTRY(__siglongjmp) leaq 72(%rdx),%rsi /* (sigset_t*)set */ movq $0,%rdx /* (sigset_t*)oset */ subq $0x8,%rsp /* make the stack 16-byte aligned */ - call PIC_PLT(CNAME(_sigprocmask)) + call __libc_sigprocmask addq $0x8,%rsp popq %rsi popq %rdi /* jmpbuf */ diff --git a/lib/libc/arm/aeabi/aeabi_asm_double.S b/lib/libc/arm/aeabi/aeabi_asm_double.S index 7a5af82a642d2..ced4d78b6cbf9 100644 --- a/lib/libc/arm/aeabi/aeabi_asm_double.S +++ b/lib/libc/arm/aeabi/aeabi_asm_double.S @@ -117,3 +117,5 @@ ENTRY(__aeabi_cdcmpeq) msr cpsr_c, ip RET END(__aeabi_cdcmpeq) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/aeabi/aeabi_asm_float.S b/lib/libc/arm/aeabi/aeabi_asm_float.S index e05daa5c05bef..de6b1c88f4f28 100644 --- a/lib/libc/arm/aeabi/aeabi_asm_float.S +++ b/lib/libc/arm/aeabi/aeabi_asm_float.S @@ -108,3 +108,5 @@ ENTRY(__aeabi_cfcmpeq) msr cpsr_c, ip RET END(__aeabi_cfcmpeq) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/aeabi/aeabi_vfp_double.S b/lib/libc/arm/aeabi/aeabi_vfp_double.S index aae49f85b9405..be4309dd6efcd 100644 --- a/lib/libc/arm/aeabi/aeabi_vfp_double.S +++ b/lib/libc/arm/aeabi/aeabi_vfp_double.S @@ -201,3 +201,4 @@ AEABI_ENTRY(dsub) RET AEABI_END(dsub) + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/aeabi/aeabi_vfp_float.S b/lib/libc/arm/aeabi/aeabi_vfp_float.S index 7de8daf4f32b0..c9df41cf4b2ec 100644 --- a/lib/libc/arm/aeabi/aeabi_vfp_float.S +++ b/lib/libc/arm/aeabi/aeabi_vfp_float.S @@ -188,3 +188,4 @@ AEABI_ENTRY(fsub) RET AEABI_END(fsub) + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/__aeabi_read_tp.S b/lib/libc/arm/gen/__aeabi_read_tp.S index 670d0b835f60e..224d6a632185e 100644 --- a/lib/libc/arm/gen/__aeabi_read_tp.S +++ b/lib/libc/arm/gen/__aeabi_read_tp.S @@ -45,3 +45,4 @@ END(__aeabi_read_tp) .word ARM_TP_ADDRESS #endif + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/_ctx_start.S b/lib/libc/arm/gen/_ctx_start.S index 41bfff9c65ec9..faedfb5c6443c 100644 --- a/lib/libc/arm/gen/_ctx_start.S +++ b/lib/libc/arm/gen/_ctx_start.S @@ -8,3 +8,5 @@ ENTRY(_ctx_start) bl _C_LABEL(ctx_done) bl _C_LABEL(abort) END(_ctx_start) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/_set_tp.c b/lib/libc/arm/gen/_set_tp.c index 97cabec8674f9..2332f599a9191 100644 --- a/lib/libc/arm/gen/_set_tp.c +++ b/lib/libc/arm/gen/_set_tp.c @@ -30,6 +30,7 @@ #include <sys/types.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S index 853f61cb45256..e3c67fa7b9bb4 100644 --- a/lib/libc/arm/gen/_setjmp.S +++ b/lib/libc/arm/gen/_setjmp.S @@ -157,3 +157,5 @@ botch: b . #endif END(_longjmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/alloca.S b/lib/libc/arm/gen/alloca.S index e4a73d45f2adc..2539b7a80c976 100644 --- a/lib/libc/arm/gen/alloca.S +++ b/lib/libc/arm/gen/alloca.S @@ -44,3 +44,5 @@ ENTRY(alloca) mov r0, sp /* r0 = base of new space */ RET END(alloca) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/divsi3.S b/lib/libc/arm/gen/divsi3.S index 82de5de257eef..fac0663cdb2ad 100644 --- a/lib/libc/arm/gen/divsi3.S +++ b/lib/libc/arm/gen/divsi3.S @@ -389,3 +389,5 @@ ENTRY(__divsi3) mov r0, r3 RET END(__divsi3) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S index c9ae3294f53b2..4e3850d136c23 100644 --- a/lib/libc/arm/gen/setjmp.S +++ b/lib/libc/arm/gen/setjmp.S @@ -158,3 +158,5 @@ ENTRY(__longjmp) bl PIC_SYM(_C_LABEL(abort), PLT) 1: b 1b /* Cannot get here */ END(__longjmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/gen/sigsetjmp.S b/lib/libc/arm/gen/sigsetjmp.S index 3743e8934738f..236f5310a7f3b 100644 --- a/lib/libc/arm/gen/sigsetjmp.S +++ b/lib/libc/arm/gen/sigsetjmp.S @@ -66,3 +66,5 @@ ENTRY(siglongjmp) beq PIC_SYM(_C_LABEL(_longjmp), PLT) b PIC_SYM(_C_LABEL(longjmp), PLT) END(siglongjmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/ffs.S b/lib/libc/arm/string/ffs.S index cc7f396a61dd3..0ed8152447552 100644 --- a/lib/libc/arm/string/ffs.S +++ b/lib/libc/arm/string/ffs.S @@ -84,3 +84,5 @@ ENTRY(ffs) RET #endif END(ffs) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/memcmp.S b/lib/libc/arm/string/memcmp.S index 6fd8130f79b08..33a11b7c4c497 100644 --- a/lib/libc/arm/string/memcmp.S +++ b/lib/libc/arm/string/memcmp.S @@ -181,3 +181,5 @@ ENTRY(memcmp) RET #endif END(memcmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/memcpy_arm.S b/lib/libc/arm/string/memcpy_arm.S index 56fb70314d116..57b0449e50995 100644 --- a/lib/libc/arm/string/memcpy_arm.S +++ b/lib/libc/arm/string/memcpy_arm.S @@ -334,3 +334,5 @@ ENTRY(memcpy) sub r1, r1, #1 b .Lmemcpy_l4 END(memcpy) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/memcpy_xscale.S b/lib/libc/arm/string/memcpy_xscale.S index a451de46bc443..ab01544fc176c 100644 --- a/lib/libc/arm/string/memcpy_xscale.S +++ b/lib/libc/arm/string/memcpy_xscale.S @@ -1784,3 +1784,5 @@ ENTRY(memcpy) bx lr #endif /* !_STANDALONE */ END(memcpy) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/memmove.S b/lib/libc/arm/string/memmove.S index 2cd5a5e2dbebd..8f961470076cf 100644 --- a/lib/libc/arm/string/memmove.S +++ b/lib/libc/arm/string/memmove.S @@ -609,3 +609,5 @@ END(memmove) #else END(bcopy) #endif + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/memset.S b/lib/libc/arm/string/memset.S index 6d7690182f3a2..96d2f93183c49 100644 --- a/lib/libc/arm/string/memset.S +++ b/lib/libc/arm/string/memset.S @@ -263,3 +263,5 @@ END(bzero) #else END(memset) #endif + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/strcmp.S b/lib/libc/arm/string/strcmp.S index d610fea1f2984..1cdce8bcbab9d 100644 --- a/lib/libc/arm/string/strcmp.S +++ b/lib/libc/arm/string/strcmp.S @@ -43,3 +43,5 @@ ENTRY(strcmp) sub r0, r2, r3 RET END(strcmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/strlen.S b/lib/libc/arm/string/strlen.S index c9334f9c08cef..240fa7d9e85fe 100644 --- a/lib/libc/arm/string/strlen.S +++ b/lib/libc/arm/string/strlen.S @@ -83,3 +83,5 @@ ENTRY(strlen) mov r0, r1 RET END(strlen) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/string/strncmp.S b/lib/libc/arm/string/strncmp.S index a5c0320ee3963..affcaa0537b27 100644 --- a/lib/libc/arm/string/strncmp.S +++ b/lib/libc/arm/string/strncmp.S @@ -56,3 +56,5 @@ ENTRY(strncmp) sub r0, r2, r3 RET END(strncmp) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/Ovfork.S b/lib/libc/arm/sys/Ovfork.S index 4520e02b40291..73c619e3609d2 100644 --- a/lib/libc/arm/sys/Ovfork.S +++ b/lib/libc/arm/sys/Ovfork.S @@ -53,3 +53,5 @@ ENTRY(vfork) and r0, r0, r1 /* r0 == 0 if child, else unchanged */ mov r15, r2 END(vfork) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/brk.S b/lib/libc/arm/sys/brk.S index e5f833637d095..bf1b4fb61d7ba 100644 --- a/lib/libc/arm/sys/brk.S +++ b/lib/libc/arm/sys/brk.S @@ -91,3 +91,5 @@ ENTRY(_brk) .Lcurbrk: .word PIC_SYM(CURBRK, GOT) END(_brk) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/cerror.S b/lib/libc/arm/sys/cerror.S index 26f52113f9754..5fad698caf116 100644 --- a/lib/libc/arm/sys/cerror.S +++ b/lib/libc/arm/sys/cerror.S @@ -47,3 +47,5 @@ ASENTRY(CERROR) mvn r1, #0x00000000 ldmfd sp!, {r4, pc} END(CERROR) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/pipe.S b/lib/libc/arm/sys/pipe.S index 77ce0fcca13b3..778e923143763 100644 --- a/lib/libc/arm/sys/pipe.S +++ b/lib/libc/arm/sys/pipe.S @@ -49,3 +49,5 @@ ENTRY(_pipe) mov r0, #0x00000000 RET END(_pipe) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/ptrace.S b/lib/libc/arm/sys/ptrace.S index 876da32caf871..dade22374d5e4 100644 --- a/lib/libc/arm/sys/ptrace.S +++ b/lib/libc/arm/sys/ptrace.S @@ -47,3 +47,5 @@ ENTRY(ptrace) bcs PIC_SYM(CERROR, PLT) RET END(ptrace) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/sbrk.S b/lib/libc/arm/sys/sbrk.S index 5cd9a03e3a805..25622c4a809ba 100644 --- a/lib/libc/arm/sys/sbrk.S +++ b/lib/libc/arm/sys/sbrk.S @@ -78,3 +78,5 @@ ENTRY(_sbrk) .Lcurbrk: .word PIC_SYM(CURBRK, GOT) END(_sbrk) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/shmat.S b/lib/libc/arm/sys/shmat.S index 3fc3d02c6e47c..3574b1d4f4e4b 100644 --- a/lib/libc/arm/sys/shmat.S +++ b/lib/libc/arm/sys/shmat.S @@ -5,3 +5,5 @@ __FBSDID("$FreeBSD$"); #include "SYS.h" RSYSCALL(shmat) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/sigreturn.S b/lib/libc/arm/sys/sigreturn.S index 1e0f245a5efce..c377e4a296e44 100644 --- a/lib/libc/arm/sys/sigreturn.S +++ b/lib/libc/arm/sys/sigreturn.S @@ -40,3 +40,5 @@ __FBSDID("$FreeBSD$"); */ RSYSCALL(sigreturn) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/arm/sys/syscall.S b/lib/libc/arm/sys/syscall.S index 73e6b83181828..c88d1aeb4b653 100644 --- a/lib/libc/arm/sys/syscall.S +++ b/lib/libc/arm/sys/syscall.S @@ -36,3 +36,5 @@ __FBSDID("$FreeBSD$"); #include "SYS.h" RSYSCALL(syscall) + + .section .note.GNU-stack,"",%progbits diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index 45454824ba6b9..983ff928bc0bb 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); __weak_reference(__creat, creat); __weak_reference(__creat, _creat); +int __creat(const char *path, mode_t mode); + #pragma weak creat int __creat(const char *path, mode_t mode) diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c index 199846fd272a5..08484765397f5 100644 --- a/lib/libc/compat-43/sigcompat.c +++ b/lib/libc/compat-43/sigcompat.c @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" int -sigvec(signo, sv, osv) - int signo; - struct sigvec *sv, *osv; +sigvec(int signo, struct sigvec *sv, struct sigvec *osv) { struct sigaction sa, osa; struct sigaction *sap, *osap; @@ -59,7 +57,7 @@ sigvec(signo, sv, osv) } else sap = NULL; osap = osv != NULL ? &osa : NULL; - ret = _sigaction(signo, sap, osap); + ret = __libc_sigaction(signo, sap, osap); if (ret == 0 && osv != NULL) { osv->sv_handler = osa.sa_handler; osv->sv_flags = osa.sa_flags ^ SV_INTERRUPT; @@ -69,30 +67,28 @@ sigvec(signo, sv, osv) } int -sigsetmask(mask) - int mask; +sigsetmask(int mask) { sigset_t set, oset; int n; sigemptyset(&set); set.__bits[0] = mask; - n = _sigprocmask(SIG_SETMASK, &set, &oset); + n = __libc_sigprocmask(SIG_SETMASK, &set, &oset); if (n) return (n); return (oset.__bits[0]); } int -sigblock(mask) - int mask; +sigblock(int mask) { sigset_t set, oset; int n; sigemptyset(&set); set.__bits[0] = mask; - n = _sigprocmask(SIG_BLOCK, &set, &oset); + n = __libc_sigprocmask(SIG_BLOCK, &set, &oset); if (n) return (n); return (oset.__bits[0]); @@ -105,7 +101,7 @@ sigpause(int mask) sigemptyset(&set); set.__bits[0] = mask; - return (_sigsuspend(&set)); + return (__libc_sigsuspend(&set)); } int @@ -113,11 +109,11 @@ xsi_sigpause(int sig) { sigset_t set; - if (_sigprocmask(SIG_BLOCK, NULL, &set) == -1) + if (__libc_sigprocmask(SIG_BLOCK, NULL, &set) == -1) return (-1); if (sigdelset(&set, sig) == -1) return (-1); - return (_sigsuspend(&set)); + return (__libc_sigsuspend(&set)); } int @@ -128,7 +124,7 @@ sighold(int sig) sigemptyset(&set); if (sigaddset(&set, sig) == -1) return (-1); - return (_sigprocmask(SIG_BLOCK, &set, NULL)); + return (__libc_sigprocmask(SIG_BLOCK, &set, NULL)); } int @@ -138,7 +134,7 @@ sigignore(int sig) bzero(&sa, sizeof(sa)); sa.sa_handler = SIG_IGN; - return (_sigaction(sig, &sa, NULL)); + return (__libc_sigaction(sig, &sa, NULL)); } int @@ -149,7 +145,7 @@ sigrelse(int sig) sigemptyset(&set); if (sigaddset(&set, sig) == -1) return (-1); - return (_sigprocmask(SIG_UNBLOCK, &set, NULL)); + return (__libc_sigprocmask(SIG_UNBLOCK, &set, NULL)); } void @@ -161,26 +157,26 @@ void sigemptyset(&set); if (sigaddset(&set, sig) == -1) return (SIG_ERR); - if (_sigprocmask(SIG_BLOCK, NULL, &pset) == -1) + if (__libc_sigprocmask(SIG_BLOCK, NULL, &pset) == -1) return (SIG_ERR); if ((__sighandler_t *)disp == SIG_HOLD) { - if (_sigprocmask(SIG_BLOCK, &set, &pset) == -1) + if (__libc_sigprocmask(SIG_BLOCK, &set, &pset) == -1) return (SIG_ERR); if (sigismember(&pset, sig)) return (SIG_HOLD); else { - if (_sigaction(sig, NULL, &psa) == -1) + if (__libc_sigaction(sig, NULL, &psa) == -1) return (SIG_ERR); return (psa.sa_handler); } } else { - if (_sigprocmask(SIG_UNBLOCK, &set, &pset) == -1) + if (__libc_sigprocmask(SIG_UNBLOCK, &set, &pset) == -1) return (SIG_ERR); } bzero(&sa, sizeof(sa)); sa.sa_handler = disp; - if (_sigaction(sig, &sa, &psa) == -1) + if (__libc_sigaction(sig, &sa, &psa) == -1) return (SIG_ERR); if (sigismember(&pset, sig)) return (SIG_HOLD); diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index 94ba014ed3af7..051fc28e93f6b 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" #include <db.h> #include "btree.h" @@ -401,10 +402,10 @@ tmp(void) } (void)sigfillset(&set); - (void)_sigprocmask(SIG_BLOCK, &set, &oset); + (void)__libc_sigprocmask(SIG_BLOCK, &set, &oset); if ((fd = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); - (void)_sigprocmask(SIG_SETMASK, &oset, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); } diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index d319d988c165d..8040419f728ed 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #endif #include "un-namespace.h" +#include "libc_private.h" #include <db.h> #include "hash.h" @@ -861,10 +862,10 @@ open_temp(HTAB *hashp) /* Block signals; make sure file goes away at process exit. */ (void)sigfillset(&set); - (void)_sigprocmask(SIG_BLOCK, &set, &oset); + (void)__libc_sigprocmask(SIG_BLOCK, &set, &oset); if ((hashp->fp = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); - (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); } diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index 42ffb1b50ab7b..37adaf62d51bb 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -56,9 +56,7 @@ __FBSDID("$FreeBSD$"); * NULL on failure */ extern DBM * -dbm_open(file, flags, mode) - const char *file; - int flags, mode; +dbm_open(const char *file, int flags, int mode) { HASHINFO info; char path[MAXPATHLEN]; @@ -80,8 +78,7 @@ dbm_open(file, flags, mode) } extern void -dbm_close(db) - DBM *db; +dbm_close(DBM *db) { (void)(db->close)(db); } @@ -92,9 +89,7 @@ dbm_close(db) * NULL on failure */ extern datum -dbm_fetch(db, key) - DBM *db; - datum key; +dbm_fetch(DBM *db, datum key) { datum retdata; int status; @@ -118,8 +113,7 @@ dbm_fetch(db, key) * NULL on failure */ extern datum -dbm_firstkey(db) - DBM *db; +dbm_firstkey(DBM *db) { int status; datum retkey; @@ -139,8 +133,7 @@ dbm_firstkey(db) * NULL on failure */ extern datum -dbm_nextkey(db) - DBM *db; +dbm_nextkey(DBM *db) { int status; datum retkey; @@ -160,9 +153,7 @@ dbm_nextkey(db) * <0 failure */ extern int -dbm_delete(db, key) - DBM *db; - datum key; +dbm_delete(DBM *db, datum key) { int status; DBT dbtkey; @@ -183,10 +174,7 @@ dbm_delete(db, key) * 1 if DBM_INSERT and entry exists */ extern int -dbm_store(db, key, data, flags) - DBM *db; - datum key, data; - int flags; +dbm_store(DBM *db, datum key, datum data, int flags) { DBT dbtkey, dbtdata; @@ -199,8 +187,7 @@ dbm_store(db, key, data, flags) } extern int -dbm_error(db) - DBM *db; +dbm_error(DBM *db) { HTAB *hp; @@ -209,8 +196,7 @@ dbm_error(db) } extern int -dbm_clearerr(db) - DBM *db; +dbm_clearerr(DBM *db) { HTAB *hp; @@ -220,8 +206,7 @@ dbm_clearerr(db) } extern int -dbm_dirfno(db) - DBM *db; +dbm_dirfno(DBM *db) { return(((HTAB *)db->internal)->fp); } diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index dd286c092ab69..8fce730f27995 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -64,7 +64,7 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo, int rfd, sverrno; /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) + if (fname != NULL && (rfd = _open(fname, flags | O_CLOEXEC, mode)) < 0) return (NULL); /* Create a btree in memory (backed by disk). */ diff --git a/lib/libc/gdtoa/_ldtoa.c b/lib/libc/gdtoa/_ldtoa.c index 60c6b223bd6ef..00d76013f8875 100644 --- a/lib/libc/gdtoa/_ldtoa.c +++ b/lib/libc/gdtoa/_ldtoa.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include <limits.h> #include <math.h> #include <stdlib.h> +#include "../stdio/floatio.h" #include "fpmath.h" #include "gdtoaimp.h" diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c index 318be4c0f21d5..439a9e138e877 100644 --- a/lib/libc/gen/alarm.c +++ b/lib/libc/gen/alarm.c @@ -40,8 +40,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> unsigned int -alarm(secs) - unsigned int secs; +alarm(unsigned int secs) { struct itimerval it, oitv; struct itimerval *itp = ⁢ diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c index 73e199ce7e417..ccbc7a4bd0d64 100644 --- a/lib/libc/gen/assert.c +++ b/lib/libc/gen/assert.c @@ -38,10 +38,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> void -__assert(func, file, line, failedexpr) - const char *func, *file; - int line; - const char *failedexpr; +__assert(const char *func, const char *file, int line, const char *failedexpr) { if (func == NULL) (void)fprintf(stderr, diff --git a/lib/libc/gen/clock.c b/lib/libc/gen/clock.c index b405cda027234..435e0f827432f 100644 --- a/lib/libc/gen/clock.c +++ b/lib/libc/gen/clock.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); + (r).tv_usec / (1000000 / CLOCKS_PER_SEC)) clock_t -clock() +clock(void) { struct rusage ru; diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c index b359a87aa6436..15c6f4af7583c 100644 --- a/lib/libc/gen/daemon.c +++ b/lib/libc/gen/daemon.c @@ -41,10 +41,10 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" int -daemon(nochdir, noclose) - int nochdir, noclose; +daemon(int nochdir, int noclose) { struct sigaction osa, sa; int fd; @@ -56,7 +56,7 @@ daemon(nochdir, noclose) sigemptyset(&sa.sa_mask); sa.sa_handler = SIG_IGN; sa.sa_flags = 0; - osa_ok = _sigaction(SIGHUP, &sa, &osa); + osa_ok = __libc_sigaction(SIGHUP, &sa, &osa); switch (fork()) { case -1: @@ -74,7 +74,7 @@ daemon(nochdir, noclose) newgrp = setsid(); oerrno = errno; if (osa_ok != -1) - _sigaction(SIGHUP, &osa, NULL); + __libc_sigaction(SIGHUP, &osa, NULL); if (newgrp == -1) { errno = oerrno; diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c index da0b923573ade..bf9564589eb51 100644 --- a/lib/libc/gen/devname.c +++ b/lib/libc/gen/devname.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <sys/param.h> #include <sys/stat.h> diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 7d287974fa25f..53c9d67ab9e2b 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -41,6 +41,10 @@ __FBSDID("$FreeBSD$"); static char sorry[] = "Service unavailable"; +void _rtld_thread_init(void *); +void _rtld_atfork_pre(int *); +void _rtld_atfork_post(int *); + /* * For ELF, the dynamic linker directly resolves references to its * services to functions inside the dynamic linker itself. These diff --git a/lib/libc/gen/dup3.c b/lib/libc/gen/dup3.c index ac8877cdc8a62..ff3431af461b8 100644 --- a/lib/libc/gen/dup3.c +++ b/lib/libc/gen/dup3.c @@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include "un-namespace.h" +int __dup3(int, int, int); + int __dup3(int oldfd, int newfd, int flags) { diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c index 7bd75116c3869..069f62e53b34f 100644 --- a/lib/libc/gen/elf_utils.c +++ b/lib/libc/gen/elf_utils.c @@ -33,6 +33,9 @@ #include <link.h> #include <stddef.h> +int __elf_phdr_match_addr(struct dl_phdr_info *, void *); +void __pthread_map_stacks_exec(void); + int __elf_phdr_match_addr(struct dl_phdr_info *phdr_info, void *addr) { diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c index 0ba584cf0cb2d..a536e5af8736e 100644 --- a/lib/libc/gen/err.c +++ b/lib/libc/gen/err.c @@ -79,10 +79,7 @@ _err(int eval, const char *fmt, ...) } void -verr(eval, fmt, ap) - int eval; - const char *fmt; - va_list ap; +verr(int eval, const char *fmt, va_list ap) { verrc(eval, errno, fmt, ap); } diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 4998ee82f63e2..c6731f7cf7d07 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -131,9 +131,7 @@ execlp(const char *name, const char *arg, ...) } int -execv(name, argv) - const char *name; - char * const *argv; +execv(const char *name, char * const *argv) { (void)_execve(name, argv, environ); return (-1); diff --git a/lib/libc/gen/feature_present.c b/lib/libc/gen/feature_present.c index 7a2c28265c3dc..a230c8a8be038 100644 --- a/lib/libc/gen/feature_present.c +++ b/lib/libc/gen/feature_present.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> /* * Returns true if the named feature is present in the currently diff --git a/lib/libc/gen/fmtcheck.c b/lib/libc/gen/fmtcheck.c index 5b3f2c4cd75fc..7929f1f4b231f 100644 --- a/lib/libc/gen/fmtcheck.c +++ b/lib/libc/gen/fmtcheck.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> __weak_reference(__fmtcheck, fmtcheck); +const char * __fmtcheck(const char *, const char *); enum __e_fmtcheck_types { FMTCHECK_START, diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index 47d0a4131f5cb..2f240a8149183 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -76,9 +76,7 @@ static int fnmatch1(const char *, const char *, const char *, int, mbstate_t, mbstate_t); int -fnmatch(pattern, string, flags) - const char *pattern, *string; - int flags; +fnmatch(const char *pattern, const char *string, int flags) { static const mbstate_t initial; @@ -86,16 +84,17 @@ fnmatch(pattern, string, flags) } static int -fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) - const char *pattern, *string, *stringstart; - int flags; - mbstate_t patmbs, strmbs; +fnmatch1(const char *pattern, const char *string, const char *stringstart, + int flags, mbstate_t patmbs, mbstate_t strmbs) { + const char *bt_pattern, *bt_string; + mbstate_t bt_patmbs, bt_strmbs; char *newp; char c; wchar_t pc, sc; size_t pclen, sclen; + bt_pattern = bt_string = NULL; for (;;) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) @@ -111,16 +110,18 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) case EOS: if ((flags & FNM_LEADING_DIR) && sc == '/') return (0); - return (sc == EOS ? 0 : FNM_NOMATCH); + if (sc == EOS) + return (0); + goto backtrack; case '?': if (sc == EOS) return (FNM_NOMATCH); if (sc == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); + goto backtrack; if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); + goto backtrack; string += sclen; break; case '*': @@ -132,7 +133,7 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); + goto backtrack; /* Optimize for pattern with * at end or before /. */ if (c == EOS) @@ -148,33 +149,24 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) break; } - /* General case, use recursion. */ - while (sc != EOS) { - if (!fnmatch1(pattern, string, stringstart, - flags, patmbs, strmbs)) - return (0); - sclen = mbrtowc(&sc, string, MB_LEN_MAX, - &strmbs); - if (sclen == (size_t)-1 || - sclen == (size_t)-2) { - sc = (unsigned char)*string; - sclen = 1; - memset(&strmbs, 0, sizeof(strmbs)); - } - if (sc == '/' && flags & FNM_PATHNAME) - break; - string += sclen; - } - return (FNM_NOMATCH); + /* + * First try the shortest match for the '*' that + * could work. We can forget any earlier '*' since + * there is no way having it match more characters + * can help us, given that we are already here. + */ + bt_pattern = pattern, bt_patmbs = patmbs; + bt_string = string, bt_strmbs = strmbs; + break; case '[': if (sc == EOS) return (FNM_NOMATCH); if (sc == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); + goto backtrack; if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); + goto backtrack; switch (rangematch(pattern, sc, flags, &newp, &patmbs)) { @@ -184,7 +176,7 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) pattern = newp; break; case RANGE_NOMATCH: - return (FNM_NOMATCH); + goto backtrack; } string += sclen; break; @@ -199,14 +191,39 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) /* FALLTHROUGH */ default: norm: + string += sclen; if (pc == sc) ; else if ((flags & FNM_CASEFOLD) && (towlower(pc) == towlower(sc))) ; - else - return (FNM_NOMATCH); - string += sclen; + else { + backtrack: + /* + * If we have a mismatch (other than hitting + * the end of the string), go back to the last + * '*' seen and have it match one additional + * character. + */ + if (bt_pattern == NULL) + return (FNM_NOMATCH); + sclen = mbrtowc(&sc, bt_string, MB_LEN_MAX, + &bt_strmbs); + if (sclen == (size_t)-1 || + sclen == (size_t)-2) { + sc = (unsigned char)*bt_string; + sclen = 1; + memset(&bt_strmbs, 0, + sizeof(bt_strmbs)); + } + if (sc == EOS) + return (FNM_NOMATCH); + if (sc == '/' && flags & FNM_PATHNAME) + return (FNM_NOMATCH); + bt_string += sclen; + pattern = bt_pattern, patmbs = bt_patmbs; + string = bt_string, strmbs = bt_strmbs; + } break; } } @@ -214,12 +231,8 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) } static int -rangematch(pattern, test, flags, newp, patmbs) - const char *pattern; - wchar_t test; - int flags; - char **newp; - mbstate_t *patmbs; +rangematch(const char *pattern, wchar_t test, int flags, char **newp, + mbstate_t *patmbs) { int negate, ok; wchar_t c, c2; diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c index 4269e370c9f43..2fad66e64ee1e 100644 --- a/lib/libc/gen/ftok.c +++ b/lib/libc/gen/ftok.c @@ -33,9 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ipc.h> key_t -ftok(path, id) - const char *path; - int id; +ftok(const char *path, int id) { struct stat st; diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 1be41da11539c..51b6c261e5799 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -120,10 +120,8 @@ static const char *ufslike_filesystems[] = { }; FTS * -__fts_open_44bsd(argv, options, compar) - char * const *argv; - int options; - int (*compar)(const FTSENT * const *, const FTSENT * const *); +__fts_open_44bsd(char * const *argv, int options, + int (*compar)(const FTSENT * const *, const FTSENT * const *)) { struct _fts_private *priv; FTS *sp; @@ -139,9 +137,8 @@ __fts_open_44bsd(argv, options, compar) } /* Allocate/initialize the stream. */ - if ((priv = malloc(sizeof(*priv))) == NULL) + if ((priv = calloc(1, sizeof(*priv))) == NULL) return (NULL); - memset(priv, 0, sizeof(*priv)); sp = &priv->ftsp_fts; sp->fts_compar = compar; sp->fts_options = options; @@ -234,9 +231,7 @@ mem1: free(sp); } static void -fts_load(sp, p) - FTS *sp; - FTSENT *p; +fts_load(FTS *sp, FTSENT *p) { int len; char *cp; @@ -260,8 +255,7 @@ fts_load(sp, p) } int -__fts_close_44bsd(sp) - FTS *sp; +__fts_close_44bsd(FTS *sp) { FTSENT *freep, *p; int saved_errno; @@ -315,8 +309,7 @@ __fts_close_44bsd(sp) ? p->fts_pathlen - 1 : p->fts_pathlen) FTSENT * -__fts_read_44bsd(sp) - FTS *sp; +__fts_read_44bsd(FTS *sp) { FTSENT *p, *tmp; int instr; @@ -510,10 +503,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); */ /* ARGSUSED */ int -__fts_set_44bsd(sp, p, instr) - FTS *sp; - FTSENT *p; - int instr; +__fts_set_44bsd(FTS *sp, FTSENT *p, int instr) { if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && instr != FTS_NOINSTR && instr != FTS_SKIP) { @@ -525,9 +515,7 @@ __fts_set_44bsd(sp, p, instr) } FTSENT * -__fts_children_44bsd(sp, instr) - FTS *sp; - int instr; +__fts_children_44bsd(FTS *sp, int instr) { FTSENT *p; int fd; @@ -635,9 +623,7 @@ __fts_set_clientptr_44bsd(FTS *sp, void *clientptr) * been found, cutting the stat calls by about 2/3. */ static FTSENT * -fts_build(sp, type) - FTS *sp; - int type; +fts_build(FTS *sp, int type) { struct dirent *dp; FTSENT *p, *head; @@ -901,10 +887,7 @@ mem1: saved_errno = errno; } static u_short -fts_stat(sp, p, follow) - FTS *sp; - FTSENT *p; - int follow; +fts_stat(FTS *sp, FTSENT *p, int follow) { FTSENT *t; dev_t dev; @@ -999,10 +982,7 @@ fts_compar(const void *a, const void *b) } static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - int nitems; +fts_sort(FTS *sp, FTSENT *head, int nitems) { FTSENT **ap, *p; @@ -1031,10 +1011,7 @@ fts_sort(sp, head, nitems) } static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - char *name; - int namelen; +fts_alloc(FTS *sp, char *name, int namelen) { FTSENT *p; size_t len; @@ -1081,8 +1058,7 @@ fts_alloc(sp, name, namelen) } static void -fts_lfree(head) - FTSENT *head; +fts_lfree(FTSENT *head) { FTSENT *p; @@ -1100,9 +1076,7 @@ fts_lfree(head) * plus 256 bytes so don't realloc the path 2 bytes at a time. */ static int -fts_palloc(sp, more) - FTS *sp; - size_t more; +fts_palloc(FTS *sp, size_t more) { sp->fts_pathlen += more + 256; @@ -1127,9 +1101,7 @@ fts_palloc(sp, more) * already returned. */ static void -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; +fts_padjust(FTS *sp, FTSENT *head) { FTSENT *p; char *addr = sp->fts_path; @@ -1153,8 +1125,7 @@ fts_padjust(sp, head) } static size_t -fts_maxarglen(argv) - char * const *argv; +fts_maxarglen(char * const *argv) { size_t len, max; @@ -1170,11 +1141,7 @@ fts_maxarglen(argv) * Assumes p->fts_dev and p->fts_ino are filled in. */ static int -fts_safe_changedir(sp, p, fd, path) - FTS *sp; - FTSENT *p; - int fd; - char *path; +fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) { int ret, oerrno, newfd; struct stat sb; diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index 8083a88b86e6d..03ef5c84e079b 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -110,10 +110,8 @@ static const char *ufslike_filesystems[] = { }; FTS * -fts_open(argv, options, compar) - char * const *argv; - int options; - int (*compar)(const FTSENT * const *, const FTSENT * const *); +fts_open(char * const *argv, int options, + int (*compar)(const FTSENT * const *, const FTSENT * const *)) { struct _fts_private *priv; FTS *sp; @@ -1105,8 +1103,7 @@ fts_padjust(FTS *sp, FTSENT *head) } static size_t -fts_maxarglen(argv) - char * const *argv; +fts_maxarglen(char * const *argv) { size_t len, max; diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c index 7e88e3ff176a9..bbf5b1e896867 100644 --- a/lib/libc/gen/getbsize.c +++ b/lib/libc/gen/getbsize.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> char * -getbsize(headerlenp, blocksizep) - int *headerlenp; - long *blocksizep; +getbsize(int *headerlenp, long *blocksizep) { static char header[20]; long n, max, mul, blocksize; diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c index da76d56824f4d..6884897fe22cf 100644 --- a/lib/libc/gen/getcwd.c +++ b/lib/libc/gen/getcwd.c @@ -55,9 +55,7 @@ __FBSDID("$FreeBSD$"); extern int __getcwd(char *, size_t); char * -getcwd(pt, size) - char *pt; - size_t size; +getcwd(char *pt, size_t size) { struct dirent *dp; DIR *dir = NULL; diff --git a/lib/libc/gen/getdomainname.c b/lib/libc/gen/getdomainname.c index 21eb66def4b15..5a388576f142f 100644 --- a/lib/libc/gen/getdomainname.c +++ b/lib/libc/gen/getdomainname.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -getdomainname(name, namelen) - char *name; - int namelen; +getdomainname(char *name, int namelen) { int mib[2]; size_t size; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 1f4d7e9fb299f..31d2af1449675 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -75,6 +75,7 @@ static const ns_src defaultsrc[] = { { NULL, 0 } }; +int __getgroupmembership(const char *, gid_t, gid_t *, int, int *); int __gr_match_entry(const char *, size_t, enum nss_lookup_type, const char *, gid_t); int __gr_parse_entry(char *, size_t, struct group *, char *, size_t, @@ -1238,7 +1239,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap) int rv, stayopen; #define set_setent(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ @@ -1308,7 +1309,7 @@ compat_group(void *retval, void *mdata, va_list ap) int rv, stayopen, *errnop; #define set_lookup_type(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c index c83805e5ccb77..dc2b372a8ea5c 100644 --- a/lib/libc/gen/gethostname.c +++ b/lib/libc/gen/gethostname.c @@ -40,9 +40,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -gethostname(name, namelen) - char *name; - size_t namelen; +gethostname(char *name, size_t namelen) { int mib[2]; diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c index 127d3e8de0942..9c06d0a4d9861 100644 --- a/lib/libc/gen/getloadavg.c +++ b/lib/libc/gen/getloadavg.c @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * Return number of samples retrieved, or -1 on error. */ int -getloadavg(loadavg, nelem) - double loadavg[]; - int nelem; +getloadavg(double loadavg[], int nelem) { struct loadavg loadinfo; int i, mib[2]; diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c index 2b532f642c8a4..99f82aa8fc617 100644 --- a/lib/libc/gen/getmntinfo.c +++ b/lib/libc/gen/getmntinfo.c @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); * Return information about mounted filesystems. */ int -getmntinfo(mntbufp, flags) - struct statfs **mntbufp; - int flags; +getmntinfo(struct statfs **mntbufp, int flags) { static struct statfs *mntbuf; static int mntsize; diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c index f4b812861d72c..da2eb69a93eb3 100644 --- a/lib/libc/gen/getpagesize.c +++ b/lib/libc/gen/getpagesize.c @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); */ int -getpagesize() +getpagesize(void) { int mib[2]; static int value; diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 09a624785a15e..6546f587ae198 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1607,7 +1607,8 @@ compat_redispatch(struct compat_state *st, enum nss_lookup_type how, { NULL, NULL, NULL } }; void *discard; - int rv, e, i; + int rv, e; + unsigned int i; for (i = 0; i < sizeof(dtab)/sizeof(dtab[0]) - 1; i++) dtab[i].mdata = (void *)lookup_how; @@ -1702,7 +1703,7 @@ compat_setpwent(void *retval, void *mdata, va_list ap) int rv, stayopen; #define set_setent(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c index 53536e136f827..6e782865dfe33 100644 --- a/lib/libc/gen/getusershell.c +++ b/lib/libc/gen/getusershell.c @@ -102,10 +102,7 @@ static int _local_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_local_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_local_initshells(void *rv, void *cb_data, va_list ap) { char *sp, *cp; FILE *fp; @@ -139,10 +136,7 @@ static int _dns_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_dns_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_dns_initshells(void *rv, void *cb_data, va_list ap) { char shellname[] = "shells-XXXXX"; int hsindex, hpi, r; @@ -183,10 +177,7 @@ static int _nis_initshells(void *, void *, va_list); /*ARGSUSED*/ static int -_nis_initshells(rv, cb_data, ap) - void *rv; - void *cb_data; - va_list ap; +_nis_initshells(void *rv, void *cb_data, va_list ap) { static char *ypdomain; char *key, *data; @@ -239,7 +230,7 @@ _nis_initshells(rv, cb_data, ap) #endif /* YP */ static const char *const * -initshells() +initshells(void) { static const ns_dtab dtab[] = { NS_FILES_CB(_local_initshells, NULL) diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c index 0d896bbe63000..c90c5eeb8474c 100644 --- a/lib/libc/gen/getvfsbyname.c +++ b/lib/libc/gen/getvfsbyname.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); * and if it is resident, return its xvfsconf structure. */ int -getvfsbyname(fsname, vfcp) - const char *fsname; - struct xvfsconf *vfcp; +getvfsbyname(const char *fsname, struct xvfsconf *vfcp) { struct xvfsconf *xvfsp; size_t buflen; diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c index 95a3a060b3bfc..971d616e43e4c 100644 --- a/lib/libc/gen/glob.c +++ b/lib/libc/gen/glob.c @@ -650,13 +650,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last, int err; char buf[MAXPATHLEN]; - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(); + struct dirent *(*readdirfunc)(DIR *); if (pathend > pathend_last) return (GLOB_ABORTED); @@ -677,12 +671,14 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last, err = 0; - /* Search directory for matching names. */ + /* pglob->gl_readdir takes a void *, fix this manually */ if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; + readdirfunc = (struct dirent *(*)(DIR *))pglob->gl_readdir; else readdirfunc = readdir; - while ((dp = (*readdirfunc)(dirp))) { + + /* Search directory for matching names. */ + while ((dp = (*readdirfunc)(dirp)) != NULL) { char *sc; Char *dc; wchar_t wc; diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c index aacaf7e647d0f..d6a644c2c004c 100644 --- a/lib/libc/gen/initgroups.c +++ b/lib/libc/gen/initgroups.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -initgroups(uname, agroup) - const char *uname; - gid_t agroup; +initgroups(const char *uname, gid_t agroup) { int ngroups, ret; long ngroups_max; diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c index 076b824a44091..02b0ffdfeeaa5 100644 --- a/lib/libc/gen/isatty.c +++ b/lib/libc/gen/isatty.c @@ -37,8 +37,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> int -isatty(fd) - int fd; +isatty(int fd) { int retval; struct termios t; diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index ec878c5bebc5f..e93f89bfd4f21 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -61,11 +61,10 @@ __FBSDID("$FreeBSD$"); int __fdnlist(int, struct nlist *); int __aout_fdnlist(int, struct nlist *); int __elf_fdnlist(int, struct nlist *); +int __elf_is_okay__(Elf_Ehdr *); int -nlist(name, list) - const char *name; - struct nlist *list; +nlist(const char *name, struct nlist *list) { int fd, n; @@ -89,11 +88,10 @@ static struct nlist_handlers { }; int -__fdnlist(fd, list) - int fd; - struct nlist *list; +__fdnlist(int fd, struct nlist *list) { - int n = -1, i; + int n = -1; + unsigned int i; for (i = 0; i < sizeof(nlist_fn) / sizeof(nlist_fn[0]); i++) { n = (nlist_fn[i].fn)(fd, list); @@ -107,9 +105,7 @@ __fdnlist(fd, list) #ifdef _NLIST_DO_AOUT int -__aout_fdnlist(fd, list) - int fd; - struct nlist *list; +__aout_fdnlist(int fd, struct nlist *list) { struct nlist *p, *symtab; caddr_t strtab, a_out_mmap; @@ -235,9 +231,7 @@ __elf_is_okay__(Elf_Ehdr *ehdr) } int -__elf_fdnlist(fd, list) - int fd; - struct nlist *list; +__elf_fdnlist(int fd, struct nlist *list) { struct nlist *p; Elf_Off symoff = 0, symstroff = 0; @@ -377,11 +371,7 @@ __elf_fdnlist(fd, list) * n_value and n_type members. */ static void -elf_sym_to_nlist(nl, s, shdr, shnum) - struct nlist *nl; - Elf_Sym *s; - Elf_Shdr *shdr; - int shnum; +elf_sym_to_nlist(struct nlist *nl, Elf_Sym *s, Elf_Shdr *shdr, int shnum) { nl->n_value = s->st_value; diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c index ef48c1cd4518f..8e7a638783f45 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +int __pause(void); + /* * Backwards compatible pause. */ diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index e54bb5c668c2f..a7a9708dfda60 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -67,8 +67,7 @@ static pthread_mutex_t pidlist_mutex = PTHREAD_MUTEX_INITIALIZER; #define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&pidlist_mutex) FILE * -popen(command, type) - const char *command, *type; +popen(const char *command, const char *type) { struct pid *cur; FILE *iop; @@ -179,8 +178,7 @@ popen(command, type) * if already `pclosed', or waitpid returns an error. */ int -pclose(iop) - FILE *iop; +pclose(FILE *iop) { struct pid *cur, *last = NULL; int pstat; diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index e3124b2e24ba5..c65a730875d2f 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -118,15 +118,18 @@ process_spawnattr(const posix_spawnattr_t sa) return (errno); } - /* Set signal masks/defaults */ + /* + * Set signal masks/defaults. + * Use unwrapped syscall, libthr is in undefined state after vfork(). + */ if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { - _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); + __sys_sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); } if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { for (i = 1; i <= _SIG_MAXSIG; i++) { if (sigismember(&sa->sa_sigdefault, i)) - if (_sigaction(i, &sigact, NULL) != 0) + if (__sys_sigaction(i, &sigact, NULL) != 0) return (errno); } } diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c index 6fca4b18aabbe..5c5aadae33ad1 100644 --- a/lib/libc/gen/psignal.c +++ b/lib/libc/gen/psignal.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" void -psignal(sig, s) - unsigned int sig; - const char *s; +psignal(unsigned int sig, const char *s) { const char *c; diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c index 994fea57911b6..4bc895eb409a3 100644 --- a/lib/libc/gen/raise.c +++ b/lib/libc/gen/raise.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); __weak_reference(__raise, raise); __weak_reference(__raise, _raise); +int __raise(int); int __raise(int s) diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index c6f5d3fd6c9b2..b5162ed1e0e6a 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); * get next entry in a directory. */ struct dirent * -_readdir_unlocked(dirp, skip) - DIR *dirp; - int skip; +_readdir_unlocked(DIR *dirp, int skip) { struct dirent *dp; long initial_seek; @@ -91,8 +89,7 @@ _readdir_unlocked(dirp, skip) } struct dirent * -readdir(dirp) - DIR *dirp; +readdir(DIR *dirp) { struct dirent *dp; @@ -107,10 +104,7 @@ readdir(dirp) } int -readdir_r(dirp, entry, result) - DIR *dirp; - struct dirent *entry; - struct dirent **result; +readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; int saved_errno; diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c index 95ae725e040c4..60051a189e576 100644 --- a/lib/libc/gen/readpassphrase.c +++ b/lib/libc/gen/readpassphrase.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <readpassphrase.h> #include "un-namespace.h" +#include "libc_private.h" static volatile sig_atomic_t signo[NSIG]; @@ -104,15 +105,15 @@ restart: sigemptyset(&sa.sa_mask); sa.sa_flags = 0; /* don't restart system calls */ sa.sa_handler = handler; - (void)_sigaction(SIGALRM, &sa, &savealrm); - (void)_sigaction(SIGHUP, &sa, &savehup); - (void)_sigaction(SIGINT, &sa, &saveint); - (void)_sigaction(SIGPIPE, &sa, &savepipe); - (void)_sigaction(SIGQUIT, &sa, &savequit); - (void)_sigaction(SIGTERM, &sa, &saveterm); - (void)_sigaction(SIGTSTP, &sa, &savetstp); - (void)_sigaction(SIGTTIN, &sa, &savettin); - (void)_sigaction(SIGTTOU, &sa, &savettou); + (void)__libc_sigaction(SIGALRM, &sa, &savealrm); + (void)__libc_sigaction(SIGHUP, &sa, &savehup); + (void)__libc_sigaction(SIGINT, &sa, &saveint); + (void)__libc_sigaction(SIGPIPE, &sa, &savepipe); + (void)__libc_sigaction(SIGQUIT, &sa, &savequit); + (void)__libc_sigaction(SIGTERM, &sa, &saveterm); + (void)__libc_sigaction(SIGTSTP, &sa, &savetstp); + (void)__libc_sigaction(SIGTTIN, &sa, &savettin); + (void)__libc_sigaction(SIGTTOU, &sa, &savettou); if (!(flags & RPP_STDIN)) (void)_write(output, prompt, strlen(prompt)); @@ -142,15 +143,15 @@ restart: errno == EINTR && !signo[SIGTTOU]) continue; } - (void)_sigaction(SIGALRM, &savealrm, NULL); - (void)_sigaction(SIGHUP, &savehup, NULL); - (void)_sigaction(SIGINT, &saveint, NULL); - (void)_sigaction(SIGQUIT, &savequit, NULL); - (void)_sigaction(SIGPIPE, &savepipe, NULL); - (void)_sigaction(SIGTERM, &saveterm, NULL); - (void)_sigaction(SIGTSTP, &savetstp, NULL); - (void)_sigaction(SIGTTIN, &savettin, NULL); - (void)_sigaction(SIGTTOU, &savettou, NULL); + (void)__libc_sigaction(SIGALRM, &savealrm, NULL); + (void)__libc_sigaction(SIGHUP, &savehup, NULL); + (void)__libc_sigaction(SIGINT, &saveint, NULL); + (void)__libc_sigaction(SIGQUIT, &savequit, NULL); + (void)__libc_sigaction(SIGPIPE, &savepipe, NULL); + (void)__libc_sigaction(SIGTERM, &saveterm, NULL); + (void)__libc_sigaction(SIGTSTP, &savetstp, NULL); + (void)__libc_sigaction(SIGTTIN, &savettin, NULL); + (void)__libc_sigaction(SIGTTOU, &savettou, NULL); if (input != STDIN_FILENO) (void)_close(input); diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c index e157cd682e1c5..2421c472541ae 100644 --- a/lib/libc/gen/rewinddir.c +++ b/lib/libc/gen/rewinddir.c @@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$"); #include "telldir.h" void -rewinddir(dirp) - DIR *dirp; +rewinddir(DIR *dirp) { if (__isthreaded) diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c index e9851a7b1ea63..699de4626c100 100644 --- a/lib/libc/gen/seekdir.c +++ b/lib/libc/gen/seekdir.c @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * _seekdir is in telldir.c so that it can share opaque data structures. */ void -seekdir(dirp, loc) - DIR *dirp; - long loc; +seekdir(DIR *dirp, long loc) { if (__isthreaded) _pthread_mutex_lock(&dirp->dd_lock); diff --git a/lib/libc/gen/semctl.c b/lib/libc/gen/semctl.c index 156d18cac70d4..c68734d6318bb 100644 --- a/lib/libc/gen/semctl.c +++ b/lib/libc/gen/semctl.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); int __semctl(int semid, int semnum, int cmd, union semun *arg); int freebsd7___semctl(int semid, int semnum, int cmd, union semun_old *arg); +int freebsd7_semctl(int semid, int semnum, int cmd, ...); int semctl(int semid, int semnum, int cmd, ...) diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c index 3cfeb55e04c63..90fa4aa45af03 100644 --- a/lib/libc/gen/setjmperr.c +++ b/lib/libc/gen/setjmperr.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" void -longjmperror() +longjmperror(void) { #define ERRMSG "longjmp botch.\n" (void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c index 815cf146ed0ba..7525567bb7921 100644 --- a/lib/libc/gen/setmode.c +++ b/lib/libc/gen/setmode.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #endif #include "un-namespace.h" +#include "libc_private.h" #define SET_LEN 6 /* initial # of bitcmd struct to malloc */ #define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */ @@ -364,9 +365,9 @@ getumask(void) * handler, protect them as best we can. */ sigfillset(&sigset); - (void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset); + (void)__libc_sigprocmask(SIG_BLOCK, &sigset, &sigoset); (void)umask(mask = umask(0)); - (void)_sigprocmask(SIG_SETMASK, &sigoset, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &sigoset, NULL); return (mask); } diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c index fde33ca567cea..d99b772337869 100644 --- a/lib/libc/gen/siginterrupt.c +++ b/lib/libc/gen/siginterrupt.c @@ -43,14 +43,13 @@ __FBSDID("$FreeBSD$"); * after an instance of the indicated signal. */ int -siginterrupt(sig, flag) - int sig, flag; +siginterrupt(int sig, int flag) { extern sigset_t _sigintr __hidden; struct sigaction sa; int ret; - if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0) + if ((ret = __libc_sigaction(sig, (struct sigaction *)0, &sa)) < 0) return (ret); if (flag) { sigaddset(&_sigintr, sig); @@ -59,5 +58,5 @@ siginterrupt(sig, flag) sigdelset(&_sigintr, sig); sa.sa_flags |= SA_RESTART; } - return (_sigaction(sig, &sa, (struct sigaction *)0)); + return (__libc_sigaction(sig, &sa, (struct sigaction *)0)); } diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c index ee96dcc3c5b62..70e7f1712cea3 100644 --- a/lib/libc/gen/signal.c +++ b/lib/libc/gen/signal.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); sigset_t _sigintr __hidden; /* shared with siginterrupt */ sig_t -signal(s, a) - int s; - sig_t a; +signal(int s, sig_t a) { struct sigaction sa, osa; @@ -55,7 +53,7 @@ signal(s, a) sa.sa_flags = 0; if (!sigismember(&_sigintr, s)) sa.sa_flags |= SA_RESTART; - if (_sigaction(s, &sa, &osa) < 0) + if (__libc_sigaction(s, &sa, &osa) < 0) return (SIG_ERR); return (osa.sa_handler); } diff --git a/lib/libc/gen/sigsetops.c b/lib/libc/gen/sigsetops.c index cf7e688fa1006..cbcbfec487203 100644 --- a/lib/libc/gen/sigsetops.c +++ b/lib/libc/gen/sigsetops.c @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> int -sigaddset(set, signo) - sigset_t *set; - int signo; +sigaddset(sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { @@ -53,9 +51,7 @@ sigaddset(set, signo) } int -sigdelset(set, signo) - sigset_t *set; - int signo; +sigdelset(sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { @@ -67,8 +63,7 @@ sigdelset(set, signo) } int -sigemptyset(set) - sigset_t *set; +sigemptyset(sigset_t *set) { int i; @@ -78,8 +73,7 @@ sigemptyset(set) } int -sigfillset(set) - sigset_t *set; +sigfillset(sigset_t *set) { int i; @@ -89,9 +83,7 @@ sigfillset(set) } int -sigismember(set, signo) - const sigset_t *set; - int signo; +sigismember(const sigset_t *set, int signo) { if (signo <= 0 || signo > _SIG_MAXSIG) { diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index 6bb4ecd808384..6c33c3543a52a 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +unsigned int __sleep(unsigned int); + unsigned int __sleep(unsigned int seconds) { diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index 55e99451b13dd..dba9cd24fb65c 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -94,14 +94,13 @@ static struct { * are set, return the empty string. */ char * -fflagstostr(flags) - u_long flags; +fflagstostr(u_long flags) { char *string; const char *sp; char *dp; u_long setflags; - int i; + u_int i; if ((string = (char *)malloc(nmappings * (longestflaglen + 1))) == NULL) return (NULL); @@ -128,9 +127,7 @@ fflagstostr(flags) * to the offending token. */ int -strtofflags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; +strtofflags(char **stringp, u_long *setp, u_long *clrp) { char *string, *p; int i; diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 2b3acfb5db746..be3d4af9116dc 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -69,8 +69,7 @@ __FBSDID("$FreeBSD$"); * less useful than returning up-to-date values, however. */ long -sysconf(name) - int name; +sysconf(int name) { struct rlimit rl; size_t len; diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 7d7b90a7442e9..4594d9af9a505 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -28,7 +28,7 @@ .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd May 17, 2013 +.Dd September 10, 2015 .Dt SYSCTL 3 .Os .Sh NAME @@ -736,8 +736,6 @@ privilege may change the value. .It "VM_LOADAVG struct loadavg no" .It "VM_TOTAL struct vmtotal no" .It "VM_SWAPPING_ENABLED integer maybe" -.It "VM_V_CACHE_MAX integer yes" -.It "VM_V_CACHE_MIN integer yes" .It "VM_V_FREE_MIN integer yes" .It "VM_V_FREE_RESERVED integer yes" .It "VM_V_FREE_TARGET integer yes" @@ -757,12 +755,6 @@ The returned data consists of a 1 if process swapping is enabled or 0 if disabled. This variable is permanently set to 0 if the kernel was built with swapping disabled. -.It Li VM_V_CACHE_MAX -Maximum desired size of the cache queue. -.It Li VM_V_CACHE_MIN -Minimum desired size of the cache queue. -If the cache queue size -falls very far below this value, the pageout daemon is awakened. .It Li VM_V_FREE_MIN Minimum amount of memory (cache memory plus free memory) required to be available before a process waiting on memory will be diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c index 19cd6ee9fec8c..3e5678cf2eb18 100644 --- a/lib/libc/gen/telldir.c +++ b/lib/libc/gen/telldir.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); * return a pointer into a directory */ long -telldir(dirp) - DIR *dirp; +telldir(DIR *dirp) { struct ddloc *lp; long idx; @@ -86,9 +85,7 @@ telldir(dirp) * Only values returned by "telldir" should be passed to seekdir. */ void -_seekdir(dirp, loc) - DIR *dirp; - long loc; +_seekdir(DIR *dirp, long loc) { struct ddloc *lp; struct dirent *dp; @@ -152,8 +149,7 @@ _fixtelldir(DIR *dirp, long oldseek, long oldloc) * Reclaim memory for telldir cookies which weren't used. */ void -_reclaim_telldir(dirp) - DIR *dirp; +_reclaim_telldir(DIR *dirp) { struct ddloc *lp; struct ddloc *templp; diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 73eb9a261939a..ca4d69661b706 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -270,7 +270,7 @@ __libc_free_tls(void *tcb __unused, size_t tcbsize __unused, extern char **environ; void -_init_tls() +_init_tls(void) { #ifndef PIC Elf_Addr *sp; diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c index 1de0837e937a7..397e3ad466c47 100644 --- a/lib/libc/gen/ttyslot.c +++ b/lib/libc/gen/ttyslot.c @@ -33,6 +33,8 @@ static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +int __ttyslot(void); + int __ttyslot(void) { diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c index bf75775bb853f..6a1dca7915335 100644 --- a/lib/libc/gen/ualarm.c +++ b/lib/libc/gen/ualarm.c @@ -44,9 +44,7 @@ __FBSDID("$FreeBSD$"); * every ``reload'' microseconds after the first signal. */ useconds_t -ualarm(usecs, reload) - useconds_t usecs; - useconds_t reload; +ualarm(useconds_t usecs, useconds_t reload) { struct itimerval new, old; diff --git a/lib/libc/gen/uname.c b/lib/libc/gen/uname.c index 5a7baf7c32105..499f761ae48b5 100644 --- a/lib/libc/gen/uname.c +++ b/lib/libc/gen/uname.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #undef uname +int uname(struct utsname *); + int uname(struct utsname *name) { diff --git a/lib/libc/gen/unvis-compat.c b/lib/libc/gen/unvis-compat.c index 080143e39df8e..5fa5ca9ee0534 100644 --- a/lib/libc/gen/unvis-compat.c +++ b/lib/libc/gen/unvis-compat.c @@ -34,6 +34,8 @@ #define _UNVIS_END 1 +int __unvis_44bsd(char *, int, int *, int); + int __unvis_44bsd(char *cp, int c, int *astate, int flag) { diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 7c35f6c6fd9c3..90be6d455c914 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +int __usleep(useconds_t); + int __usleep(useconds_t useconds) { diff --git a/lib/libc/gen/utime.c b/lib/libc/gen/utime.c index 97bf8787956ac..0250a7ad8c330 100644 --- a/lib/libc/gen/utime.c +++ b/lib/libc/gen/utime.c @@ -38,9 +38,7 @@ __FBSDID("$FreeBSD$"); #include <utime.h> int -utime(path, times) - const char *path; - const struct utimbuf *times; +utime(const char *path, const struct utimbuf *times) { struct timeval tv[2], *tvp; diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 46a3fdd0bf525..7cede6e321b36 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __wait(int *); + pid_t __wait(int *istat) { diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c index 965effe432622..b50e3dd14b50c 100644 --- a/lib/libc/gen/wait3.c +++ b/lib/libc/gen/wait3.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __wait3(int *, int, struct rusage *); + pid_t __wait3(int *istat, int options, struct rusage *rup) { diff --git a/lib/libc/gen/waitid.c b/lib/libc/gen/waitid.c index 17a2dd6920b6d..8bdd6521aa31a 100644 --- a/lib/libc/gen/waitid.c +++ b/lib/libc/gen/waitid.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include "libc_private.h" +int __waitid(idtype_t, id_t, siginfo_t *, int); + int __waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags) { diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index 5177591a67cb2..5dc4fa820ea2c 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" +pid_t __waitpid(pid_t, int *, int); + pid_t __waitpid(pid_t pid, int *istat, int options) { diff --git a/lib/libc/gen/wordexp.3 b/lib/libc/gen/wordexp.3 index 2fc20ef81f2bb..dd4605ffa6fd5 100644 --- a/lib/libc/gen/wordexp.3 +++ b/lib/libc/gen/wordexp.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 18, 2015 +.Dd September 30, 2015 .Dt WORDEXP 3 .Os .Sh NAME @@ -108,8 +108,9 @@ function frees the memory allocated by .Sh IMPLEMENTATION NOTES The .Fn wordexp -function is implemented by executing -.Xr sh 1 . +function is implemented using the undocumented +.Ic freebsd_wordexp +shell built-in command. .Sh RETURN VALUES The .Fn wordexp @@ -191,18 +192,19 @@ and functions conform to .St -p1003.1-2001 . .Sh BUGS -Do not pass untrusted user data to -.Fn wordexp , -regardless of whether the -.Dv WRDE_NOCMD -flag is set. -The -.Fn wordexp -function attempts to detect input that would cause commands to be -executed before passing it to the shell -but it does not use the same parser so it may be fooled. -.Pp The current .Fn wordexp implementation does not recognize multibyte characters other than UTF-8, since the shell (which it invokes to perform expansions) does not. +.Sh SECURITY CONSIDERATIONS +Pathname generation may create output that is exponentially larger than the +input size. +.Pp +Although this implementation detects command substitution reliably for +.Dv WRDE_NOCMD , +the attack surface remains fairly large. +Also, some other implementations +(such as older versions of this one) +may execute command substitutions even if +.Dv WRDE_NOCMD +is set. diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c index 958ddc66d73da..3791e1e05b195 100644 --- a/lib/libc/gen/wordexp.c +++ b/lib/libc/gen/wordexp.c @@ -32,17 +32,19 @@ #include <fcntl.h> #include <paths.h> #include <signal.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <wordexp.h> #include "un-namespace.h" +#include "libc_private.h" __FBSDID("$FreeBSD$"); static int we_askshell(const char *, wordexp_t *, int); -static int we_check(const char *, int); +static int we_check(const char *); /* * wordexp -- @@ -64,7 +66,7 @@ wordexp(const char * __restrict words, wordexp_t * __restrict we, int flags) we->we_strings = NULL; we->we_nbytes = 0; } - if ((error = we_check(words, flags)) != 0) { + if ((error = we_check(words)) != 0) { wordfree(we); return (error); } @@ -93,17 +95,37 @@ we_read_fully(int fd, char *buffer, size_t len) return done; } +static bool +we_write_fully(int fd, const char *buffer, size_t len) +{ + size_t done; + ssize_t nwritten; + + done = 0; + do { + nwritten = _write(fd, buffer + done, len - done); + if (nwritten == -1 && errno == EINTR) + continue; + if (nwritten <= 0) + return (false); + done += nwritten; + } while (done != len); + return (true); +} + /* * we_askshell -- - * Use the `wordexp' /bin/sh builtin function to do most of the work - * in expanding the word string. This function is complicated by + * Use the `freebsd_wordexp' /bin/sh builtin function to do most of the + * work in expanding the word string. This function is complicated by * memory management. */ static int we_askshell(const char *words, wordexp_t *we, int flags) { - int pdes[2]; /* Pipe to child */ - char buf[18]; /* Buffer for byte and word count */ + int pdesw[2]; /* Pipe for writing words */ + int pdes[2]; /* Pipe for reading output */ + char wfdstr[sizeof(int) * 3 + 1]; + char buf[35]; /* Buffer for byte and word count */ long nwords, nbytes; /* Number of words, bytes from child */ long i; /* Handy integer */ size_t sofs; /* Offset into we->we_strings */ @@ -118,21 +140,28 @@ we_askshell(const char *words, wordexp_t *we, int flags) char **nwv; /* Temporary for realloc() */ sigset_t newsigblock, oldsigblock; const char *ifs; - char save; serrno = errno; ifs = getenv("IFS"); - if (pipe2(pdes, O_CLOEXEC) < 0) + if (pipe2(pdesw, O_CLOEXEC) < 0) + return (WRDE_NOSPACE); /* XXX */ + snprintf(wfdstr, sizeof(wfdstr), "%d", pdesw[0]); + if (pipe2(pdes, O_CLOEXEC) < 0) { + _close(pdesw[0]); + _close(pdesw[1]); return (WRDE_NOSPACE); /* XXX */ + } (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); - (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); + (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); if ((pid = fork()) < 0) { serrno = errno; + _close(pdesw[0]); + _close(pdesw[1]); _close(pdes[0]); _close(pdes[1]); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); errno = serrno; return (WRDE_NOSPACE); /* XXX */ } @@ -140,48 +169,59 @@ we_askshell(const char *words, wordexp_t *we, int flags) /* * We are the child; make /bin/sh expand `words'. */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); if ((pdes[1] != STDOUT_FILENO ? _dup2(pdes[1], STDOUT_FILENO) : _fcntl(pdes[1], F_SETFD, 0)) < 0) _exit(1); + if (_fcntl(pdesw[0], F_SETFD, 0) < 0) + _exit(1); execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", "IFS=$1;eval \"$2\";eval \"echo;set -- $3\";" - "IFS=;a=\"$*\";printf '%08x' \"$#\" \"${#a}\";" - "printf '%s\\0' \"$@\"", + "-c", "IFS=$1;eval \"$2\";" + "freebsd_wordexp -f \"$3\" ${4:+\"$4\"}", "", ifs != NULL ? ifs : " \t\n", - flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words, + flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", + wfdstr, + flags & WRDE_NOCMD ? "-p" : "", (char *)NULL); _exit(1); } /* - * We are the parent; read the output of the shell wordexp function, - * which is a byte indicating that the words were parsed successfully, - * a 32-bit hexadecimal word count, a 32-bit hexadecimal byte count - * (not including terminating null bytes), followed by the expanded - * words separated by nulls. + * We are the parent; write the words. */ _close(pdes[1]); - switch (we_read_fully(pdes[0], buf, 17)) { + _close(pdesw[0]); + if (!we_write_fully(pdesw[1], words, strlen(words))) { + _close(pdesw[1]); + error = WRDE_SYNTAX; + goto cleanup; + } + _close(pdesw[1]); + /* + * Read the output of the shell wordexp function, + * which is a byte indicating that the words were parsed successfully, + * a 64-bit hexadecimal word count, a dummy byte, a 64-bit hexadecimal + * byte count (not including terminating null bytes), followed by the + * expanded words separated by nulls. + */ + switch (we_read_fully(pdes[0], buf, 34)) { case 1: - error = WRDE_BADVAL; + error = buf[0] == 'C' ? WRDE_CMDSUB : WRDE_BADVAL; serrno = errno; goto cleanup; - case 17: + case 34: break; default: error = WRDE_SYNTAX; serrno = errno; goto cleanup; } - save = buf[9]; - buf[9] = '\0'; - nwords = strtol(buf + 1, NULL, 16); - buf[9] = save; buf[17] = '\0'; - nbytes = strtol(buf + 9, NULL, 16) + nwords; + nwords = strtol(buf + 1, NULL, 16); + buf[34] = '\0'; + nbytes = strtol(buf + 18, NULL, 16) + nwords; /* * Allocate or reallocate (when flags & WRDE_APPEND) the word vector @@ -222,7 +262,7 @@ cleanup: do wpid = _waitpid(pid, &status, 0); while (wpid < 0 && errno == EINTR); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); if (error != 0) { errno = serrno; return (error); @@ -254,83 +294,96 @@ cleanup: * we_check -- * Check that the string contains none of the following unquoted * special characters: <newline> |&;<>(){} - * or command substitutions when WRDE_NOCMD is set in flags. + * This mainly serves for {} which are normally legal in sh. + * It deliberately does not attempt to model full sh syntax. */ static int -we_check(const char *words, int flags) +we_check(const char *words) { char c; - int dquote, level, quote, squote; + /* Saw \ or $, possibly not special: */ + bool quote = false, dollar = false; + /* Saw ', ", ${, ` or $(, possibly not special: */ + bool have_sq = false, have_dq = false, have_par_begin = false; + bool have_cmd = false; + /* Definitely saw a ', ", ${, ` or $(, need a closing character: */ + bool need_sq = false, need_dq = false, need_par_end = false; + bool need_cmd_old = false, need_cmd_new = false; - quote = squote = dquote = 0; while ((c = *words++) != '\0') { switch (c) { case '\\': - if (squote == 0) - quote ^= 1; + quote = !quote; + continue; + case '$': + if (quote) + quote = false; + else + dollar = !dollar; continue; case '\'': - if (quote + dquote == 0) - squote ^= 1; + if (!quote && !have_sq && !have_dq) + need_sq = true; + else + need_sq = false; + have_sq = true; break; case '"': - if (quote + squote == 0) - dquote ^= 1; + if (!quote && !have_sq && !have_dq) + need_dq = true; + else + need_dq = false; + have_dq = true; break; case '`': - if (quote + squote == 0 && flags & WRDE_NOCMD) - return (WRDE_CMDSUB); - while ((c = *words++) != '\0' && c != '`') - if (c == '\\' && (c = *words++) == '\0') - break; - if (c == '\0') - return (WRDE_SYNTAX); + if (!quote && !have_sq && !have_cmd) + need_cmd_old = true; + else + need_cmd_old = false; + have_cmd = true; break; - case '|': case '&': case ';': case '<': case '>': - case '{': case '}': case '(': case ')': case '\n': - if (quote + squote + dquote == 0) + case '{': + if (!quote && !dollar && !have_sq && !have_dq && + !have_cmd) return (WRDE_BADCHAR); + if (dollar) { + if (!quote && !have_sq) + need_par_end = true; + have_par_begin = true; + } break; - case '$': - if ((c = *words++) == '\0') - break; - else if (quote + squote == 0 && c == '(') { - if (flags & WRDE_NOCMD && *words != '(') - return (WRDE_CMDSUB); - level = 1; - while ((c = *words++) != '\0') { - if (c == '\\') { - if ((c = *words++) == '\0') - break; - } else if (c == '(') - level++; - else if (c == ')' && --level == 0) - break; - } - if (c == '\0' || level != 0) - return (WRDE_SYNTAX); - } else if (quote + squote == 0 && c == '{') { - level = 1; - while ((c = *words++) != '\0') { - if (c == '\\') { - if ((c = *words++) == '\0') - break; - } else if (c == '{') - level++; - else if (c == '}' && --level == 0) - break; - } - if (c == '\0' || level != 0) - return (WRDE_SYNTAX); - } else - --words; + case '}': + if (!quote && !have_sq && !have_dq && !have_par_begin && + !have_cmd) + return (WRDE_BADCHAR); + need_par_end = false; + break; + case '(': + if (!quote && !dollar && !have_sq && !have_dq && + !have_cmd) + return (WRDE_BADCHAR); + if (dollar) { + if (!quote && !have_sq) + need_cmd_new = true; + have_cmd = true; + } + break; + case ')': + if (!quote && !have_sq && !have_dq && !have_cmd) + return (WRDE_BADCHAR); + need_cmd_new = false; + break; + case '|': case '&': case ';': case '<': case '>': case '\n': + if (!quote && !have_sq && !have_dq && !have_cmd) + return (WRDE_BADCHAR); break; default: break; } - quote = 0; + quote = dollar = false; } - if (quote + squote + dquote != 0) + if (quote || dollar || need_sq || need_dq || need_par_end || + need_cmd_old || need_cmd_new) return (WRDE_SYNTAX); return (0); diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 1f56bc2c3617d..eebce0a5cac58 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -68,11 +68,10 @@ static int s_scale; void moncontrol(int); static int hertz(void); +void _mcleanup(void); void -monstartup(lowpc, highpc) - u_long lowpc; - u_long highpc; +monstartup(u_long lowpc, u_long highpc) { int o; char *cp; @@ -218,8 +217,7 @@ _mcleanup(void) * all the data structures are ready. */ void -moncontrol(mode) - int mode; +moncontrol(int mode) { struct gmonparam *p = &_gmonparam; @@ -239,7 +237,7 @@ moncontrol(mode) * if something goes wrong, we return 0, an impossible hertz. */ static int -hertz() +hertz(void) { struct itimerval tim; diff --git a/lib/libc/i386/gen/setjmp.S b/lib/libc/i386/gen/setjmp.S index 6e15868a1901d..eb33e101ea86a 100644 --- a/lib/libc/i386/gen/setjmp.S +++ b/lib/libc/i386/gen/setjmp.S @@ -50,21 +50,12 @@ __FBSDID("$FreeBSD$"); ENTRY(setjmp) movl 4(%esp),%ecx - PIC_PROLOGUE -#ifdef PIC - subl $12,%esp /* make the stack 16-byte aligned */ -#endif leal 28(%ecx), %eax pushl %eax /* (sigset_t*)oset */ pushl $0 /* (sigset_t*)set */ pushl $1 /* SIG_BLOCK */ - call PIC_PLT(CNAME(_sigprocmask)) -#ifdef PIC - addl $24,%esp -#else + call __libc_sigprocmask addl $12,%esp -#endif - PIC_EPILOGUE movl 4(%esp),%ecx movl 0(%esp),%edx movl %edx, 0(%ecx) @@ -81,21 +72,12 @@ END(setjmp) WEAK_REFERENCE(__longjmp, longjmp) ENTRY(__longjmp) movl 4(%esp),%edx - PIC_PROLOGUE -#ifdef PIC - subl $12,%esp /* make the stack 16-byte aligned */ -#endif pushl $0 /* (sigset_t*)oset */ leal 28(%edx), %eax pushl %eax /* (sigset_t*)set */ pushl $3 /* SIG_SETMASK */ - call PIC_PLT(CNAME(_sigprocmask)) -#ifdef PIC - addl $24,%esp -#else + call __libc_sigprocmask addl $12,%esp -#endif - PIC_EPILOGUE movl 4(%esp),%edx movl 8(%esp),%eax movl 0(%edx),%ecx diff --git a/lib/libc/i386/gen/sigsetjmp.S b/lib/libc/i386/gen/sigsetjmp.S index 1c636493c507e..7566d72464095 100644 --- a/lib/libc/i386/gen/sigsetjmp.S +++ b/lib/libc/i386/gen/sigsetjmp.S @@ -59,21 +59,12 @@ ENTRY(sigsetjmp) movl %eax,44(%ecx) testl %eax,%eax jz 2f - PIC_PROLOGUE -#ifdef PIC - subl $12,%esp /* make the stack 16-byte aligned */ -#endif leal 28(%ecx), %eax pushl %eax /* (sigset_t*)oset */ pushl $0 /* (sigset_t*)set */ pushl $1 /* SIG_BLOCK */ - call PIC_PLT(CNAME(_sigprocmask)) -#ifdef PIC - addl $24,%esp -#else + call __libc_sigprocmask addl $12,%esp -#endif - PIC_EPILOGUE movl 4(%esp),%ecx 2: movl 0(%esp),%edx movl %edx, 0(%ecx) @@ -92,21 +83,12 @@ ENTRY(__siglongjmp) movl 4(%esp),%edx cmpl $0,44(%edx) jz 2f - PIC_PROLOGUE -#ifdef PIC - subl $12,%esp /* make the stack 16-byte aligned */ -#endif pushl $0 /* (sigset_t*)oset */ leal 28(%edx), %eax pushl %eax /* (sigset_t*)set */ pushl $3 /* SIG_SETMASK */ - call PIC_PLT(CNAME(_sigprocmask)) -#ifdef PIC - addl $24,%esp -#else + call __libc_sigprocmask addl $12,%esp -#endif - PIC_EPILOGUE movl 4(%esp),%edx 2: movl 8(%esp),%eax movl 0(%edx),%ecx diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h index a670d63e08543..5caf9a362550e 100644 --- a/lib/libc/include/libc_private.h +++ b/lib/libc/include/libc_private.h @@ -359,6 +359,11 @@ __pid_t __sys_wait6(enum idtype, __id_t, int *, int, __ssize_t __sys_write(int, const void *, __size_t); __ssize_t __sys_writev(int, const struct iovec *, int); +int __libc_sigaction(int, const struct sigaction *, + struct sigaction *) __hidden; +int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *) + __hidden; +int __libc_sigsuspend(const __sigset_t *) __hidden; int __libc_sigwait(const __sigset_t * __restrict, int * restrict sig); int __libc_system(const char *); diff --git a/lib/libc/inet/inet_lnaof.c b/lib/libc/inet/inet_lnaof.c index 7cab8946bba93..274253f4a3103 100644 --- a/lib/libc/inet/inet_lnaof.c +++ b/lib/libc/inet/inet_lnaof.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); * number formats. */ in_addr_t -inet_lnaof(in) - struct in_addr in; +inet_lnaof(struct in_addr in) { in_addr_t i = ntohl(in.s_addr); diff --git a/lib/libc/inet/inet_makeaddr.c b/lib/libc/inet/inet_makeaddr.c index 04a37a0347930..bce0aa1c127fb 100644 --- a/lib/libc/inet/inet_makeaddr.c +++ b/lib/libc/inet/inet_makeaddr.c @@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$"); * building addresses stored in the ifnet structure. */ struct in_addr -inet_makeaddr(net, host) - in_addr_t net, host; +inet_makeaddr(in_addr_t net, in_addr_t host) { struct in_addr a; diff --git a/lib/libc/inet/inet_net_ntop.c b/lib/libc/inet/inet_net_ntop.c index da7af33e2a213..001a30408c503 100644 --- a/lib/libc/inet/inet_net_ntop.c +++ b/lib/libc/inet/inet_net_ntop.c @@ -57,12 +57,7 @@ static char * inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, * Paul Vixie (ISC), July 1996 */ char * -inet_net_ntop(af, src, bits, dst, size) - int af; - const void *src; - int bits; - char *dst; - size_t size; +inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { case AF_INET: @@ -89,11 +84,7 @@ inet_net_ntop(af, src, bits, dst, size) * Paul Vixie (ISC), July 1996 */ static char * -inet_net_ntop_ipv4(src, bits, dst, size) - const u_char *src; - int bits; - char *dst; - size_t size; +inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) { char *odst = dst; char *t; diff --git a/lib/libc/inet/inet_neta.c b/lib/libc/inet/inet_neta.c index 01ad3be44a4a8..06a1bdbe13659 100644 --- a/lib/libc/inet/inet_neta.c +++ b/lib/libc/inet/inet_neta.c @@ -52,10 +52,7 @@ __FBSDID("$FreeBSD$"); * Paul Vixie (ISC), July 1996 */ char * -inet_neta(src, dst, size) - in_addr_t src; - char *dst; - size_t size; +inet_neta(in_addr_t src, char *dst, size_t size) { char *odst = dst; char *tp; diff --git a/lib/libc/inet/inet_netof.c b/lib/libc/inet/inet_netof.c index 8931c30fb03ad..2335772b68dc3 100644 --- a/lib/libc/inet/inet_netof.c +++ b/lib/libc/inet/inet_netof.c @@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$"); * address; handles class a/b/c network #'s. */ in_addr_t -inet_netof(in) - struct in_addr in; +inet_netof(struct in_addr in) { in_addr_t i = ntohl(in.s_addr); diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c index 254db41acb2dd..b5b9190ac1846 100644 --- a/lib/libc/inet/inet_network.c +++ b/lib/libc/inet/inet_network.c @@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$"); * network numbers. */ in_addr_t -inet_network(cp) - const char *cp; +inet_network(const char *cp) { in_addr_t val, base, n; char c; diff --git a/lib/libc/isc/ev_timers.c b/lib/libc/isc/ev_timers.c index 7c25c670ee642..6d08e370fd2a8 100644 --- a/lib/libc/isc/ev_timers.c +++ b/lib/libc/isc/ev_timers.c @@ -117,7 +117,7 @@ evCmpTime(struct timespec a, struct timespec b) { } struct timespec -evNowTime() { +evNowTime(void) { struct timeval now; #ifdef CLOCK_REALTIME struct timespec tsnow; @@ -136,7 +136,7 @@ evNowTime() { } struct timespec -evUTCTime() { +evUTCTime(void) { struct timeval now; #ifdef CLOCK_REALTIME struct timespec tsnow; diff --git a/lib/libc/locale/isctype.c b/lib/libc/locale/isctype.c index be1b091237fcf..25505343d41a9 100644 --- a/lib/libc/locale/isctype.c +++ b/lib/libc/locale/isctype.c @@ -45,184 +45,161 @@ __FBSDID("$FreeBSD$"); #undef digittoint int -digittoint(c) - int c; +digittoint(int c) { return (__sbmaskrune(c, 0xFF)); } #undef isalnum int -isalnum(c) - int c; +isalnum(int c) { return (__sbistype(c, _CTYPE_A|_CTYPE_D)); } #undef isalpha int -isalpha(c) - int c; +isalpha(int c) { return (__sbistype(c, _CTYPE_A)); } #undef isascii int -isascii(c) - int c; +isascii(int c) { return ((c & ~0x7F) == 0); } #undef isblank int -isblank(c) - int c; +isblank(int c) { return (__sbistype(c, _CTYPE_B)); } #undef iscntrl int -iscntrl(c) - int c; +iscntrl(int c) { return (__sbistype(c, _CTYPE_C)); } #undef isdigit int -isdigit(c) - int c; +isdigit(int c) { return (__isctype(c, _CTYPE_D)); } #undef isgraph int -isgraph(c) - int c; +isgraph(int c) { return (__sbistype(c, _CTYPE_G)); } #undef ishexnumber int -ishexnumber(c) - int c; +ishexnumber(int c) { return (__sbistype(c, _CTYPE_X)); } #undef isideogram int -isideogram(c) - int c; +isideogram(int c) { return (__sbistype(c, _CTYPE_I)); } #undef islower int -islower(c) - int c; +islower(int c) { return (__sbistype(c, _CTYPE_L)); } #undef isnumber int -isnumber(c) - int c; +isnumber(int c) { return (__sbistype(c, _CTYPE_D)); } #undef isphonogram int -isphonogram(c) - int c; +isphonogram(int c) { return (__sbistype(c, _CTYPE_Q)); } #undef isprint int -isprint(c) - int c; +isprint(int c) { return (__sbistype(c, _CTYPE_R)); } #undef ispunct int -ispunct(c) - int c; +ispunct(int c) { return (__sbistype(c, _CTYPE_P)); } #undef isrune int -isrune(c) - int c; +isrune(int c) { return (__sbistype(c, 0xFFFFFF00L)); } #undef isspace int -isspace(c) - int c; +isspace(int c) { return (__sbistype(c, _CTYPE_S)); } #undef isspecial int -isspecial(c) - int c; +isspecial(int c) { return (__sbistype(c, _CTYPE_T)); } #undef isupper int -isupper(c) - int c; +isupper(int c) { return (__sbistype(c, _CTYPE_U)); } #undef isxdigit int -isxdigit(c) - int c; +isxdigit(int c) { return (__isctype(c, _CTYPE_X)); } #undef toascii int -toascii(c) - int c; +toascii(int c) { return (c & 0x7F); } #undef tolower int -tolower(c) - int c; +tolower(int c) { return (__sbtolower(c)); } #undef toupper int -toupper(c) - int c; +toupper(int c) { return (__sbtoupper(c)); } diff --git a/lib/libc/locale/iswctype.c b/lib/libc/locale/iswctype.c index eaa1bf3d27806..59d432c90ce00 100644 --- a/lib/libc/locale/iswctype.c +++ b/lib/libc/locale/iswctype.c @@ -42,168 +42,147 @@ __FBSDID("$FreeBSD$"); #undef iswalnum int -iswalnum(wc) - wint_t wc; +iswalnum(wint_t wc) { return (__istype(wc, _CTYPE_A|_CTYPE_D)); } #undef iswalpha int -iswalpha(wc) - wint_t wc; +iswalpha(wint_t wc) { return (__istype(wc, _CTYPE_A)); } #undef iswascii int -iswascii(wc) - wint_t wc; +iswascii(wint_t wc) { return ((wc & ~0x7F) == 0); } #undef iswblank int -iswblank(wc) - wint_t wc; +iswblank(wint_t wc) { return (__istype(wc, _CTYPE_B)); } #undef iswcntrl int -iswcntrl(wc) - wint_t wc; +iswcntrl(wint_t wc) { return (__istype(wc, _CTYPE_C)); } #undef iswdigit int -iswdigit(wc) - wint_t wc; +iswdigit(wint_t wc) { return (__isctype(wc, _CTYPE_D)); } #undef iswgraph int -iswgraph(wc) - wint_t wc; +iswgraph(wint_t wc) { return (__istype(wc, _CTYPE_G)); } #undef iswhexnumber int -iswhexnumber(wc) - wint_t wc; +iswhexnumber(wint_t wc) { return (__istype(wc, _CTYPE_X)); } #undef iswideogram int -iswideogram(wc) - wint_t wc; +iswideogram(wint_t wc) { return (__istype(wc, _CTYPE_I)); } #undef iswlower int -iswlower(wc) - wint_t wc; +iswlower(wint_t wc) { return (__istype(wc, _CTYPE_L)); } #undef iswnumber int -iswnumber(wc) - wint_t wc; +iswnumber(wint_t wc) { return (__istype(wc, _CTYPE_D)); } #undef iswphonogram int -iswphonogram(wc) - wint_t wc; +iswphonogram(wint_t wc) { return (__istype(wc, _CTYPE_Q)); } #undef iswprint int -iswprint(wc) - wint_t wc; +iswprint(wint_t wc) { return (__istype(wc, _CTYPE_R)); } #undef iswpunct int -iswpunct(wc) - wint_t wc; +iswpunct(wint_t wc) { return (__istype(wc, _CTYPE_P)); } #undef iswrune int -iswrune(wc) - wint_t wc; +iswrune(wint_t wc) { return (__istype(wc, 0xFFFFFF00L)); } #undef iswspace int -iswspace(wc) - wint_t wc; +iswspace(wint_t wc) { return (__istype(wc, _CTYPE_S)); } #undef iswspecial int -iswspecial(wc) - wint_t wc; +iswspecial(wint_t wc) { return (__istype(wc, _CTYPE_T)); } #undef iswupper int -iswupper(wc) - wint_t wc; +iswupper(wint_t wc) { return (__istype(wc, _CTYPE_U)); } #undef iswxdigit int -iswxdigit(wc) - wint_t wc; +iswxdigit(wint_t wc) { return (__isctype(wc, _CTYPE_X)); } #undef towlower wint_t -towlower(wc) - wint_t wc; +towlower(wint_t wc) { return (__tolower(wc)); } #undef towupper wint_t -towupper(wc) - wint_t wc; +towupper(wint_t wc) { return (__toupper(wc)); } diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index 0322af266117d..13ff25bfd88e9 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -98,9 +98,7 @@ static char *loadlocale(int); const char *__get_locale_env(int); char * -setlocale(category, locale) - int category; - const char *locale; +setlocale(int category, const char *locale) { int i, j, len, saverr; const char *env, *r; @@ -209,7 +207,7 @@ setlocale(category, locale) } static char * -currentlocale() +currentlocale(void) { int i; @@ -228,8 +226,7 @@ currentlocale() } static char * -loadlocale(category) - int category; +loadlocale(int category) { char *new = new_categories[category]; char *old = current_categories[category]; @@ -286,8 +283,7 @@ loadlocale(category) } const char * -__get_locale_env(category) - int category; +__get_locale_env(int category) { const char *env; diff --git a/lib/libc/locale/tolower.c b/lib/libc/locale/tolower.c index f2eb48313c638..c74791da370c2 100644 --- a/lib/libc/locale/tolower.c +++ b/lib/libc/locale/tolower.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); #include "mblocal.h" __ct_rune_t -___tolower_l(c, l) - __ct_rune_t c; - locale_t l; +___tolower_l(__ct_rune_t c, locale_t l) { size_t lim; FIX_LOCALE(l); @@ -72,8 +70,7 @@ ___tolower_l(c, l) return(c); } __ct_rune_t -___tolower(c) - __ct_rune_t c; +___tolower(__ct_rune_t c) { return ___tolower_l(c, __get_locale()); } diff --git a/lib/libc/locale/toupper.c b/lib/libc/locale/toupper.c index 704ac3a2c1b0d..2c5ec86de4342 100644 --- a/lib/libc/locale/toupper.c +++ b/lib/libc/locale/toupper.c @@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$"); #include "mblocal.h" __ct_rune_t -___toupper_l(c, l) - __ct_rune_t c; - locale_t l; +___toupper_l(__ct_rune_t c, locale_t l) { size_t lim; FIX_LOCALE(l); @@ -74,8 +72,7 @@ ___toupper_l(c, l) return(c); } __ct_rune_t -___toupper(c) - __ct_rune_t c; +___toupper(__ct_rune_t c) { return ___toupper_l(c, __get_locale()); } diff --git a/lib/libc/mips/gen/_set_tp.c b/lib/libc/mips/gen/_set_tp.c index 0bf04b525acc0..a1a30c54b5970 100644 --- a/lib/libc/mips/gen/_set_tp.c +++ b/lib/libc/mips/gen/_set_tp.c @@ -30,6 +30,7 @@ #include <stdint.h> #include <machine/sysarch.h> +#include "libc_private.h" void _set_tp(void *tp) diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index 570fc2e3bcb45..1d6cb5632ca51 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2013 +.Dd October 5, 2015 .Dt GETADDRINFO 3 .Os .Sh NAME @@ -40,7 +40,6 @@ The .Fn getaddrinfo function is used to get a list of -.Tn IP addresses and port numbers for host .Fa hostname and service @@ -59,7 +58,9 @@ arguments are either pointers to NUL-terminated strings or the null pointer. An acceptable value for .Fa hostname is either a valid host name or a numeric host address string consisting -of a dotted decimal IPv4 address or an IPv6 address. +of a dotted decimal IPv4 address, +an IPv6 address, +or a UNIX-domain address. The .Fa servname is either a decimal port number or a service name listed in @@ -105,6 +106,7 @@ operating system. Denotes the type of socket that is wanted: .Dv SOCK_STREAM , .Dv SOCK_DGRAM , +.Dv SOCK_SEQPACKET , or .Dv SOCK_RAW . When @@ -112,9 +114,11 @@ When is zero the caller will accept any socket type. .It Fa ai_protocol Indicates which transport protocol is desired, -.Dv IPPROTO_UDP +.Dv IPPROTO_UDP , +.Dv IPPROTO_TCP , +.Dv IPPROTO_SCTP , or -.Dv IPPROTO_TCP . +.Dv IPPROTO_UDPLITE . If .Fa ai_protocol is zero the caller will accept any protocol. @@ -131,6 +135,9 @@ or be the bitwise-inclusive OR of one or more of the values .Dv AI_NUMERICSERV and .Dv AI_PASSIVE . +For a UNIX-domain address, +.Fa ai_flags +is ignored. .Bl -tag -width "AI_CANONNAMEXX" .It Dv AI_ADDRCONFIG If the @@ -236,15 +243,14 @@ The list can be traversed by following the pointer in each .Li addrinfo structure until a null pointer is encountered. -The three members +Each returned +.Li addrinfo +structure contains three members that are suitable for a call to +.Xr socket 2 : .Fa ai_family , .Fa ai_socktype , and -.Fa ai_protocol -in each returned -.Li addrinfo -structure are suitable for a call to -.Xr socket 2 . +.Fa ai_protocol . For each .Li addrinfo structure in the list, the @@ -419,6 +425,9 @@ freeaddrinfo(res0); .Xr getnameinfo 3 , .Xr getservbyname 3 , .Xr resolver 3 , +.Xr inet 4 , +.Xr inet6 4 , +.Xr unix 4 , .Xr hosts 5 , .Xr resolv.conf 5 , .Xr services 5 , diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 17c9b651c3758..95c588b23dd77 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -137,13 +137,20 @@ static const struct afd { offsetof(struct sockaddr_in6, sin6_addr), in6_addrany, in6_loopback, 1}, #define N_INET 1 +#define N_LOCAL 2 #else #define N_INET 0 +#define N_LOCAL 1 #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), offsetof(struct sockaddr_in, sin_addr), in_addrany, in_loopback, 0}, +#define sizeofmember(type, member) (sizeof(((type *)0)->member)) + {PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path), + sizeof(struct sockaddr_un), + offsetof(struct sockaddr_un, sun_path), + NULL, NULL, 0}, {0, 0, 0, 0, NULL, NULL, 0}, }; @@ -152,29 +159,47 @@ struct explore { int e_socktype; int e_protocol; int e_wild; -#define WILD_AF(ex) ((ex)->e_wild & 0x01) -#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) -#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) +#define AF_ANY 0x01 +#define SOCKTYPE_ANY 0x02 +#define PROTOCOL_ANY 0x04 +#define WILD_AF(ex) ((ex)->e_wild & AF_ANY) +#define WILD_SOCKTYPE(ex) ((ex)->e_wild & SOCKTYPE_ANY) +#define WILD_PROTOCOL(ex) ((ex)->e_wild & PROTOCOL_ANY) }; static const struct explore explore[] = { -#if 0 - { PF_LOCAL, ANY, ANY, 0x01 }, -#endif #ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, - { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, - { PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 }, - { PF_INET6, SOCK_RAW, ANY, 0x05 }, + { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_STREAM, IPPROTO_TCP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET6, SOCK_RAW, ANY, + AF_ANY | PROTOCOL_ANY }, #endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_SCTP, 0x03 }, - { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 }, - { PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 }, - { PF_INET, SOCK_RAW, ANY, 0x05 }, + { PF_INET, SOCK_DGRAM, IPPROTO_UDP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_STREAM, IPPROTO_TCP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_STREAM, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE, + AF_ANY | SOCKTYPE_ANY }, + { PF_INET, SOCK_RAW, ANY, + AF_ANY | PROTOCOL_ANY }, + { PF_LOCAL, SOCK_DGRAM, ANY, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_LOCAL, SOCK_STREAM, ANY, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, + { PF_LOCAL, SOCK_SEQPACKET, ANY, + AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY }, { -1, 0, 0, 0 }, }; @@ -408,6 +433,7 @@ getaddrinfo(const char *hostname, const char *servname, ERR(EAI_BADFLAGS); switch (hints->ai_family) { case PF_UNSPEC: + case PF_LOCAL: case PF_INET: #ifdef INET6 case PF_INET6: @@ -1130,6 +1156,9 @@ explore_null(const struct addrinfo *pai, const char *servname, *res = NULL; ai = NULL; + if (pai->ai_family == PF_LOCAL) + return (0); + /* * filter out AFs that are not supported by the kernel * XXX errno? @@ -1172,8 +1201,11 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, const struct afd *afd; struct addrinfo *ai; int error; - char pton[PTON_MAX]; + char pton[PTON_MAX], path[PATH_MAX], *p; +#ifdef CTASSERT + CTASSERT(sizeofmember(struct sockaddr_un, sun_path) <= PATH_MAX); +#endif *res = NULL; ai = NULL; @@ -1182,6 +1214,15 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, return 0; switch (afd->a_af) { + case AF_LOCAL: + if (hostname[0] != '/') + ERR(EAI_NONAME); + if (strlen(hostname) > afd->a_addrlen) + ERR(EAI_MEMORY); + /* NUL-termination does not need to be guaranteed. */ + strncpy(path, hostname, afd->a_addrlen); + p = &path[0]; + break; case AF_INET: /* * RFC3493 requires getaddrinfo() to accept AF_INET formats @@ -1192,17 +1233,21 @@ explore_numeric(const struct addrinfo *pai, const char *hostname, */ if (inet_aton(hostname, (struct in_addr *)pton) != 1) return 0; + p = pton; break; default: if (inet_pton(afd->a_af, hostname, pton) != 1) return 0; + p = pton; break; } if (pai->ai_family == afd->a_af) { - GET_AI(ai, afd, pton); + GET_AI(ai, afd, p); GET_PORT(ai, servname); - if ((pai->ai_flags & AI_CANONNAME)) { + if ((pai->ai_family == AF_INET || + pai->ai_family == AF_INET6) && + (pai->ai_flags & AI_CANONNAME)) { /* * Set the numeric address itself as the canonical * name, based on a clarification in RFC3493. @@ -1320,6 +1365,12 @@ get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr) memset(ai->ai_addr, 0, (size_t)afd->a_socklen); ai->ai_addr->sa_len = afd->a_socklen; ai->ai_addrlen = afd->a_socklen; + if (ai->ai_family == PF_LOCAL) { + size_t n = strnlen(addr, afd->a_addrlen); + + ai->ai_addrlen -= afd->a_addrlen - n; + ai->ai_addr->sa_len -= afd->a_addrlen - n; + } ai->ai_addr->sa_family = ai->ai_family = afd->a_af; p = (char *)(void *)(ai->ai_addr); memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); @@ -1378,6 +1429,9 @@ get_port(struct addrinfo *ai, const char *servname, int matchonly) if (servname == NULL) return 0; switch (ai->ai_family) { + case AF_LOCAL: + /* AF_LOCAL ignores servname silently. */ + return (0); case AF_INET: #ifdef AF_INET6 case AF_INET6: diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c index f301c88017346..ac93abe5a1484 100644 --- a/lib/libc/net/gethostbydns.c +++ b/lib/libc/net/gethostbydns.c @@ -107,10 +107,7 @@ int _dns_ttl_; #ifdef DEBUG static void -dprintf(msg, num, res) - char *msg; - int num; - res_state res; +dprintf(char *msg, int num, res_state res) { if (res->options & RES_DEBUG) { int save = errno; @@ -769,7 +766,7 @@ _sethostdnsent(int stayopen) } void -_endhostdnsent() +_endhostdnsent(void) { res_state statp; diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index 2dc9d0233adce..6bbe2700391a6 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -48,13 +48,6 @@ __FBSDID("$FreeBSD$"); #include "nscache.h" #endif -extern int _ht_gethostbyname(void *, void *, va_list); -extern int _dns_gethostbyname(void *, void *, va_list); -extern int _nis_gethostbyname(void *, void *, va_list); -extern int _ht_gethostbyaddr(void *, void *, va_list); -extern int _dns_gethostbyaddr(void *, void *, va_list); -extern int _nis_gethostbyaddr(void *, void *, va_list); - static int gethostbyname_internal(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *, res_state); diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 index 0549ccd2219b0..ff227fd2fc038 100644 --- a/lib/libc/net/getnameinfo.3 +++ b/lib/libc/net/getnameinfo.3 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 14, 2013 +.Dd September 20, 2015 .Dt GETNAMEINFO 3 .Os .Sh NAME @@ -47,7 +47,7 @@ functions and is the converse of the .Xr getaddrinfo 3 function. .Pp -If a link-layer address is passed to +If a link-layer address or UNIX-domain address is passed to .Fn getnameinfo , its ASCII representation will be stored in .Fa host . @@ -56,7 +56,8 @@ The string pointed to by will be set to the empty string if non-NULL; .Fa flags will always be ignored. -This is intended as a replacement for the legacy +For a link-layer address, +this can be used as a replacement of the legacy .Xr link_ntoa 3 function. .Pp @@ -66,10 +67,17 @@ structure .Fa sa should point to either a .Li sockaddr_in , -.Li sockaddr_in6 +.Li sockaddr_in6 , +.Li sockaddr_dl , or -.Li sockaddr_dl -structure (for IPv4, IPv6 or link-layer respectively) that is +.Li sockaddr_un +structure +.Po for IPv4 , +IPv6, +link-layer, +or UNIX-domain respectively +.Pc +that is .Fa salen bytes long. .Pp @@ -182,6 +190,9 @@ printf("host=%s\en", hbuf); .Xr inet_ntop 3 , .Xr link_ntoa 3 , .Xr resolver 3 , +.Xr inet 4 , +.Xr inet6 4 , +.Xr unix 4 , .Xr hosts 5 , .Xr resolv.conf 5 , .Xr services 5 , diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index 005b8773bfc15..c81318926ba12 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/socket.h> +#include <sys/un.h> #include <net/if.h> #include <net/if_dl.h> #include <net/if_types.h> @@ -62,92 +63,113 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> #include <errno.h> -static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *, +static const struct afd *find_afd(int); +static int getnameinfo_inet(const struct afd *, + const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); #ifdef INET6 static int ip6_parsenumeric(const struct sockaddr *, const char *, char *, size_t, int); static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int); #endif -static int getnameinfo_link(const struct sockaddr *, socklen_t, char *, +static int getnameinfo_link(const struct afd *, + const struct sockaddr *, socklen_t, char *, + size_t, char *, size_t, int); +static int hexname(const u_int8_t *, size_t, char *, size_t); +static int getnameinfo_un(const struct afd *, + const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); -static int hexname(const u_int8_t *, size_t, char *, size_t); - -int -getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *host, size_t hostlen, char *serv, size_t servlen, - int flags) -{ - - switch (sa->sa_family) { - case AF_INET: -#ifdef INET6 - case AF_INET6: -#endif - return getnameinfo_inet(sa, salen, host, hostlen, serv, - servlen, flags); - case AF_LINK: - return getnameinfo_link(sa, salen, host, hostlen, serv, - servlen, flags); - default: - return EAI_FAMILY; - } -} static const struct afd { int a_af; size_t a_addrlen; socklen_t a_socklen; int a_off; + int (*a_func)(const struct afd *, + const struct sockaddr *, socklen_t, char *, + size_t, char *, size_t, int); } afdl [] = { #ifdef INET6 {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, + offsetof(struct sockaddr_in6, sin6_addr), + getnameinfo_inet}, #endif {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, + offsetof(struct sockaddr_in, sin_addr), + getnameinfo_inet}, +#define sizeofmember(type, member) (sizeof(((type *)0)->member)) + {PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path), + sizeof(struct sockaddr_un), + offsetof(struct sockaddr_un, sun_path), + getnameinfo_un}, + {PF_LINK, sizeofmember(struct sockaddr_dl, sdl_data), + sizeof(struct sockaddr_dl), + offsetof(struct sockaddr_dl, sdl_data), + getnameinfo_link}, {0, 0, 0}, }; -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; +int +getnameinfo(const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, char *serv, size_t servlen, + int flags) +{ + const struct afd *afd; + + if (sa == NULL) + return (EAI_FAIL); + + afd = find_afd(sa->sa_family); + if (afd == NULL) + return (EAI_FAMILY); + if (sa->sa_family == PF_LOCAL) { + /* + * PF_LOCAL uses variable sa->sa_len depending on the + * content length of sun_path. Require 1 byte in + * sun_path at least. + */ + if (salen > afd->a_socklen || + salen <= afd->a_socklen - + sizeofmember(struct sockaddr_un, sun_path)) + return (EAI_FAIL); + } else if (salen != afd->a_socklen) + return (EAI_FAIL); + + return ((*afd->a_func)(afd, sa, salen, host, hostlen, + serv, servlen, flags)); +} + +static const struct afd * +find_afd(int af) +{ + const struct afd *afd; + + if (af == PF_UNSPEC) + return (NULL); + for (afd = &afdl[0]; afd->a_af > 0; afd++) { + if (afd->a_af == af) + return (afd); + } + return (NULL); +} static int -getnameinfo_inet(const struct sockaddr *sa, socklen_t salen, +getnameinfo_inet(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { - const struct afd *afd; struct servent *sp; struct hostent *hp; u_short port; - int family, i; const char *addr; u_int32_t v4a; int h_error; char numserv[512]; char numaddr[512]; - if (sa == NULL) - return EAI_FAIL; - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return EAI_FAMILY; - - found: - if (salen != afd->a_socklen) - return EAI_FAIL; - /* network byte order */ - port = ((const struct sockinet *)sa)->si_port; + port = ((const struct sockaddr_in *)sa)->sin_port; addr = (const char *)sa + afd->a_off; if (serv == NULL || servlen == 0) { @@ -381,7 +403,8 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags) */ /* ARGSUSED */ static int -getnameinfo_link(const struct sockaddr *sa, socklen_t salen, +getnameinfo_link(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { const struct sockaddr_dl *sdl = @@ -394,11 +417,22 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen, if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) { n = snprintf(host, hostlen, "link#%d", sdl->sdl_index); - if (n > hostlen) { + if (n >= hostlen) { *host = '\0'; - return EAI_MEMORY; + return (EAI_MEMORY); + } + return (0); + } + + if (sdl->sdl_nlen > 0 && sdl->sdl_alen == 0) { + n = sdl->sdl_nlen; + if (n >= hostlen) { + *host = '\0'; + return (EAI_MEMORY); } - return 0; + memcpy(host, sdl->sdl_data, sdl->sdl_nlen); + host[n] = '\0'; + return (0); } switch (sdl->sdl_type) { @@ -440,10 +474,7 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen, } static int -hexname(cp, len, host, hostlen) - const u_int8_t *cp; - char *host; - size_t len, hostlen; +hexname(const u_int8_t *cp, size_t len, char *host, size_t hostlen) { int i, n; char *outp = host; @@ -461,3 +492,30 @@ hexname(cp, len, host, hostlen) } return 0; } + +/* + * getnameinfo_un(): + * Format a UNIX IPC domain address (pathname). + */ +/* ARGSUSED */ +static int +getnameinfo_un(const struct afd *afd, + const struct sockaddr *sa, socklen_t salen, + char *host, size_t hostlen, char *serv, size_t servlen, int flags) +{ + size_t pathlen; + + if (serv != NULL && servlen > 0) + *serv = '\0'; + if (host != NULL && hostlen > 0) { + pathlen = sa->sa_len - afd->a_off; + + if (pathlen + 1 > hostlen) { + *host = '\0'; + return (EAI_MEMORY); + } + strlcpy(host, (const char *)sa + afd->a_off, pathlen + 1); + } + + return (0); +} diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index 79e40a5a7f60a..6667a82f46458 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -455,7 +455,7 @@ _setnetdnsent(int stayopen) } void -_endnetdnsent() +_endnetdnsent(void) { res_state statp; diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c index 9aa4d51ee5dda..4d2fb3833293e 100644 --- a/lib/libc/net/getnetnamadr.c +++ b/lib/libc/net/getnetnamadr.c @@ -46,13 +46,6 @@ __FBSDID("$FreeBSD$"); #include "nscache.h" #endif -extern int _ht_getnetbyname(void *, void *, va_list); -extern int _dns_getnetbyname(void *, void *, va_list); -extern int _nis_getnetbyname(void *, void *, va_list); -extern int _ht_getnetbyaddr(void *, void *, va_list); -extern int _dns_getnetbyaddr(void *, void *, va_list); -extern int _nis_getnetbyaddr(void *, void *, va_list); - /* Network lookup order if nsswitch.conf is broken or nonexistant */ static const ns_src default_src[] = { { NSSRC_FILES, NS_SUCCESS }, diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c index b923edf18a991..36eeb90a8a32c 100644 --- a/lib/libc/net/getproto.c +++ b/lib/libc/net/getproto.c @@ -47,12 +47,6 @@ static const ns_src defaultsrc[] = { { NULL, 0 } }; -#ifdef NS_CACHING -extern int __proto_id_func(char *, size_t *, va_list, void *); -extern int __proto_marshal_func(char *, size_t *, void *, va_list, void *); -extern int __proto_unmarshal_func(char *, size_t, void *, va_list, void *); -#endif - static int files_getprotobynumber(void *retval, void *mdata, va_list ap) { diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index 005de98700642..6a68ef508d582 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -1241,7 +1241,7 @@ setservent(int stayopen) } void -endservent() +endservent(void) { #ifdef NS_CACHING static const nss_cache_info cache_info = NS_MP_CACHE_INFO_INITIALIZER( @@ -1362,7 +1362,7 @@ getservbyport(int port, const char *proto) } struct servent * -getservent() +getservent(void) { struct key key; diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c index 8f04921760ebb..debf3fabc6af6 100644 --- a/lib/libc/net/if_nametoindex.c +++ b/lib/libc/net/if_nametoindex.c @@ -70,9 +70,7 @@ if_nametoindex(const char *ifname) s = _socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (s != -1) { -#ifdef PURIFY memset(&ifr, 0, sizeof(ifr)); -#endif strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) { _close(s); diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c index 5be6e74114e1b..2f7222bcb0e9d 100644 --- a/lib/libc/net/linkaddr.c +++ b/lib/libc/net/linkaddr.c @@ -50,9 +50,7 @@ __FBSDID("$FreeBSD$"); #define LETTER (4*3) void -link_addr(addr, sdl) - const char *addr; - struct sockaddr_dl *sdl; +link_addr(const char *addr, struct sockaddr_dl *sdl) { char *cp = sdl->sdl_data; char *cplim = sdl->sdl_len + (char *)sdl; @@ -121,8 +119,7 @@ link_addr(addr, sdl) static const char hexlist[] = "0123456789abcdef"; char * -link_ntoa(sdl) - const struct sockaddr_dl *sdl; +link_ntoa(const struct sockaddr_dl *sdl) { static char obuf[64]; char *out = obuf; diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c index dbc7e7031271d..09b035b578432 100644 --- a/lib/libc/net/map_v4v6.c +++ b/lib/libc/net/map_v4v6.c @@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$"); #include <resolv.h> #include <ctype.h> #include <syslog.h> +#include "netdb_private.h" typedef union { int32_t al; diff --git a/lib/libc/net/netdb_private.h b/lib/libc/net/netdb_private.h index b48dd7be6d07b..0eedb3c62587c 100644 --- a/lib/libc/net/netdb_private.h +++ b/lib/libc/net/netdb_private.h @@ -142,4 +142,23 @@ void _sethosthtent(int, struct hostent_data *); void _setnetdnsent(int); void _setnethtent(int, struct netent_data *); +struct hostent *__dns_getanswer(const char *, int, const char *, int); +int _dns_gethostbyaddr(void *, void *, va_list); +int _dns_gethostbyname(void *, void *, va_list); +int _dns_getnetbyaddr(void *, void *, va_list); +int _dns_getnetbyname(void *, void *, va_list); +int _ht_gethostbyaddr(void *, void *, va_list); +int _ht_gethostbyname(void *, void *, va_list); +int _ht_getnetbyaddr(void *, void *, va_list); +int _ht_getnetbyname(void *, void *, va_list); +int _nis_gethostbyaddr(void *, void *, va_list); +int _nis_gethostbyname(void *, void *, va_list); +int _nis_getnetbyaddr(void *, void *, va_list); +int _nis_getnetbyname(void *, void *, va_list); +#ifdef NS_CACHING +int __proto_id_func(char *, size_t *, va_list, void *); +int __proto_marshal_func(char *, size_t *, void *, va_list, void *); +int __proto_unmarshal_func(char *, size_t, void *, va_list, void *); +#endif + #endif /* _NETDB_PRIVATE_H_ */ diff --git a/lib/libc/net/nscache.c b/lib/libc/net/nscache.c index 68cec2129a158..88a115be673b6 100644 --- a/lib/libc/net/nscache.c +++ b/lib/libc/net/nscache.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" +#define _NS_PRIVATE #include <nsswitch.h> #include <stdlib.h> #include <string.h> diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l index 3983fa257903f..c7a95f614da84 100644 --- a/lib/libc/net/nslexer.l +++ b/lib/libc/net/nslexer.l @@ -97,14 +97,13 @@ STRING [a-zA-Z][a-zA-Z0-9_]* #undef _nsyywrap int -_nsyywrap() +_nsyywrap(void) { return 1; } /* _nsyywrap */ void -_nsyyerror(msg) - const char *msg; +_nsyyerror(const char *msg) { syslog(LOG_ERR, "NSSWITCH(nslexer): %s line %d: %s at '%s'", diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y index c1d84247bd8ca..7d2f6e2085219 100644 --- a/lib/libc/net/nsparser.y +++ b/lib/libc/net/nsparser.y @@ -145,8 +145,7 @@ Action %% static void -_nsaddsrctomap(elem) - const char *elem; +_nsaddsrctomap(const char *elem) { int i, lineno; extern int _nsyylineno; diff --git a/lib/libc/net/nss_compat.c b/lib/libc/net/nss_compat.c index 09a2d4f8f5cc6..ba1e95198cedb 100644 --- a/lib/libc/net/nss_compat.c +++ b/lib/libc/net/nss_compat.c @@ -79,6 +79,16 @@ do { \ DECLARE_TERMINATOR(group); +int __nss_compat_getgrnam_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getgrgid_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getgrent_r(void *retval, void *mdata, va_list ap); +int __nss_compat_setgrent(void *retval, void *mdata, va_list ap); +int __nss_compat_endgrent(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwnam_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwuid_r(void *retval, void *mdata, va_list ap); +int __nss_compat_getpwent_r(void *retval, void *mdata, va_list ap); +int __nss_compat_setpwent(void *retval, void *mdata, va_list ap); +int __nss_compat_endpwent(void *retval, void *mdata, va_list ap); int __nss_compat_getgrnam_r(void *retval, void *mdata, va_list ap) diff --git a/lib/libc/net/ntoh.c b/lib/libc/net/ntoh.c index 738d8c70c67de..d658c90b68ace 100644 --- a/lib/libc/net/ntoh.c +++ b/lib/libc/net/ntoh.c @@ -28,6 +28,8 @@ __FBSDID("$FreeBSD$"); #include <sys/endian.h> +#define _BYTEORDER_FUNC_DEFINED +#include <arpa/inet.h> uint32_t htonl(uint32_t hl) diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 2885dc331e087..c7ca87066c930 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #endif #include <arpa/nameser.h> #include "un-namespace.h" +#include "libc_private.h" extern int innetgr( const char *, const char *, const char *, const char * ); @@ -72,22 +73,15 @@ static int __icheckhost(const struct sockaddr *, socklen_t, const char *); char paddr[NI_MAXHOST]; int -rcmd(ahost, rport, locuser, remuser, cmd, fd2p) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; +rcmd(char **ahost, int rport, const char *locuser, const char *remuser, + const char *cmd, int *fd2p) { return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); } int -rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) - char **ahost; - u_short rport; - const char *locuser, *remuser, *cmd; - int *fd2p; - int af; +rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser, + const char *cmd, int *fd2p, int af) { struct addrinfo hints, *res, *ai; struct sockaddr_storage from; @@ -148,7 +142,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) refused = 0; sigemptyset(&newmask); sigaddset(&newmask, SIGURG); - _sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask); + __libc_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask); for (timo = 1, lport = IPPORT_RESERVED - 1;;) { s = rresvport_af(&lport, ai->ai_family); if (s < 0) { @@ -163,7 +157,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)fprintf(stderr, "rcmd: socket: %s\n", strerror(errno)); freeaddrinfo(res); - _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, + __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); return (-1); } @@ -181,7 +175,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)fprintf(stderr, "%s: %s\n", *ahost, strerror(errno)); freeaddrinfo(res); - _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, + __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); return (-1); } @@ -306,7 +300,7 @@ again: } goto bad2; } - _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); + __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); freeaddrinfo(res); return (s); bad2: @@ -314,21 +308,19 @@ bad2: (void)_close(*fd2p); bad: (void)_close(s); - _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); + __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); freeaddrinfo(res); return (-1); } int -rresvport(port) - int *port; +rresvport(int *port) { return rresvport_af(port, AF_INET); } int -rresvport_af(alport, family) - int *alport, family; +rresvport_af(int *alport, int family) { int s; struct sockaddr_storage ss; @@ -379,9 +371,7 @@ int __check_rhosts_file = 1; char *__rcmd_errstr; int -ruserok(rhost, superuser, ruser, luser) - const char *rhost, *ruser, *luser; - int superuser; +ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) { struct addrinfo hints, *res, *r; int error; @@ -414,10 +404,7 @@ ruserok(rhost, superuser, ruser, luser) * Returns 0 if ok, -1 if not ok. */ int -iruserok(raddr, superuser, ruser, luser) - unsigned long raddr; - int superuser; - const char *ruser, *luser; +iruserok(unsigned long raddr, int superuser, const char *ruser, const char *luser) { struct sockaddr_in sin; @@ -435,11 +422,8 @@ iruserok(raddr, superuser, ruser, luser) * Returns 0 if ok, -1 if not ok. */ int -iruserok_sa(ra, rlen, superuser, ruser, luser) - const void *ra; - int rlen; - int superuser; - const char *ruser, *luser; +iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser, + const char *luser) { char *cp; struct stat sbuf; @@ -519,10 +503,7 @@ again: * Returns 0 if ok, -1 if not ok. */ int -__ivaliduser(hostf, raddr, luser, ruser) - FILE *hostf; - u_int32_t raddr; - const char *luser, *ruser; +__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser) { struct sockaddr_in sin; @@ -540,11 +521,8 @@ __ivaliduser(hostf, raddr, luser, ruser) * XXX obsolete API. */ int -__ivaliduser_af(hostf, raddr, luser, ruser, af, len) - FILE *hostf; - const void *raddr; - const char *luser, *ruser; - int af, len; +__ivaliduser_af(FILE *hostf, const void *raddr, const char *luser, + const char *ruser, int af, int len) { struct sockaddr *sa = NULL; struct sockaddr_in *sin = NULL; @@ -583,11 +561,8 @@ __ivaliduser_af(hostf, raddr, luser, ruser, af, len) } int -__ivaliduser_sa(hostf, raddr, salen, luser, ruser) - FILE *hostf; - const struct sockaddr *raddr; - socklen_t salen; - const char *luser, *ruser; +__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen, + const char *luser, const char *ruser) { char *user, *p; int ch; @@ -706,10 +681,7 @@ __ivaliduser_sa(hostf, raddr, salen, luser, ruser) * Returns "true" if match, 0 if no match. */ static int -__icheckhost(raddr, salen, lhost) - const struct sockaddr *raddr; - socklen_t salen; - const char *lhost; +__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost) { struct sockaddr_in sin; struct sockaddr_in6 *sin6; diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index 6a584cadbff6e..68d3ce51015db 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -40,10 +40,7 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> ssize_t -recv(s, buf, len, flags) - int s, flags; - size_t len; - void *buf; +recv(int s, void *buf, size_t len, int flags) { /* * POSIX says recv() shall be a cancellation point, so call the diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c index f92fdec20a694..3b2ebbabd57e6 100644 --- a/lib/libc/net/rthdr.c +++ b/lib/libc/net/rthdr.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); */ size_t -inet6_rthdr_space(type, seg) - int type, seg; +inet6_rthdr_space(int type, int seg) { switch (type) { case IPV6_RTHDR_TYPE_0: @@ -67,9 +66,7 @@ inet6_rthdr_space(type, seg) } struct cmsghdr * -inet6_rthdr_init(bp, type) - void *bp; - int type; +inet6_rthdr_init(void *bp, int type) { struct cmsghdr *ch = (struct cmsghdr *)bp; struct ip6_rthdr *rthdr; @@ -98,10 +95,7 @@ inet6_rthdr_init(bp, type) /* ARGSUSED */ int -inet6_rthdr_add(cmsg, addr, flags) - struct cmsghdr *cmsg; - const struct in6_addr *addr; - u_int flags; +inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags) { struct ip6_rthdr *rthdr; @@ -143,9 +137,7 @@ inet6_rthdr_add(cmsg, addr, flags) /* ARGSUSED */ int -inet6_rthdr_lasthop(cmsg, flags) - struct cmsghdr *cmsg; - unsigned int flags; +inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags) { struct ip6_rthdr *rthdr; @@ -183,9 +175,7 @@ inet6_rthdr_lasthop(cmsg, flags) #if 0 int -inet6_rthdr_reverse(in, out) - const struct cmsghdr *in; - struct cmsghdr *out; +inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out) { return (-1); @@ -193,8 +183,7 @@ inet6_rthdr_reverse(in, out) #endif int -inet6_rthdr_segments(cmsg) - const struct cmsghdr *cmsg; +inet6_rthdr_segments(const struct cmsghdr *cmsg) { struct ip6_rthdr *rthdr; @@ -217,9 +206,7 @@ inet6_rthdr_segments(cmsg) } struct in6_addr * -inet6_rthdr_getaddr(cmsg, idx) - struct cmsghdr *cmsg; - int idx; +inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx) { struct ip6_rthdr *rthdr; @@ -249,9 +236,7 @@ inet6_rthdr_getaddr(cmsg, idx) } int -inet6_rthdr_getflags(cmsg, idx) - const struct cmsghdr *cmsg; - int idx; +inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx) { struct ip6_rthdr *rthdr; diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index c44f4b922a81e..ff984363300a7 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -40,10 +40,7 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> ssize_t -send(s, msg, len, flags) - int s, flags; - size_t len; - const void *msg; +send(int s, const void *msg, size_t len, int flags) { /* * POSIX says send() shall be a cancellation point, so call the diff --git a/lib/libc/net/sockatmark.c b/lib/libc/net/sockatmark.c index e416de80a9ca8..9337da5d5d304 100644 --- a/lib/libc/net/sockatmark.c +++ b/lib/libc/net/sockatmark.c @@ -24,13 +24,16 @@ * * $FreeBSD$ */ +#include "namespace.h" #include <sys/ioctl.h> +#include <sys/socket.h> +#include "un-namespace.h" int sockatmark(int s) { int atmark; - if (ioctl(s, SIOCATMARK, &atmark) == -1) + if (_ioctl(s, SIOCATMARK, &atmark) == -1) return -1; return atmark; } diff --git a/lib/libc/posix1e/acl_add_flag_np.3 b/lib/libc/posix1e/acl_add_flag_np.3 index db8e565a72d92..22048268706a8 100644 --- a/lib/libc/posix1e/acl_add_flag_np.3 +++ b/lib/libc/posix1e/acl_add_flag_np.3 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2014 +.Dd September 4, 2015 .Dt ACL_ADD_FLAG_NP 3 .Os .Sh NAME @@ -56,6 +56,7 @@ Valid values are: .It ACL_ENTRY_DIRECTORY_INHERIT Ta "Will be inherited by directories." .It ACL_ENTRY_NO_PROPAGATE_INHERIT Ta "Will not propagate." .It ACL_ENTRY_INHERIT_ONLY Ta "Inherit-only." +.It ACL_ENTRY_INHERITED Ta "Inherited from parent" .El .Sh RETURN VALUES .Rv -std acl_add_flag_np diff --git a/lib/libc/posix1e/acl_compat.c b/lib/libc/posix1e/acl_compat.c index c4339204f8cd1..ab1bdf6244cb3 100644 --- a/lib/libc/posix1e/acl_compat.c +++ b/lib/libc/posix1e/acl_compat.c @@ -29,6 +29,10 @@ __FBSDID("$FreeBSD$"); #include <sys/acl.h> +int __oldacl_get_perm_np(acl_permset_t, oldacl_perm_t); +int __oldacl_add_perm(acl_permset_t, oldacl_perm_t); +int __oldacl_delete_perm(acl_permset_t, oldacl_perm_t); + /* * Compatibility wrappers for applications compiled against libc from before * NFSv4 ACLs were added. diff --git a/lib/libc/posix1e/acl_entry.c b/lib/libc/posix1e/acl_entry.c index 3f8ca62c8b00e..2cffaa33d54cc 100644 --- a/lib/libc/posix1e/acl_entry.c +++ b/lib/libc/posix1e/acl_entry.c @@ -91,7 +91,7 @@ acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int offset) return (-1); } - if (offset < 0 || offset >= acl_int->acl_cnt) { + if (offset < 0 || offset > acl_int->acl_cnt) { errno = EINVAL; return (-1); } diff --git a/lib/libc/posix1e/acl_init.c b/lib/libc/posix1e/acl_init.c index 4fe403777ddb5..88a1fc5aaf1c3 100644 --- a/lib/libc/posix1e/acl_init.c +++ b/lib/libc/posix1e/acl_init.c @@ -67,8 +67,10 @@ acl_init(int count) error = posix_memalign((void *)&acl, 1 << _ACL_T_ALIGNMENT_BITS, sizeof(struct acl_t_struct)); - if (error) + if (error) { + errno = error; return (NULL); + } bzero(acl, sizeof(struct acl_t_struct)); acl->ats_brand = ACL_BRAND_UNKNOWN; diff --git a/lib/libc/posix1e/acl_strip.c b/lib/libc/posix1e/acl_strip.c index 85dfb4721a3c2..24fda84806468 100644 --- a/lib/libc/posix1e/acl_strip.c +++ b/lib/libc/posix1e/acl_strip.c @@ -107,13 +107,13 @@ _posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) if (acl_get_permset(entry, &perm) == -1) goto fail; if (acl_create_entry(&acl_new, &entry_new) == -1) - return (NULL); + goto fail; if (acl_set_tag_type(entry_new, tag) == -1) - return (NULL); + goto fail; if (acl_set_permset(entry_new, perm) == -1) - return (NULL); + goto fail; if (acl_copy_entry(entry_new, entry) == -1) - return (NULL); + goto fail; assert(_entry_brand(entry_new) == ACL_BRAND_POSIX); break; case ACL_MASK: @@ -122,20 +122,22 @@ _posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) default: break; } -fail: - acl_free(acl_new); - acl_free(acl_old); - return (NULL); } assert(_acl_brand(acl_new) == ACL_BRAND_POSIX); if (have_mask_entry && recalculate_mask) { if (acl_calc_mask(&acl_new) == -1) - return (NULL); + goto fail; } return (acl_new); + +fail: + acl_free(acl_new); + acl_free(acl_old); + + return (NULL); } acl_t diff --git a/lib/libc/posix1e/acl_support.h b/lib/libc/posix1e/acl_support.h index 11fa29bc4c86a..e7f35d5ad68c5 100644 --- a/lib/libc/posix1e/acl_support.h +++ b/lib/libc/posix1e/acl_support.h @@ -45,6 +45,8 @@ int _acl_brand_may_be(const acl_t acl, int brand); int _entry_brand_may_be(const acl_entry_t entry, int brand); void _acl_brand_as(acl_t acl, int brand); void _entry_brand_as(const acl_entry_t entry, int brand); +int _nfs4_acl_entry_from_text(acl_t, char *); +char *_nfs4_acl_to_text_np(const acl_t, ssize_t *, int); int _nfs4_format_flags(char *str, size_t size, acl_flag_t var, int verbose); int _nfs4_format_access_mask(char *str, size_t size, acl_perm_t var, int verbose); int _nfs4_parse_flags(const char *str, acl_flag_t *var); diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c index 4878b4387a8ec..1eece989ad3f2 100644 --- a/lib/libc/posix1e/acl_support_nfs4.c +++ b/lib/libc/posix1e/acl_support_nfs4.c @@ -48,6 +48,7 @@ struct flagnames_struct a_flags[] = { ACL_ENTRY_NO_PROPAGATE_INHERIT, "no_propagate", 'n'}, { ACL_ENTRY_SUCCESSFUL_ACCESS, "successfull_access", 'S'}, { ACL_ENTRY_FAILED_ACCESS, "failed_access", 'F'}, + { ACL_ENTRY_INHERITED, "inherited", 'I' }, /* * There is no ACE_IDENTIFIER_GROUP here - SunOS does not show it * in the "flags" field. There is no ACE_OWNER, ACE_GROUP or diff --git a/lib/libc/powerpc/gen/_set_tp.c b/lib/libc/powerpc/gen/_set_tp.c index aa1150a5dd163..eeb062f302170 100644 --- a/lib/libc/powerpc/gen/_set_tp.c +++ b/lib/libc/powerpc/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/powerpc64/gen/_set_tp.c b/lib/libc/powerpc64/gen/_set_tp.c index 32137e505d001..26009dcf97d06 100644 --- a/lib/libc/powerpc64/gen/_set_tp.c +++ b/lib/libc/powerpc64/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/resolv/h_errno.c b/lib/libc/resolv/h_errno.c index 88d15aee7f9cb..8ced7081ddffc 100644 --- a/lib/libc/resolv/h_errno.c +++ b/lib/libc/resolv/h_errno.c @@ -33,6 +33,9 @@ #undef h_errno extern int h_errno; +int *__h_errno(void); +void __h_errno_set(res_state res, int err); + int * __h_errno(void) { diff --git a/lib/libc/resolv/res_debug.c b/lib/libc/resolv/res_debug.c index 8ab02630f5230..37646016eb73f 100644 --- a/lib/libc/resolv/res_debug.c +++ b/lib/libc/resolv/res_debug.c @@ -367,11 +367,8 @@ p_cdname(const u_char *cp, const u_char *msg, FILE *file) { length supplied). */ const u_char * -p_fqnname(cp, msg, msglen, name, namelen) - const u_char *cp, *msg; - int msglen; - char *name; - int namelen; +p_fqnname(const u_char *cp, const u_char *msg, int msglen, char *name, + int namelen) { int n, newlen; @@ -758,8 +755,7 @@ static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, /*% takes an XeY precision/size value, returns a string representation. */ static const char * -precsize_ntoa(prec) - u_int8_t prec; +precsize_ntoa(u_int8_t prec) { char *retbuf = precsize_ntoa_retbuf; unsigned long val; @@ -912,9 +908,7 @@ latlon2ul(const char **latlonstrptr, int *which) { * converts a zone file representation in a string to an RDATA on-the-wire * representation. */ int -loc_aton(ascii, binary) - const char *ascii; - u_char *binary; +loc_aton(const char *ascii, u_char *binary) { const char *cp, *maxcp; u_char *bcp; @@ -1023,9 +1017,7 @@ loc_aton(ascii, binary) /*% takes an on-the-wire LOC RR and formats it in a human readable format. */ const char * -loc_ntoa(binary, ascii) - const u_char *binary; - char *ascii; +loc_ntoa(const u_char *binary, char *ascii) { static const char *error = "?"; static char tmpbuf[sizeof diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c index b5444ef364bc2..4dbd6d1caca27 100644 --- a/lib/libc/resolv/res_init.c +++ b/lib/libc/resolv/res_init.c @@ -718,8 +718,7 @@ res_setoptions(res_state statp, const char *options, const char *source) #ifdef RESOLVSORT /* XXX - should really support CIDR which means explicit masks always. */ static u_int32_t -net_mask(in) /*!< XXX - should really use system's version of this */ - struct in_addr in; +net_mask(struct in_addr in) /*!< XXX - should really use system's version of this */ { u_int32_t i = ntohl(in.s_addr); diff --git a/lib/libc/resolv/res_mkupdate.c b/lib/libc/resolv/res_mkupdate.c index 00bce4c53ccb2..d4981a56328f5 100644 --- a/lib/libc/resolv/res_mkupdate.c +++ b/lib/libc/resolv/res_mkupdate.c @@ -973,7 +973,7 @@ struct valuelist { static struct valuelist *servicelist, *protolist; static void -res_buildservicelist() { +res_buildservicelist(void) { struct servent *sp; struct valuelist *slp; diff --git a/lib/libc/resolv/res_send.c b/lib/libc/resolv/res_send.c index fd1cd06baff56..56904915544c0 100644 --- a/lib/libc/resolv/res_send.c +++ b/lib/libc/resolv/res_send.c @@ -574,8 +574,7 @@ res_nsend(res_state statp, /* Private */ static int -get_salen(sa) - const struct sockaddr *sa; +get_salen(const struct sockaddr *sa) { #ifdef HAVE_SA_LEN @@ -596,9 +595,7 @@ get_salen(sa) * pick appropriate nsaddr_list for use. see res_init() for initialization. */ static struct sockaddr * -get_nsaddr(statp, n) - res_state statp; - size_t n; +get_nsaddr(res_state statp, size_t n) { if (!statp->nsaddr_list[n].sin_family && EXT(statp).ext) { diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c index 1bc26615b5d40..5435e7749fdf5 100644 --- a/lib/libc/rpc/auth_des.c +++ b/lib/libc/rpc/auth_des.c @@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$"); extern bool_t xdr_authdes_cred( XDR *, struct authdes_cred *); extern bool_t xdr_authdes_verf( XDR *, struct authdes_verf *); -extern int key_encryptsession_pk(); +extern int key_encryptsession_pk(char *, netobj *, des_block *); extern bool_t __rpc_get_time_offset(struct timeval *, nis_server *, char *, char **, char **); @@ -259,7 +259,7 @@ failed: */ /*ARGSUSED*/ static void -authdes_nextverf(AUTH *auth) +authdes_nextverf(AUTH *auth __unused) { /* what the heck am I supposed to do??? */ } @@ -420,7 +420,7 @@ authdes_validate(AUTH *auth, struct opaque_auth *rverf) */ /*ARGSUSED*/ static bool_t -authdes_refresh(AUTH *auth, void *dummy) +authdes_refresh(AUTH *auth, void *dummy __unused) { /* LINTED pointer alignment */ struct ad_private *ad = AUTH_PRIVATE(auth); diff --git a/lib/libc/rpc/auth_none.c b/lib/libc/rpc/auth_none.c index 311fa5581bb69..0b846ebc9b180 100644 --- a/lib/libc/rpc/auth_none.c +++ b/lib/libc/rpc/auth_none.c @@ -65,9 +65,9 @@ static bool_t authnone_validate (AUTH *, struct opaque_auth *); static bool_t authnone_refresh (AUTH *, void *); static void authnone_destroy (AUTH *); -extern bool_t xdr_opaque_auth(); +extern bool_t xdr_opaque_auth(XDR *, struct opaque_auth *); -static struct auth_ops *authnone_ops(); +static struct auth_ops *authnone_ops(void); static struct authnone_private { AUTH no_client; @@ -76,7 +76,7 @@ static struct authnone_private { } *authnone_private; AUTH * -authnone_create() +authnone_create(void) { struct authnone_private *ap = authnone_private; XDR xdr_stream; @@ -156,7 +156,7 @@ authnone_destroy(AUTH *client) } static struct auth_ops * -authnone_ops() +authnone_ops(void) { static struct auth_ops ops; diff --git a/lib/libc/rpc/auth_time.c b/lib/libc/rpc/auth_time.c index 7aea23268a571..4b714468b92e2 100644 --- a/lib/libc/rpc/auth_time.c +++ b/lib/libc/rpc/auth_time.c @@ -61,8 +61,7 @@ extern int _rpc_dtablesize( void ); static int saw_alarm = 0; static void -alarm_hndler(s) - int s; +alarm_hndler(int s) { saw_alarm = 1; return; @@ -83,12 +82,7 @@ alarm_hndler(s) * Turn a 'universal address' into a struct sockaddr_in. * Bletch. */ -static int uaddr_to_sockaddr(uaddr, sin) -#ifdef foo - endpoint *endpt; -#endif - char *uaddr; - struct sockaddr_in *sin; +static int uaddr_to_sockaddr(char *uaddr, struct sockaddr_in *sin) { unsigned char p_bytes[2]; int i; @@ -118,9 +112,7 @@ static int uaddr_to_sockaddr(uaddr, sin) * Free the strings that were strduped into the eps structure. */ static void -free_eps(eps, num) - endpoint eps[]; - int num; +free_eps(endpoint eps[], int num) { int i; @@ -142,14 +134,15 @@ free_eps(eps, num) * fact that gethostbyname() could do an NIS search. Ideally, the * NIS+ server will call __rpc_get_time_offset() with the nis_server * structure already populated. + * + * host - name of the time host + * srv - nis_server struct to use. + * eps[] - array of endpoints + * maxep - max array size */ static nis_server * -get_server(sin, host, srv, eps, maxep) - struct sockaddr_in *sin; - char *host; /* name of the time host */ - nis_server *srv; /* nis_server struct to use. */ - endpoint eps[]; /* array of endpoints */ - int maxep; /* max array size */ +get_server(struct sockaddr_in *sin, char *host, nis_server *srv, + endpoint eps[], int maxep) { char hname[256]; int num_ep = 0, i; @@ -236,14 +229,16 @@ get_server(sin, host, srv, eps, maxep) * structure and to then contact the machine for the time. * * td = "server" - "client" + * + * td - Time difference + * srv - NIS Server description + * thost - if no server, this is the timehost + * uaddr - known universal address + * netid - known network identifier */ int -__rpc_get_time_offset(td, srv, thost, uaddr, netid) - struct timeval *td; /* Time difference */ - nis_server *srv; /* NIS Server description */ - char *thost; /* if no server, this is the timehost */ - char **uaddr; /* known universal address */ - struct sockaddr_in *netid; /* known network identifier */ +__rpc_get_time_offset(struct timeval *td, nis_server *srv, char *thost, + char **uaddr, struct sockaddr_in *netid) { CLIENT *clnt; /* Client handle */ endpoint *ep, /* useful endpoints */ @@ -260,7 +255,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) char ut[64], ipuaddr[64]; endpoint teps[32]; nis_server tsrv; - void (*oldsig)() = NULL; /* old alarm handler */ + void (*oldsig)(int) = NULL; /* old alarm handler */ struct sockaddr_in sin; socklen_t len; int s = RPC_ANYSOCK; @@ -429,7 +424,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) } else { int res; - oldsig = (void (*)())signal(SIGALRM, alarm_hndler); + oldsig = (void (*)(int))signal(SIGALRM, alarm_hndler); saw_alarm = 0; /* global tracking the alarm */ alarm(20); /* only wait 20 seconds */ res = _connect(s, (struct sockaddr *)&sin, sizeof(sin)); diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 1ec543046d341..14043358e3586 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -91,12 +91,7 @@ struct audata { * Returns an auth handle with the given stuff in it. */ AUTH * -authunix_create(machname, uid, gid, len, aup_gids) - char *machname; - u_int uid; - u_int gid; - int len; - u_int *aup_gids; +authunix_create(char *machname, u_int uid, u_int gid, int len, u_int *aup_gids) { struct authunix_parms aup; char mymem[MAX_AUTH_BYTES]; @@ -182,7 +177,7 @@ authunix_create(machname, uid, gid, len, aup_gids) * syscalls. */ AUTH * -authunix_create_default() +authunix_create_default(void) { AUTH *auth; int ngids; @@ -218,16 +213,13 @@ authunix_create_default() /* ARGSUSED */ static void -authunix_nextverf(auth) - AUTH *auth; +authunix_nextverf(AUTH *auth) { /* no action necessary */ } static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; +authunix_marshal(AUTH *auth, XDR *xdrs) { struct audata *au; @@ -239,9 +231,7 @@ authunix_marshal(auth, xdrs) } static bool_t -authunix_validate(auth, verf) - AUTH *auth; - struct opaque_auth *verf; +authunix_validate(AUTH *auth, struct opaque_auth *verf) { struct audata *au; XDR xdrs; @@ -317,8 +307,7 @@ done: } static void -authunix_destroy(auth) - AUTH *auth; +authunix_destroy(AUTH *auth) { struct audata *au; @@ -343,8 +332,7 @@ authunix_destroy(auth) * sets private data, au_marshed and au_mpos */ static void -marshal_new_auth(auth) - AUTH *auth; +marshal_new_auth(AUTH *auth) { XDR xdr_stream; XDR *xdrs = &xdr_stream; @@ -363,7 +351,7 @@ marshal_new_auth(auth) } static struct auth_ops * -authunix_ops() +authunix_ops(void) { static struct auth_ops ops; diff --git a/lib/libc/rpc/authdes_prot.c b/lib/libc/rpc/authdes_prot.c index ae129737c4cca..0d4bec06264ac 100644 --- a/lib/libc/rpc/authdes_prot.c +++ b/lib/libc/rpc/authdes_prot.c @@ -49,9 +49,7 @@ __FBSDID("$FreeBSD$"); #define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) bool_t -xdr_authdes_cred(xdrs, cred) - XDR *xdrs; - struct authdes_cred *cred; +xdr_authdes_cred(XDR *xdrs, struct authdes_cred *cred) { enum authdes_namekind *padc_namekind = &cred->adc_namekind; /* @@ -78,9 +76,7 @@ xdr_authdes_cred(xdrs, cred) bool_t -xdr_authdes_verf(xdrs, verf) - XDR *xdrs; - struct authdes_verf *verf; +xdr_authdes_verf(XDR *xdrs, struct authdes_verf *verf) { /* * Unrolled xdr diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index 42a5fad80212f..cd6676bda2b33 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -55,9 +55,7 @@ __FBSDID("$FreeBSD$"); * XDR for unix authentication parameters. */ bool_t -xdr_authunix_parms(xdrs, p) - XDR *xdrs; - struct authunix_parms *p; +xdr_authunix_parms(XDR *xdrs, struct authunix_parms *p) { u_int **paup_gids; diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c index c8b164699affc..8629cba5ea394 100644 --- a/lib/libc/rpc/bindresvport.c +++ b/lib/libc/rpc/bindresvport.c @@ -61,9 +61,7 @@ __FBSDID("$FreeBSD$"); * Bind a socket to a privileged IP port */ int -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; +bindresvport(int sd, struct sockaddr_in *sin) { return bindresvport_sa(sd, (struct sockaddr *)sin); } @@ -72,9 +70,7 @@ bindresvport(sd, sin) * Bind a socket to a privileged IP port */ int -bindresvport_sa(sd, sa) - int sd; - struct sockaddr *sa; +bindresvport_sa(int sd, struct sockaddr *sa) { int old, error, af; struct sockaddr_storage myaddr; diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c index 6ee1f909270c2..7242aa4b68df0 100644 --- a/lib/libc/rpc/clnt_bcast.c +++ b/lib/libc/rpc/clnt_bcast.c @@ -225,21 +225,26 @@ __rpc_broadenable(int af, int s, struct broadif *bip) return 0; } - +/* + * rpc_broadcast_exp() + * + * prog - program number + * vers - version number + * proc - procedure number + * xargs - xdr routine for args + * argsp - pointer to args + * xresults - xdr routine for results + * resultsp - pointer to results + * eachresult - call with each result obtained + * inittime - how long to wait initially + * waittime - maximum time to wait + * nettype - transport type + */ enum clnt_stat -rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, - eachresult, inittime, waittime, nettype) - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ - int inittime; /* how long to wait initially */ - int waittime; /* maximum time to wait */ - const char *nettype; /* transport type */ +rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, + xdrproc_t xargs, caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, + resultproc_t eachresult, int inittime, int waittime, + const char *nettype) { enum clnt_stat stat = RPC_SUCCESS; /* Return status */ XDR xdr_stream; /* XDR stream */ @@ -251,7 +256,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, int inlen; u_int maxbufsize = 0; AUTH *sys_auth = authunix_create_default(); - int i; + u_int i; void *handle; char uaddress[1024]; /* A self imposed limit */ char *uaddrp = uaddress; @@ -649,19 +654,23 @@ done_broad: return (stat); } - +/* + * rpc_broadcast() + * + * prog - program number + * vers - version number + * proc - procedure number + * xargs - xdr routine for args + * argsp - pointer to args + * xresults - xdr routine for results + * resultsp - pointer to results + * eachresult - call with each result obtained + * nettype - transport type + */ enum clnt_stat -rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, - eachresult, nettype) - rpcprog_t prog; /* program number */ - rpcvers_t vers; /* version number */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - caddr_t argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - caddr_t resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ - const char *nettype; /* transport type */ +rpc_broadcast(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, xdrproc_t xargs, + caddr_t argsp, xdrproc_t xresults, caddr_t resultsp, + resultproc_t eachresult, const char *nettype) { enum clnt_stat dummy; diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index cebbaf9e344f0..274a255ea2fc7 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -153,15 +153,17 @@ struct cu_data { * If they are 0, use the transport default. * * If svcaddr is NULL, returns NULL. + * + * fd - open file descriptor + * svcaddr - servers address + * program - program number + * version - version number + * sendsz - buffer recv size + * recvsz - buffer send size */ CLIENT * -clnt_dg_create(fd, svcaddr, program, version, sendsz, recvsz) - int fd; /* open file descriptor */ - const struct netbuf *svcaddr; /* servers address */ - rpcprog_t program; /* program number */ - rpcvers_t version; /* version number */ - u_int sendsz; /* buffer recv size */ - u_int recvsz; /* buffer send size */ +clnt_dg_create(int fd, const struct netbuf *svcaddr, rpcprog_t program, + rpcvers_t version, u_int sendsz, u_int recvsz) { CLIENT *cl = NULL; /* client handle */ struct cu_data *cu = NULL; /* private data */ @@ -301,15 +303,18 @@ err2: return (NULL); } +/* + * cl - client handle + * proc - procedure number + * xargs - xdr routine for args + * argsp - pointer to args + * xresults - xdr routine for results + * resultsp - pointer to results + * utimeout - seconds to wait before giving up + */ static enum clnt_stat -clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout) - CLIENT *cl; /* client handle */ - rpcproc_t proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - void *argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - void *resultsp; /* pointer to results */ - struct timeval utimeout; /* seconds to wait before giving up */ +clnt_dg_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xargs, void *argsp, + xdrproc_t xresults, void *resultsp, struct timeval utimeout) { struct cu_data *cu = (struct cu_data *)cl->cl_private; XDR *xdrs; @@ -602,9 +607,7 @@ out: } static void -clnt_dg_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; +clnt_dg_geterr(CLIENT *cl, struct rpc_err *errp) { struct cu_data *cu = (struct cu_data *)cl->cl_private; @@ -612,10 +615,7 @@ clnt_dg_geterr(cl, errp) } static bool_t -clnt_dg_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; +clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) { struct cu_data *cu = (struct cu_data *)cl->cl_private; XDR *xdrs = &(cu->cu_outxdrs); @@ -638,16 +638,12 @@ clnt_dg_freeres(cl, xdr_res, res_ptr) /*ARGSUSED*/ static void -clnt_dg_abort(h) - CLIENT *h; +clnt_dg_abort(CLIENT *h) { } static bool_t -clnt_dg_control(cl, request, info) - CLIENT *cl; - u_int request; - void *info; +clnt_dg_control(CLIENT *cl, u_int request, void *info) { struct cu_data *cu = (struct cu_data *)cl->cl_private; struct netbuf *addr; @@ -790,8 +786,7 @@ clnt_dg_control(cl, request, info) } static void -clnt_dg_destroy(cl) - CLIENT *cl; +clnt_dg_destroy(CLIENT *cl) { struct cu_data *cu = (struct cu_data *)cl->cl_private; int cu_fd = cu->cu_fd; @@ -820,7 +815,7 @@ clnt_dg_destroy(cl) } static struct clnt_ops * -clnt_dg_ops() +clnt_dg_ops(void) { static struct clnt_ops ops; sigset_t mask; @@ -848,8 +843,7 @@ clnt_dg_ops() * Make sure that the time is not garbage. -1 value is allowed. */ static bool_t -time_not_ok(t) - struct timeval *t; +time_not_ok(struct timeval *t) { return (t->tv_sec < -1 || t->tv_sec > 100000000 || t->tv_usec < -1 || t->tv_usec > 1000000); diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index 5d87b0cbc14c5..15d72803df71c 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -61,7 +61,7 @@ static char *auth_errmsg(enum auth_stat); #define CLNT_PERROR_BUFLEN 256 static char * -_buf() +_buf(void) { if (buf == 0) @@ -73,9 +73,7 @@ _buf() * Print reply error info */ char * -clnt_sperror(rpch, s) - CLIENT *rpch; - const char *s; +clnt_sperror(CLIENT *rpch, const char *s) { struct rpc_err e; char *err; @@ -180,9 +178,7 @@ clnt_sperror(rpch, s) } void -clnt_perror(rpch, s) - CLIENT *rpch; - const char *s; +clnt_perror(CLIENT *rpch, const char *s) { assert(rpch != NULL); @@ -217,8 +213,7 @@ static const char *const rpc_errlist[] = { * This interface for use by clntrpc */ char * -clnt_sperrno(stat) - enum clnt_stat stat; +clnt_sperrno(enum clnt_stat stat) { unsigned int errnum = stat; @@ -230,16 +225,14 @@ clnt_sperrno(stat) } void -clnt_perrno(num) - enum clnt_stat num; +clnt_perrno(enum clnt_stat num) { (void) fprintf(stderr, "%s\n", clnt_sperrno(num)); } char * -clnt_spcreateerror(s) - const char *s; +clnt_spcreateerror(const char *s) { char *str; size_t len, i; @@ -291,8 +284,7 @@ clnt_spcreateerror(s) } void -clnt_pcreateerror(s) - const char *s; +clnt_pcreateerror(const char *s) { assert(s != NULL); @@ -319,8 +311,7 @@ static const char *const auth_errlist[] = { }; static char * -auth_errmsg(stat) - enum auth_stat stat; +auth_errmsg(enum auth_stat stat) { unsigned int errnum = stat; diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c index 26e2856f2823b..ad641127ff8a1 100644 --- a/lib/libc/rpc/clnt_raw.c +++ b/lib/libc/rpc/clnt_raw.c @@ -87,9 +87,7 @@ static struct clnt_ops *clnt_raw_ops(void); * Create a client handle for memory based rpc. */ CLIENT * -clnt_raw_create(prog, vers) - rpcprog_t prog; - rpcvers_t vers; +clnt_raw_create(rpcprog_t prog, rpcvers_t vers) { struct clntraw_private *clp; struct rpc_msg call_msg; @@ -142,14 +140,8 @@ clnt_raw_create(prog, vers) /* ARGSUSED */ static enum clnt_stat -clnt_raw_call(h, proc, xargs, argsp, xresults, resultsp, timeout) - CLIENT *h; - rpcproc_t proc; - xdrproc_t xargs; - void *argsp; - xdrproc_t xresults; - void *resultsp; - struct timeval timeout; +clnt_raw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, void *argsp, + xdrproc_t xresults, void *resultsp, struct timeval timeout) { struct clntraw_private *clp = clntraw_private; XDR *xdrs = &clp->xdr_stream; @@ -240,19 +232,14 @@ call_again: /*ARGSUSED*/ static void -clnt_raw_geterr(cl, err) - CLIENT *cl; - struct rpc_err *err; +clnt_raw_geterr(CLIENT *cl, struct rpc_err *err) { } /* ARGSUSED */ static bool_t -clnt_raw_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; +clnt_raw_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) { struct clntraw_private *clp = clntraw_private; XDR *xdrs = &clp->xdr_stream; @@ -271,30 +258,25 @@ clnt_raw_freeres(cl, xdr_res, res_ptr) /*ARGSUSED*/ static void -clnt_raw_abort(cl) - CLIENT *cl; +clnt_raw_abort(CLIENT *cl) { } /*ARGSUSED*/ static bool_t -clnt_raw_control(cl, ui, str) - CLIENT *cl; - u_int ui; - void *str; +clnt_raw_control(CLIENT *cl, u_int ui, void *str) { return (FALSE); } /*ARGSUSED*/ static void -clnt_raw_destroy(cl) - CLIENT *cl; +clnt_raw_destroy(CLIENT *cl) { } static struct clnt_ops * -clnt_raw_ops() +clnt_raw_ops(void) { static struct clnt_ops ops; diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index 3541205725607..4fc374ad6a339 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -107,17 +107,19 @@ rpc_call_key_init(void) * the future calls to same prog, vers, host and nettype combination. * * The total time available is 25 seconds. + * + * host - host name + * prognum - program number + * versnum - version number + * procnum - procedure number + * inproc, outproc - in/out XDR procedures + * in, out - recv/send data + * nettype - nettype */ enum clnt_stat -rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) - const char *host; /* host name */ - rpcprog_t prognum; /* program number */ - rpcvers_t versnum; /* version number */ - rpcproc_t procnum; /* procedure number */ - xdrproc_t inproc, outproc; /* in/out XDR procedures */ - const char *in; - char *out; /* recv/send data */ - const char *nettype; /* nettype */ +rpc_call(const char *host, const rpcprog_t prognum, const rpcvers_t versnum, + const rpcproc_t procnum, const xdrproc_t inproc, const char *in, + const xdrproc_t outproc, char *out, const char *nettype) { struct rpc_call_private *rcp = (struct rpc_call_private *) 0; enum clnt_stat clnt_stat; diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index b15d69bff7a55..e463165069dd7 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -153,15 +153,17 @@ static const char __no_mem_str[] = "out of memory"; * set this something more useful. * * fd should be an open socket + * + * fd - open file descriptor + * raddr - servers address + * prog - program number + * vers - version number + * sendsz - buffer send size + * recvsz - buffer recv size */ CLIENT * -clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) - int fd; /* open file descriptor */ - const struct netbuf *raddr; /* servers address */ - const rpcprog_t prog; /* program number */ - const rpcvers_t vers; /* version number */ - u_int sendsz; /* buffer recv size */ - u_int recvsz; /* buffer send size */ +clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog, + const rpcvers_t vers, u_int sendsz, u_int recvsz) { CLIENT *cl; /* client handle */ struct ct_data *ct = NULL; /* client handle */ @@ -311,14 +313,8 @@ err: } static enum clnt_stat -clnt_vc_call(cl, proc, xdr_args, args_ptr, xdr_results, results_ptr, timeout) - CLIENT *cl; - rpcproc_t proc; - xdrproc_t xdr_args; - void *args_ptr; - xdrproc_t xdr_results; - void *results_ptr; - struct timeval timeout; +clnt_vc_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xdr_args, void *args_ptr, + xdrproc_t xdr_results, void *results_ptr, struct timeval timeout) { struct ct_data *ct = (struct ct_data *) cl->cl_private; XDR *xdrs = &(ct->ct_xdrs); @@ -461,9 +457,7 @@ call_again: } static void -clnt_vc_geterr(cl, errp) - CLIENT *cl; - struct rpc_err *errp; +clnt_vc_geterr(CLIENT *cl, struct rpc_err *errp) { struct ct_data *ct; @@ -475,10 +469,7 @@ clnt_vc_geterr(cl, errp) } static bool_t -clnt_vc_freeres(cl, xdr_res, res_ptr) - CLIENT *cl; - xdrproc_t xdr_res; - void *res_ptr; +clnt_vc_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr) { struct ct_data *ct; XDR *xdrs; @@ -507,16 +498,12 @@ clnt_vc_freeres(cl, xdr_res, res_ptr) /*ARGSUSED*/ static void -clnt_vc_abort(cl) - CLIENT *cl; +clnt_vc_abort(CLIENT *cl) { } static bool_t -clnt_vc_control(cl, request, info) - CLIENT *cl; - u_int request; - void *info; +clnt_vc_control(CLIENT *cl, u_int request, void *info) { struct ct_data *ct; void *infop = info; @@ -644,8 +631,7 @@ clnt_vc_control(cl, request, info) static void -clnt_vc_destroy(cl) - CLIENT *cl; +clnt_vc_destroy(CLIENT *cl) { struct ct_data *ct = (struct ct_data *) cl->cl_private; int ct_fd = ct->ct_fd; @@ -684,10 +670,7 @@ clnt_vc_destroy(cl) * around for the rpc level. */ static int -read_vc(ctp, buf, len) - void *ctp; - void *buf; - int len; +read_vc(void *ctp, void *buf, int len) { struct sockaddr sa; socklen_t sal; @@ -741,10 +724,7 @@ read_vc(ctp, buf, len) } static int -write_vc(ctp, buf, len) - void *ctp; - void *buf; - int len; +write_vc(void *ctp, void *buf, int len) { struct sockaddr sa; socklen_t sal; @@ -775,7 +755,7 @@ write_vc(ctp, buf, len) } static struct clnt_ops * -clnt_vc_ops() +clnt_vc_ops(void) { static struct clnt_ops ops; sigset_t mask, newmask; @@ -803,18 +783,14 @@ clnt_vc_ops() * Note this is different from time_not_ok in clnt_dg.c */ static bool_t -time_not_ok(t) - struct timeval *t; +time_not_ok(struct timeval *t) { return (t->tv_sec <= -1 || t->tv_sec > 100000000 || t->tv_usec <= -1 || t->tv_usec > 1000000); } static int -__msgread(sock, buf, cnt) - int sock; - void *buf; - size_t cnt; +__msgread(int sock, void *buf, size_t cnt) { struct iovec iov[1]; struct msghdr msg; @@ -839,10 +815,7 @@ __msgread(sock, buf, cnt) } static int -__msgwrite(sock, buf, cnt) - int sock; - void *buf; - size_t cnt; +__msgwrite(int sock, void *buf, size_t cnt) { struct iovec iov[1]; struct msghdr msg; diff --git a/lib/libc/rpc/crypt_client.c b/lib/libc/rpc/crypt_client.c index 5290021a3341b..b7f0d1fff48c8 100644 --- a/lib/libc/rpc/crypt_client.c +++ b/lib/libc/rpc/crypt_client.c @@ -43,10 +43,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" int -_des_crypt_call(buf, len, dparms) - char *buf; - int len; - struct desparams *dparms; +_des_crypt_call(char *buf, int len, struct desparams *dparms) { CLIENT *clnt; desresp *result_1; diff --git a/lib/libc/rpc/des_crypt.c b/lib/libc/rpc/des_crypt.c index ace8ed6ce129a..236e9ed87ff30 100644 --- a/lib/libc/rpc/des_crypt.c +++ b/lib/libc/rpc/des_crypt.c @@ -41,7 +41,7 @@ static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02 __FBSDID("$FreeBSD$"); static int common_crypt( char *, char *, unsigned, unsigned, struct desparams * ); -int (*__des_crypt_LOCAL)() = 0; +int (*__des_crypt_LOCAL)(char *, unsigned, struct desparams *) = 0; extern int _des_crypt_call(char *, int, struct desparams *); /* * Copy 8 bytes @@ -70,12 +70,7 @@ extern int _des_crypt_call(char *, int, struct desparams *); * CBC mode encryption */ int -cbc_crypt(key, buf, len, mode, ivec) - char *key; - char *buf; - unsigned len; - unsigned mode; - char *ivec; +cbc_crypt(char *key, char *buf, unsigned len, unsigned mode, char *ivec) { int err; struct desparams dp; @@ -97,11 +92,7 @@ cbc_crypt(key, buf, len, mode, ivec) * ECB mode encryption */ int -ecb_crypt(key, buf, len, mode) - char *key; - char *buf; - unsigned len; - unsigned mode; +ecb_crypt(char *key, char *buf, unsigned len, unsigned mode) { struct desparams dp; @@ -120,12 +111,8 @@ ecb_crypt(key, buf, len, mode) * Common code to cbc_crypt() & ecb_crypt() */ static int -common_crypt(key, buf, len, mode, desp) - char *key; - char *buf; - unsigned len; - unsigned mode; - struct desparams *desp; +common_crypt(char *key, char *buf, unsigned len, unsigned mode, + struct desparams *desp) { int desdev; diff --git a/lib/libc/rpc/des_soft.c b/lib/libc/rpc/des_soft.c index 80d8c5241a011..5eb99151c0e03 100644 --- a/lib/libc/rpc/des_soft.c +++ b/lib/libc/rpc/des_soft.c @@ -58,8 +58,7 @@ static char partab[128] = { * Add odd parity to low bit of 8 byte key */ void -des_setparity(p) - char *p; +des_setparity(char *p) { int i; diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c index 34be6e1dc37e1..c1e22da52e468 100644 --- a/lib/libc/rpc/getnetconfig.c +++ b/lib/libc/rpc/getnetconfig.c @@ -147,7 +147,7 @@ nc_key_init(void) #define MAXNETCONFIGLINE 1000 static int * -__nc_error() +__nc_error(void) { static int nc_error = 0; int *nc_addr; @@ -194,7 +194,7 @@ __nc_error() * the netconfig database is not present). */ void * -setnetconfig() +setnetconfig(void) { struct netconfig_vars *nc_vars; @@ -240,8 +240,7 @@ setnetconfig() */ struct netconfig * -getnetconfig(handlep) -void *handlep; +getnetconfig(void *handlep) { struct netconfig_vars *ncp = (struct netconfig_vars *)handlep; char *stringp; /* tmp string pointer */ @@ -378,8 +377,7 @@ void *handlep; * previously). */ int -endnetconfig(handlep) -void *handlep; +endnetconfig(void *handlep) { struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep; @@ -444,8 +442,7 @@ void *handlep; */ struct netconfig * -getnetconfigent(netid) - const char *netid; +getnetconfigent(const char *netid) { FILE *file; /* NETCONFIG db's file pointer */ char *linep; /* holds current netconfig line */ @@ -536,8 +533,7 @@ getnetconfigent(netid) */ void -freenetconfigent(netconfigp) - struct netconfig *netconfigp; +freenetconfigent(struct netconfig *netconfigp) { if (netconfigp != NULL) { free(netconfigp->nc_netid); /* holds all netconfigp's strings */ @@ -558,12 +554,13 @@ freenetconfigent(netconfigp) * Note that we modify stringp (putting NULLs after tokens) and * we set the ncp's string field pointers to point to these tokens within * stringp. + * + * stringp - string to parse + * ncp - where to put results */ static int -parse_ncp(stringp, ncp) -char *stringp; /* string to parse */ -struct netconfig *ncp; /* where to put results */ +parse_ncp(char *stringp, struct netconfig *ncp) { char *tokenp; /* for processing tokens */ char *lasts; @@ -655,7 +652,7 @@ struct netconfig *ncp; /* where to put results */ * Returns a string describing the reason for failure. */ char * -nc_sperror() +nc_sperror(void) { const char *message; @@ -686,8 +683,7 @@ nc_sperror() * Prints a message onto standard error describing the reason for failure. */ void -nc_perror(s) - const char *s; +nc_perror(const char *s) { fprintf(stderr, "%s: %s\n", s, nc_sperror()); } @@ -696,8 +692,7 @@ nc_perror(s) * Duplicates the matched netconfig buffer. */ static struct netconfig * -dup_ncp(ncp) -struct netconfig *ncp; +dup_ncp(struct netconfig *ncp) { struct netconfig *p; char *tmp; diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c index 29155c7afc700..ce2984bc002b5 100644 --- a/lib/libc/rpc/getnetpath.c +++ b/lib/libc/rpc/getnetpath.c @@ -82,7 +82,7 @@ char *_get_next_token(char *, int); */ void * -setnetpath() +setnetpath(void) { struct netpath_vars *np_sessionp; /* this session's variables */ @@ -141,8 +141,7 @@ failed: */ struct netconfig * -getnetpath(handlep) - void *handlep; +getnetpath(void *handlep) { struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep; struct netconfig *ncp = NULL; /* temp. holds a netconfig session */ @@ -197,8 +196,7 @@ getnetpath(handlep) * (e.g. if setnetpath() was not called previously. */ int -endnetpath(handlep) - void *handlep; +endnetpath(void *handlep) { struct netpath_vars *np_sessionp = (struct netpath_vars *)handlep; struct netpath_chain *chainp, *lastp; @@ -231,12 +229,12 @@ endnetpath(handlep) * Returns pointer to the rest-of-the-string after the current token. * The token itself starts at arg, and we null terminate it. We return NULL * if either the arg is empty, or if this is the last token. + * + * npp - string + * token - char to parse string for */ - char * -_get_next_token(npp, token) -char *npp; /* string */ -int token; /* char to parse string for */ +_get_next_token(char *npp, int token) { char *cp; /* char pointer */ char *np; /* netpath pointer */ diff --git a/lib/libc/rpc/getpublickey.c b/lib/libc/rpc/getpublickey.c index 143c0fcaeb04e..4c806856629b0 100644 --- a/lib/libc/rpc/getpublickey.c +++ b/lib/libc/rpc/getpublickey.c @@ -56,15 +56,13 @@ __FBSDID("$FreeBSD$"); /* * Hack to let ypserv/rpc.nisd use AUTH_DES. */ -int (*__getpublickey_LOCAL)() = 0; +int (*__getpublickey_LOCAL)(const char *, char *) = 0; /* * Get somebody's public key */ static int -__getpublickey_real(netname, publickey) - const char *netname; - char *publickey; +__getpublickey_real(const char *netname, char *publickey) { char lookup[3 * HEXKEYBYTES]; char *p; @@ -89,9 +87,7 @@ __getpublickey_real(netname, publickey) */ int -getpublicandprivatekey(key, ret) - const char *key; - char *ret; +getpublicandprivatekey(const char *key, char *ret) { char buf[1024]; /* big enough */ char *res; @@ -166,9 +162,7 @@ getpublicandprivatekey(key, ret) } } -int getpublickey(netname, publickey) - const char *netname; - char *publickey; +int getpublickey(const char *netname, char *publickey) { if (__getpublickey_LOCAL != NULL) return(__getpublickey_LOCAL(netname, publickey)); diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c index fa404d8c0d7e0..72c5da89746bb 100644 --- a/lib/libc/rpc/getrpcent.c +++ b/lib/libc/rpc/getrpcent.c @@ -989,7 +989,7 @@ getrpcbynumber(int number) } struct rpcent * -getrpcent() +getrpcent(void) { union key key; @@ -1023,7 +1023,7 @@ setrpcent(int stayopen) } void -endrpcent() +endrpcent(void) { #ifdef NS_CACHING static const nss_cache_info cache_info = NS_MP_CACHE_INFO_INITIALIZER( diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c index 1ceaa3f5ec299..b365678a7ace5 100644 --- a/lib/libc/rpc/getrpcport.c +++ b/lib/libc/rpc/getrpcport.c @@ -53,9 +53,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" int -getrpcport(host, prognum, versnum, proto) - char *host; - int prognum, versnum, proto; +getrpcport(char *host, int prognum, int versnum, int proto) { struct sockaddr_in addr; struct hostent *hp; diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c index 3864061c68b9d..b9bc77a7fd49d 100644 --- a/lib/libc/rpc/key_call.c +++ b/lib/libc/rpc/key_call.c @@ -81,15 +81,14 @@ __FBSDID("$FreeBSD$"); * implementations of these functions, and to call those in key_call(). */ -cryptkeyres *(*__key_encryptsession_pk_LOCAL)() = 0; -cryptkeyres *(*__key_decryptsession_pk_LOCAL)() = 0; -des_block *(*__key_gendes_LOCAL)() = 0; +cryptkeyres *(*__key_encryptsession_pk_LOCAL)(uid_t, void *arg) = 0; +cryptkeyres *(*__key_decryptsession_pk_LOCAL)(uid_t, void *arg) = 0; +des_block *(*__key_gendes_LOCAL)(uid_t, void *) = 0; static int key_call( u_long, xdrproc_t, void *, xdrproc_t, void *); int -key_setsecret(secretkey) - const char *secretkey; +key_setsecret(const char *secretkey) { keystatus status; @@ -131,10 +130,7 @@ key_secretkey_is_set(void) } int -key_encryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; +key_encryptsession_pk(char *remotename, netobj *remotekey, des_block *deskey) { cryptkeyarg2 arg; cryptkeyres res; @@ -155,10 +151,7 @@ key_encryptsession_pk(remotename, remotekey, deskey) } int -key_decryptsession_pk(remotename, remotekey, deskey) - char *remotename; - netobj *remotekey; - des_block *deskey; +key_decryptsession_pk(char *remotename, netobj *remotekey, des_block *deskey) { cryptkeyarg2 arg; cryptkeyres res; @@ -179,9 +172,7 @@ key_decryptsession_pk(remotename, remotekey, deskey) } int -key_encryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; +key_encryptsession(const char *remotename, des_block *deskey) { cryptkeyarg arg; cryptkeyres res; @@ -201,9 +192,7 @@ key_encryptsession(remotename, deskey) } int -key_decryptsession(remotename, deskey) - const char *remotename; - des_block *deskey; +key_decryptsession(const char *remotename, des_block *deskey) { cryptkeyarg arg; cryptkeyres res; @@ -223,8 +212,7 @@ key_decryptsession(remotename, deskey) } int -key_gendes(key) - des_block *key; +key_gendes(des_block *key) { if (!key_call((u_long)KEY_GEN, (xdrproc_t)xdr_void, NULL, (xdrproc_t)xdr_des_block, key)) { @@ -234,8 +222,7 @@ key_gendes(key) } int -key_setnet(arg) -struct key_netstarg *arg; +key_setnet(struct key_netstarg *arg) { keystatus status; @@ -254,9 +241,7 @@ struct key_netstarg *arg; int -key_get_conv(pkey, deskey) - char *pkey; - des_block *deskey; +key_get_conv(char *pkey, des_block *deskey) { cryptkeyres res; @@ -305,8 +290,7 @@ key_call_init(void) * Keep the handle cached. This call may be made quite often. */ static CLIENT * -getkeyserv_handle(vers) -int vers; +getkeyserv_handle(int vers) { void *localhandle; struct netconfig *nconf; @@ -429,12 +413,8 @@ int vers; /* returns 0 on failure, 1 on success */ static int -key_call(proc, xdr_arg, arg, xdr_rslt, rslt) - u_long proc; - xdrproc_t xdr_arg; - void *arg; - xdrproc_t xdr_rslt; - void *rslt; +key_call(u_long proc, xdrproc_t xdr_arg, void *arg, xdrproc_t xdr_rslt, + void *rslt) { CLIENT *clnt; struct timeval wait_time; diff --git a/lib/libc/rpc/mt_misc.c b/lib/libc/rpc/mt_misc.c index 7abcaedaee231..2e17c27f444c2 100644 --- a/lib/libc/rpc/mt_misc.c +++ b/lib/libc/rpc/mt_misc.c @@ -93,7 +93,7 @@ rce_key_init(void) } struct rpc_createerr * -__rpc_createerr() +__rpc_createerr(void) { struct rpc_createerr *rce_addr = 0; diff --git a/lib/libc/rpc/netname.c b/lib/libc/rpc/netname.c index 7b1661ebb2e82..77b522b6ac935 100644 --- a/lib/libc/rpc/netname.c +++ b/lib/libc/rpc/netname.c @@ -79,8 +79,7 @@ static char *OPSYS = "unix"; * Figure out my fully qualified network name */ int -getnetname(name) - char name[MAXNETNAMELEN+1]; +getnetname(char name[MAXNETNAMELEN+1]) { uid_t uid; @@ -97,10 +96,7 @@ getnetname(name) * Convert unix cred to network-name */ int -user2netname(netname, uid, domain) - char netname[MAXNETNAMELEN + 1]; - const uid_t uid; - const char *domain; +user2netname(char netname[MAXNETNAMELEN + 1], const uid_t uid, const char *domain) { char *dfltdom; @@ -122,10 +118,7 @@ user2netname(netname, uid, domain) * Convert host to network-name */ int -host2netname(netname, host, domain) - char netname[MAXNETNAMELEN + 1]; - const char *host; - const char *domain; +host2netname(char netname[MAXNETNAMELEN + 1], const char *host, const char *domain) { char *dfltdom; char hostname[MAXHOSTNAMELEN+1]; diff --git a/lib/libc/rpc/netnamer.c b/lib/libc/rpc/netnamer.c index fce4b4d90f51f..e7a297213b053 100644 --- a/lib/libc/rpc/netnamer.c +++ b/lib/libc/rpc/netnamer.c @@ -68,12 +68,8 @@ static int _getgroups( char *, gid_t * ); * Convert network-name into unix credential */ int -netname2user(netname, uidp, gidp, gidlenp, gidlist) - char netname[MAXNETNAMELEN + 1]; - uid_t *uidp; - gid_t *gidp; - int *gidlenp; - gid_t *gidlist; +netname2user(char netname[MAXNETNAMELEN + 1], uid_t *uidp, gid_t *gidp, + int *gidlenp, gid_t *gidlist) { char *p; int gidlen; @@ -149,9 +145,7 @@ netname2user(netname, uidp, gidp, gidlenp, gidlist) */ static int -_getgroups(uname, groups) - char *uname; - gid_t groups[NGRPS]; +_getgroups(char *uname, gid_t groups[NGRPS]) { gid_t ngroups = 0; struct group *grp; @@ -190,10 +184,7 @@ toomany: * Convert network-name to hostname */ int -netname2host(netname, hostname, hostlen) - char netname[MAXNETNAMELEN + 1]; - char *hostname; - int hostlen; +netname2host(char netname[MAXNETNAMELEN + 1], char *hostname, int hostlen) { int err; char valbuf[1024]; @@ -239,8 +230,7 @@ netname2host(netname, hostname, hostlen) * network information service. */ int -getnetid(key, ret) - char *key, *ret; +getnetid(char *key, char *ret) { char buf[1024]; /* big enough */ char *res; diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index 34e254a70bdd8..1049005cfddfb 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -70,8 +70,7 @@ __FBSDID("$FreeBSD$"); * Calls the pmap service remotely to do get the maps. */ struct pmaplist * -pmap_getmaps(address) - struct sockaddr_in *address; +pmap_getmaps(struct sockaddr_in *address) { struct pmaplist *head = NULL; int sock = -1; diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index e06f9585b4a85..c1e0c7a4b88da 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -66,11 +66,8 @@ static const struct timeval tottimeout = { 60, 0 }; * Returns 0 if no map exists. */ u_short -pmap_getport(address, program, version, protocol) - struct sockaddr_in *address; - u_long program; - u_long version; - u_int protocol; +pmap_getport(struct sockaddr_in *address, u_long program, u_long version, + u_int protocol) { u_short port = 0; int sock = -1; diff --git a/lib/libc/rpc/pmap_prot.c b/lib/libc/rpc/pmap_prot.c index 1967467835914..bf0167235bf5d 100644 --- a/lib/libc/rpc/pmap_prot.c +++ b/lib/libc/rpc/pmap_prot.c @@ -52,9 +52,7 @@ __FBSDID("$FreeBSD$"); bool_t -xdr_pmap(xdrs, regs) - XDR *xdrs; - struct pmap *regs; +xdr_pmap(XDR *xdrs, struct pmap *regs) { assert(xdrs != NULL); diff --git a/lib/libc/rpc/pmap_prot2.c b/lib/libc/rpc/pmap_prot2.c index 56a11985d2f65..f892afbc9bd75 100644 --- a/lib/libc/rpc/pmap_prot2.c +++ b/lib/libc/rpc/pmap_prot2.c @@ -90,9 +90,7 @@ __FBSDID("$FreeBSD$"); * this sounds like a job for xdr_reference! */ bool_t -xdr_pmaplist(xdrs, rp) - XDR *xdrs; - struct pmaplist **rp; +xdr_pmaplist(XDR *xdrs, struct pmaplist **rp) { /* * more_elements is pre-computed in case the direction is @@ -134,9 +132,7 @@ xdr_pmaplist(xdrs, rp) * functionality to xdr_pmaplist(). */ bool_t -xdr_pmaplist_ptr(xdrs, rp) - XDR *xdrs; - struct pmaplist *rp; +xdr_pmaplist_ptr(XDR *xdrs, struct pmaplist *rp) { return xdr_pmaplist(xdrs, (struct pmaplist **)(void *)rp); } diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index fe7b4323d8484..124120498dcba 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -76,14 +76,9 @@ static const struct timeval timeout = { 3, 0 }; * programs to do a lookup and call in one step. */ enum clnt_stat -pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, - port_ptr) - struct sockaddr_in *addr; - u_long prog, vers, proc; - xdrproc_t xdrargs, xdrres; - caddr_t argsp, resp; - struct timeval tout; - u_long *port_ptr; +pmap_rmtcall(struct sockaddr_in *addr, u_long prog, u_long vers, u_long proc, + xdrproc_t xdrargs, caddr_t argsp, xdrproc_t xdrres, caddr_t resp, + struct timeval tout, u_long *port_ptr) { int sock = -1; CLIENT *client; @@ -122,9 +117,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, * written for XDR_ENCODE direction only */ bool_t -xdr_rmtcall_args(xdrs, cap) - XDR *xdrs; - struct rmtcallargs *cap; +xdr_rmtcall_args(XDR *xdrs, struct rmtcallargs *cap) { u_int lenposition, argposition, position; @@ -156,9 +149,7 @@ xdr_rmtcall_args(xdrs, cap) * written for XDR_DECODE direction only */ bool_t -xdr_rmtcallres(xdrs, crp) - XDR *xdrs; - struct rmtcallres *crp; +xdr_rmtcallres(XDR *xdrs, struct rmtcallres *crp) { caddr_t port_ptr; diff --git a/lib/libc/rpc/rpc_callmsg.c b/lib/libc/rpc/rpc_callmsg.c index 5b7ea490094e1..0e29e09a92ad0 100644 --- a/lib/libc/rpc/rpc_callmsg.c +++ b/lib/libc/rpc/rpc_callmsg.c @@ -54,9 +54,7 @@ __FBSDID("$FreeBSD$"); * XDR a call message */ bool_t -xdr_callmsg(xdrs, cmsg) - XDR *xdrs; - struct rpc_msg *cmsg; +xdr_callmsg(XDR *xdrs, struct rpc_msg *cmsg) { enum msg_type *prm_direction; int32_t *buf; diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c index 57ef267357ee2..fe970e11b2031 100644 --- a/lib/libc/rpc/rpc_generic.c +++ b/lib/libc/rpc/rpc_generic.c @@ -111,7 +111,7 @@ static int getnettype(const char *); * expensive call every time. */ int -__rpc_dtbsize() +__rpc_dtbsize(void) { static int tbsize; struct rlimit rl; @@ -132,12 +132,12 @@ __rpc_dtbsize() /* * Find the appropriate buffer size + * + * size - Size requested */ u_int /*ARGSUSED*/ -__rpc_get_t_size(af, proto, size) - int af, proto; - int size; /* Size requested */ +__rpc_get_t_size(int af, int proto, int size) { int maxsize, defsize; @@ -164,8 +164,7 @@ __rpc_get_t_size(af, proto, size) * Find the appropriate address buffer size */ u_int -__rpc_get_a_size(af) - int af; +__rpc_get_a_size(int af) { switch (af) { case AF_INET: @@ -184,8 +183,7 @@ __rpc_get_a_size(af) #if 0 static char * -strlocase(p) - char *p; +strlocase(char *p) { char *t = p; @@ -201,8 +199,7 @@ strlocase(p) * If nettype is NULL, it defaults to NETPATH. */ static int -getnettype(nettype) - const char *nettype; +getnettype(const char *nettype) { int i; @@ -237,8 +234,7 @@ keys_init(void) * This should be freed by calling freenetconfigent() */ struct netconfig * -__rpc_getconfip(nettype) - const char *nettype; +__rpc_getconfip(const char *nettype) { char *netid; char *netid_tcp = (char *) NULL; @@ -309,8 +305,7 @@ __rpc_getconfip(nettype) * __rpc_getconf(). */ void * -__rpc_setconf(nettype) - const char *nettype; +__rpc_setconf(const char *nettype) { struct handle *handle; @@ -353,8 +348,7 @@ failed: * __rpc_setconf() should have been called previously. */ struct netconfig * -__rpc_getconf(vhandle) - void *vhandle; +__rpc_getconf(void *vhandle) { struct handle *handle; struct netconfig *nconf; @@ -430,8 +424,7 @@ __rpc_getconf(vhandle) } void -__rpc_endconf(vhandle) - void * vhandle; +__rpc_endconf(void *vhandle) { struct handle *handle; @@ -452,8 +445,7 @@ __rpc_endconf(vhandle) * Returns NULL if fails, else a non-NULL pointer. */ void * -rpc_nullproc(clnt) - CLIENT *clnt; +rpc_nullproc(CLIENT *clnt) { struct timeval TIMEOUT = {25, 0}; @@ -469,8 +461,7 @@ rpc_nullproc(clnt) * one succeeds in finding the netconf for the given fd. */ struct netconfig * -__rpcgettp(fd) - int fd; +__rpcgettp(int fd) { const char *netid; struct __rpc_sockinfo si; diff --git a/lib/libc/rpc/rpc_prot.c b/lib/libc/rpc/rpc_prot.c index 20dc8fa3484cd..53fc70a342a2e 100644 --- a/lib/libc/rpc/rpc_prot.c +++ b/lib/libc/rpc/rpc_prot.c @@ -68,9 +68,7 @@ extern struct opaque_auth _null_auth; * (see auth.h) */ bool_t -xdr_opaque_auth(xdrs, ap) - XDR *xdrs; - struct opaque_auth *ap; +xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap) { assert(xdrs != NULL); @@ -86,9 +84,7 @@ xdr_opaque_auth(xdrs, ap) * XDR a DES block */ bool_t -xdr_des_block(xdrs, blkp) - XDR *xdrs; - des_block *blkp; +xdr_des_block(XDR *xdrs, des_block *blkp) { assert(xdrs != NULL); @@ -103,9 +99,7 @@ xdr_des_block(xdrs, blkp) * XDR the MSG_ACCEPTED part of a reply message union */ bool_t -xdr_accepted_reply(xdrs, ar) - XDR *xdrs; - struct accepted_reply *ar; +xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar) { enum accept_stat *par_stat; @@ -142,9 +136,7 @@ xdr_accepted_reply(xdrs, ar) * XDR the MSG_DENIED part of a reply message union */ bool_t -xdr_rejected_reply(xdrs, rr) - XDR *xdrs; - struct rejected_reply *rr; +xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr) { enum reject_stat *prj_stat; enum auth_stat *prj_why; @@ -182,9 +174,7 @@ static const struct xdr_discrim reply_dscrm[3] = { * XDR a reply message */ bool_t -xdr_replymsg(xdrs, rmsg) - XDR *xdrs; - struct rpc_msg *rmsg; +xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg) { enum msg_type *prm_direction; enum reply_stat *prp_stat; @@ -212,9 +202,7 @@ xdr_replymsg(xdrs, rmsg) * The rm_xid is not really static, but the user can easily munge on the fly. */ bool_t -xdr_callhdr(xdrs, cmsg) - XDR *xdrs; - struct rpc_msg *cmsg; +xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg) { enum msg_type *prm_direction; @@ -238,9 +226,7 @@ xdr_callhdr(xdrs, cmsg) /* ************************** Client utility routine ************* */ static void -accepted(acpt_stat, error) - enum accept_stat acpt_stat; - struct rpc_err *error; +accepted(enum accept_stat acpt_stat, struct rpc_err *error) { assert(error != NULL); @@ -279,9 +265,7 @@ accepted(acpt_stat, error) } static void -rejected(rjct_stat, error) - enum reject_stat rjct_stat; - struct rpc_err *error; +rejected(enum reject_stat rjct_stat, struct rpc_err *error) { assert(error != NULL); @@ -306,9 +290,7 @@ rejected(rjct_stat, error) * given a reply message, fills in the error */ void -_seterr_reply(msg, error) - struct rpc_msg *msg; - struct rpc_err *error; +_seterr_reply(struct rpc_msg *msg, struct rpc_err *error) { assert(msg != NULL); diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c index febc597c5d943..8fc91ffde304a 100644 --- a/lib/libc/rpc/rpc_soc.c +++ b/lib/libc/rpc/rpc_soc.c @@ -88,14 +88,8 @@ static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *); * A common clnt create routine */ static CLIENT * -clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp) - struct sockaddr_in *raddr; - rpcprog_t prog; - rpcvers_t vers; - int *sockp; - u_int sendsz; - u_int recvsz; - char *tp; +clnt_com_create(struct sockaddr_in *raddr, rpcprog_t prog, rpcvers_t vers, int *sockp, + u_int sendsz, u_int recvsz, char *tp) { CLIENT *cl; int madefd = FALSE; @@ -164,14 +158,8 @@ err: if (madefd == TRUE) } CLIENT * -clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - struct timeval wait; - int *sockp; - u_int sendsz; - u_int recvsz; +clntudp_bufcreate(struct sockaddr_in *raddr, u_long prog, u_long vers, + struct timeval wait, int *sockp, u_int sendsz, u_int recvsz) { CLIENT *cl; @@ -185,12 +173,8 @@ clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz) } CLIENT * -clntudp_create(raddr, program, version, wait, sockp) - struct sockaddr_in *raddr; - u_long program; - u_long version; - struct timeval wait; - int *sockp; +clntudp_create(struct sockaddr_in *raddr, u_long program, u_long version, + struct timeval wait, int *sockp) { return clntudp_bufcreate(raddr, program, version, wait, sockp, @@ -198,13 +182,8 @@ clntudp_create(raddr, program, version, wait, sockp) } CLIENT * -clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_in *raddr; - u_long prog; - u_long vers; - int *sockp; - u_int sendsz; - u_int recvsz; +clnttcp_create(struct sockaddr_in *raddr, u_long prog, u_long vers, int *sockp, + u_int sendsz, u_int recvsz) { return clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp, @@ -212,9 +191,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) } CLIENT * -clntraw_create(prog, vers) - u_long prog; - u_long vers; +clntraw_create(u_long prog, u_long vers) { return clnt_raw_create((rpcprog_t)prog, (rpcvers_t)vers); @@ -224,11 +201,7 @@ clntraw_create(prog, vers) * A common server create routine */ static SVCXPRT * -svc_com_create(fd, sendsize, recvsize, netid) - int fd; - u_int sendsize; - u_int recvsize; - char *netid; +svc_com_create(int fd, u_int sendsize, u_int recvsize, char *netid) { struct netconfig *nconf; SVCXPRT *svc; @@ -268,29 +241,21 @@ svc_com_create(fd, sendsize, recvsize, netid) } SVCXPRT * -svctcp_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svctcp_create(int fd, u_int sendsize, u_int recvsize) { return svc_com_create(fd, sendsize, recvsize, "tcp"); } SVCXPRT * -svcudp_bufcreate(fd, sendsz, recvsz) - int fd; - u_int sendsz, recvsz; +svcudp_bufcreate(int fd, u_int sendsz, u_int recvsz) { return svc_com_create(fd, sendsz, recvsz, "udp"); } SVCXPRT * -svcfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svcfd_create(int fd, u_int sendsize, u_int recvsize) { return svc_fd_create(fd, sendsize, recvsize); @@ -298,23 +263,21 @@ svcfd_create(fd, sendsize, recvsize) SVCXPRT * -svcudp_create(fd) - int fd; +svcudp_create(int fd) { return svc_com_create(fd, UDPMSGSIZE, UDPMSGSIZE, "udp"); } SVCXPRT * -svcraw_create() +svcraw_create(void) { return svc_raw_create(); } int -get_myaddress(addr) - struct sockaddr_in *addr; +get_myaddress(struct sockaddr_in *addr) { memset((void *) addr, 0, sizeof(*addr)); @@ -328,11 +291,8 @@ get_myaddress(addr) * For connectionless "udp" transport. Obsoleted by rpc_call(). */ int -callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) - const char *host; - int prognum, versnum, procnum; - xdrproc_t inproc, outproc; - void *in, *out; +callrpc(const char *host, int prognum, int versnum, int procnum, + xdrproc_t inproc, void *in, xdrproc_t outproc, void *out) { return (int)rpc_call(host, (rpcprog_t)prognum, (rpcvers_t)versnum, @@ -343,10 +303,9 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) * For connectionless kind of transport. Obsoleted by rpc_reg() */ int -registerrpc(prognum, versnum, procnum, progname, inproc, outproc) - int prognum, versnum, procnum; - char *(*progname)(char [UDPMSGSIZE]); - xdrproc_t inproc, outproc; +registerrpc(int prognum, int versnum, int procnum, + char *(*progname)(char [UDPMSGSIZE]), + xdrproc_t inproc, xdrproc_t outproc) { return rpc_reg((rpcprog_t)prognum, (rpcvers_t)versnum, @@ -374,10 +333,12 @@ clnt_broadcast_key_init(void) */ /* ARGSUSED */ static bool_t -rpc_wrap_bcast(resultp, addr, nconf) - char *resultp; /* results of the call */ - struct netbuf *addr; /* address of the guy who responded */ - struct netconfig *nconf; /* Netconf of the transport */ +rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf) +/* + * char *resultp; // results of the call + * struct netbuf *addr; // address of the guy who responded + * struct netconfig *nconf; // Netconf of the transport + */ { resultproc_t clnt_broadcast_result; @@ -395,15 +356,18 @@ rpc_wrap_bcast(resultp, addr, nconf) * Broadcasts on UDP transport. Obsoleted by rpc_broadcast(). */ enum clnt_stat -clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) - u_long prog; /* program number */ - u_long vers; /* version number */ - u_long proc; /* procedure number */ - xdrproc_t xargs; /* xdr routine for args */ - void *argsp; /* pointer to args */ - xdrproc_t xresults; /* xdr routine for results */ - void *resultsp; /* pointer to results */ - resultproc_t eachresult; /* call with each result obtained */ +clnt_broadcast(u_long prog, u_long vers, u_long proc, xdrproc_t xargs, + void *argsp, xdrproc_t xresults, void *resultsp, resultproc_t eachresult) +/* + * u_long prog; // program number + * u_long vers; // version number + * u_long proc; // procedure number + * xdrproc_t xargs; // xdr routine for args + * void *argsp; // pointer to args + * xdrproc_t xresults; // xdr routine for results + * void *resultsp; // pointer to results + * resultproc_t eachresult; // call with each result obtained + */ { if (thr_main()) @@ -422,11 +386,14 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) * authdes_seccreate(). */ AUTH * -authdes_create(servername, window, syncaddr, ckey) - char *servername; /* network name of server */ - u_int window; /* time to live */ - struct sockaddr *syncaddr; /* optional hostaddr to sync with */ - des_block *ckey; /* optional conversation key to use */ +authdes_create(char *servername, u_int window, struct sockaddr *syncaddr, + des_block *ckey) +/* + * char *servername; // network name of server + * u_int window; // time to live + * struct sockaddr *syncaddr; // optional hostaddr to sync with + * des_block *ckey; // optional conversation key to use + */ { AUTH *dummy; AUTH *nauth; @@ -453,13 +420,8 @@ fallback: * Create a client handle for a unix connection. Obsoleted by clnt_vc_create() */ CLIENT * -clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) - struct sockaddr_un *raddr; - u_long prog; - u_long vers; - int *sockp; - u_int sendsz; - u_int recvsz; +clntunix_create(struct sockaddr_un *raddr, u_long prog, u_long vers, int *sockp, + u_int sendsz, u_int recvsz) { struct netbuf *svcaddr; CLIENT *cl; @@ -504,11 +466,7 @@ done: * Obsoleted by svc_vc_create(). */ SVCXPRT * -svcunix_create(sock, sendsize, recvsize, path) - int sock; - u_int sendsize; - u_int recvsize; - char *path; +svcunix_create(int sock, u_int sendsize, u_int recvsize, char *path) { struct netconfig *nconf; void *localhandle; @@ -568,10 +526,7 @@ done: * descriptor as its first input. Obsoleted by svc_fd_create(); */ SVCXPRT * -svcunixfd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svcunixfd_create(int fd, u_int sendsize, u_int recvsize) { return (svc_fd_create(fd, sendsize, recvsize)); } diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c index a0d840e65f4e1..d53d908fc2e42 100644 --- a/lib/libc/rpc/rpcb_clnt.c +++ b/lib/libc/rpc/rpcb_clnt.c @@ -109,9 +109,7 @@ static struct netbuf *got_entry(rpcb_entry_list_ptr, const struct netconfig *); * These are private routines that may not be provided in future releases. */ bool_t -__rpc_control(request, info) - int request; - void *info; +__rpc_control(int request, void *info) { switch (request) { case CLCR_GET_RPCB_TIMEOUT: @@ -150,8 +148,7 @@ __rpc_control(request, info) */ static struct address_cache * -check_cache(host, netid) - const char *host, *netid; +check_cache(const char *host, const char *netid) { struct address_cache *cptr; @@ -171,8 +168,7 @@ check_cache(host, netid) } static void -delete_cache(addr) - struct netbuf *addr; +delete_cache(struct netbuf *addr) { struct address_cache *cptr, *prevptr = NULL; @@ -198,10 +194,8 @@ delete_cache(addr) } static void -add_cache(host, netid, taddr, uaddr) - const char *host, *netid; - char *uaddr; - struct netbuf *taddr; +add_cache(const char *host, const char *netid, struct netbuf *taddr, + char *uaddr) { struct address_cache *ad_cache, *cptr, *prevptr; @@ -286,10 +280,7 @@ out: * On error, returns NULL and free's everything. */ static CLIENT * -getclnthandle(host, nconf, targaddr) - const char *host; - const struct netconfig *nconf; - char **targaddr; +getclnthandle(const char *host, const struct netconfig *nconf, char **targaddr) { CLIENT *client; struct netbuf *addr, taddr; @@ -435,7 +426,7 @@ getclnthandle(host, nconf, targaddr) * rpcbind. Returns NULL on error and free's everything. */ static CLIENT * -local_rpcb() +local_rpcb(void) { CLIENT *client; static struct netconfig *loopnconf; @@ -531,13 +522,13 @@ try_nconf: /* * Set a mapping between program, version and address. * Calls the rpcbind service to do the mapping. + * + * nconf - Network structure of transport + * address - Services netconfig address */ bool_t -rpcb_set(program, version, nconf, address) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; /* Network structure of transport */ - const struct netbuf *address; /* Services netconfig address */ +rpcb_set(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, + const struct netbuf *address) { CLIENT *client; bool_t rslt = FALSE; @@ -594,10 +585,7 @@ rpcb_set(program, version, nconf, address) * only for the given transport. */ bool_t -rpcb_unset(program, version, nconf) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; +rpcb_unset(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf) { CLIENT *client; bool_t rslt = FALSE; @@ -634,9 +622,7 @@ rpcb_unset(program, version, nconf) * From the merged list, find the appropriate entry */ static struct netbuf * -got_entry(relp, nconf) - rpcb_entry_list_ptr relp; - const struct netconfig *nconf; +got_entry(rpcb_entry_list_ptr relp, const struct netconfig *nconf) { struct netbuf *na = NULL; rpcb_entry_list_ptr sp; @@ -667,7 +653,7 @@ got_entry(relp, nconf) * local transport. */ static bool_t -__rpcbind_is_up() +__rpcbind_is_up(void) { struct netconfig *nconf; struct sockaddr_un sun; @@ -722,13 +708,9 @@ __rpcbind_is_up() * starts working properly. Also look under clnt_vc.c. */ struct netbuf * -__rpcb_findaddr_timed(program, version, nconf, host, clpp, tp) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; - const char *host; - CLIENT **clpp; - struct timeval *tp; +__rpcb_findaddr_timed(rpcprog_t program, rpcvers_t version, + const struct netconfig *nconf, const char *host, + CLIENT **clpp, struct timeval *tp) { static bool_t check_rpcbind = TRUE; CLIENT *client = NULL; @@ -1037,12 +1019,8 @@ done: * Assuming that the address is all properly allocated */ int -rpcb_getaddr(program, version, nconf, address, host) - rpcprog_t program; - rpcvers_t version; - const struct netconfig *nconf; - struct netbuf *address; - const char *host; +rpcb_getaddr(rpcprog_t program, rpcvers_t version, const struct netconfig *nconf, + struct netbuf *address, const char *host) { struct netbuf *na; @@ -1073,9 +1051,7 @@ rpcb_getaddr(program, version, nconf, address, host) * It returns NULL on failure. */ rpcblist * -rpcb_getmaps(nconf, host) - const struct netconfig *nconf; - const char *host; +rpcb_getmaps(const struct netconfig *nconf, const char *host) { rpcblist_ptr head = NULL; CLIENT *client; @@ -1123,19 +1099,20 @@ done: * which will look up a service program in the address maps, and then * remotely call that routine with the given parameters. This allows * programs to do a lookup and call in one step. -*/ + * + * nconf -Netconfig structure + * host - Remote host name + * proc - Remote proc identifiers + * xdrargs, xdrres; XDR routines + * argsp, resp - Argument and Result + * tout - Timeout value for this call + * addr_ptr - Preallocated netbuf address + */ enum clnt_stat -rpcb_rmtcall(nconf, host, prog, vers, proc, xdrargs, argsp, - xdrres, resp, tout, addr_ptr) - const struct netconfig *nconf; /* Netconfig structure */ - const char *host; /* Remote host name */ - rpcprog_t prog; - rpcvers_t vers; - rpcproc_t proc; /* Remote proc identifiers */ - xdrproc_t xdrargs, xdrres; /* XDR routines */ - caddr_t argsp, resp; /* Argument and Result */ - struct timeval tout; /* Timeout value for this call */ - const struct netbuf *addr_ptr; /* Preallocated netbuf address */ +rpcb_rmtcall(const struct netconfig *nconf, const char *host, rpcprog_t prog, + rpcvers_t vers, rpcproc_t proc, xdrproc_t xdrargs, caddr_t argsp, + xdrproc_t xdrres, caddr_t resp, struct timeval tout, + const struct netbuf *addr_ptr) { CLIENT *client; enum clnt_stat stat; @@ -1206,9 +1183,7 @@ error: * Returns 1 if succeeds else 0. */ bool_t -rpcb_gettime(host, timep) - const char *host; - time_t *timep; +rpcb_gettime(const char *host, time_t *timep) { CLIENT *client = NULL; void *handle; @@ -1267,9 +1242,7 @@ rpcb_gettime(host, timep) * really be called because local n2a libraries are always provided. */ char * -rpcb_taddr2uaddr(nconf, taddr) - struct netconfig *nconf; - struct netbuf *taddr; +rpcb_taddr2uaddr(struct netconfig *nconf, struct netbuf *taddr) { CLIENT *client; char *uaddr = NULL; @@ -1301,9 +1274,7 @@ rpcb_taddr2uaddr(nconf, taddr) * really be called because local n2a libraries are always provided. */ struct netbuf * -rpcb_uaddr2taddr(nconf, uaddr) - struct netconfig *nconf; - char *uaddr; +rpcb_uaddr2taddr(struct netconfig *nconf, char *uaddr) { CLIENT *client; struct netbuf *taddr; diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c index f543aaf0a6957..b793eca31cf57 100644 --- a/lib/libc/rpc/rpcb_prot.c +++ b/lib/libc/rpc/rpcb_prot.c @@ -54,9 +54,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" bool_t -xdr_rpcb(xdrs, objp) - XDR *xdrs; - RPCB *objp; +xdr_rpcb(XDR *xdrs, RPCB *objp) { if (!xdr_u_int32_t(xdrs, &objp->r_prog)) { return (FALSE); @@ -100,9 +98,7 @@ xdr_rpcb(xdrs, objp) */ bool_t -xdr_rpcblist_ptr(xdrs, rp) - XDR *xdrs; - rpcblist_ptr *rp; +xdr_rpcblist_ptr(XDR *xdrs, rpcblist_ptr *rp) { /* * more_elements is pre-computed in case the direction is @@ -154,9 +150,7 @@ xdr_rpcblist_ptr(xdrs, rp) * functionality to xdr_rpcblist_ptr(). */ bool_t -xdr_rpcblist(xdrs, rp) - XDR *xdrs; - RPCBLIST **rp; +xdr_rpcblist(XDR *xdrs, RPCBLIST **rp) { bool_t dummy; @@ -166,9 +160,7 @@ xdr_rpcblist(xdrs, rp) bool_t -xdr_rpcb_entry(xdrs, objp) - XDR *xdrs; - rpcb_entry *objp; +xdr_rpcb_entry(XDR *xdrs, rpcb_entry *objp) { if (!xdr_string(xdrs, &objp->r_maddr, (u_int)~0)) { return (FALSE); @@ -189,9 +181,7 @@ xdr_rpcb_entry(xdrs, objp) } bool_t -xdr_rpcb_entry_list_ptr(xdrs, rp) - XDR *xdrs; - rpcb_entry_list_ptr *rp; +xdr_rpcb_entry_list_ptr(XDR *xdrs, rpcb_entry_list_ptr *rp) { /* * more_elements is pre-computed in case the direction is @@ -244,9 +234,7 @@ xdr_rpcb_entry_list_ptr(xdrs, rp) * written for XDR_ENCODE direction only */ bool_t -xdr_rpcb_rmtcallargs(xdrs, p) - XDR *xdrs; - struct rpcb_rmtcallargs *p; +xdr_rpcb_rmtcallargs(XDR *xdrs, struct rpcb_rmtcallargs *p) { struct r_rpcb_rmtcallargs *objp = (struct r_rpcb_rmtcallargs *)(void *)p; @@ -296,9 +284,7 @@ xdr_rpcb_rmtcallargs(xdrs, p) * written for XDR_DECODE direction only */ bool_t -xdr_rpcb_rmtcallres(xdrs, p) - XDR *xdrs; - struct rpcb_rmtcallres *p; +xdr_rpcb_rmtcallres(XDR *xdrs, struct rpcb_rmtcallres *p) { bool_t dummy; struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p; @@ -314,9 +300,7 @@ xdr_rpcb_rmtcallres(xdrs, p) } bool_t -xdr_netbuf(xdrs, objp) - XDR *xdrs; - struct netbuf *objp; +xdr_netbuf(XDR *xdrs, struct netbuf *objp) { bool_t dummy; void **pp; diff --git a/lib/libc/rpc/rpcb_st_xdr.c b/lib/libc/rpc/rpcb_st_xdr.c index 8ffc5b6014f78..8919144c82897 100644 --- a/lib/libc/rpc/rpcb_st_xdr.c +++ b/lib/libc/rpc/rpcb_st_xdr.c @@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$"); /* Link list of all the stats about getport and getaddr */ bool_t -xdr_rpcbs_addrlist(xdrs, objp) - XDR *xdrs; - rpcbs_addrlist *objp; +xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp) { struct rpcbs_addrlist **pnext; @@ -83,9 +81,7 @@ xdr_rpcbs_addrlist(xdrs, objp) /* Link list of all the stats about rmtcall */ bool_t -xdr_rpcbs_rmtcalllist(xdrs, objp) - XDR *xdrs; - rpcbs_rmtcalllist *objp; +xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp) { int32_t *buf; struct rpcbs_rmtcalllist **pnext; @@ -198,9 +194,7 @@ xdr_rpcbs_rmtcalllist(xdrs, objp) } bool_t -xdr_rpcbs_proc(xdrs, objp) - XDR *xdrs; - rpcbs_proc objp; +xdr_rpcbs_proc(XDR *xdrs, rpcbs_proc objp) { if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBSTAT_HIGHPROC, sizeof (int), (xdrproc_t)xdr_int)) { @@ -210,9 +204,7 @@ xdr_rpcbs_proc(xdrs, objp) } bool_t -xdr_rpcbs_addrlist_ptr(xdrs, objp) - XDR *xdrs; - rpcbs_addrlist_ptr *objp; +xdr_rpcbs_addrlist_ptr(XDR *xdrs, rpcbs_addrlist_ptr *objp) { if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_addrlist), (xdrproc_t)xdr_rpcbs_addrlist)) { @@ -222,9 +214,7 @@ xdr_rpcbs_addrlist_ptr(xdrs, objp) } bool_t -xdr_rpcbs_rmtcalllist_ptr(xdrs, objp) - XDR *xdrs; - rpcbs_rmtcalllist_ptr *objp; +xdr_rpcbs_rmtcalllist_ptr(XDR *xdrs, rpcbs_rmtcalllist_ptr *objp) { if (!xdr_pointer(xdrs, (char **)objp, sizeof (rpcbs_rmtcalllist), (xdrproc_t)xdr_rpcbs_rmtcalllist)) { @@ -234,9 +224,7 @@ xdr_rpcbs_rmtcalllist_ptr(xdrs, objp) } bool_t -xdr_rpcb_stat(xdrs, objp) - XDR *xdrs; - rpcb_stat *objp; +xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp) { if (!xdr_rpcbs_proc(xdrs, objp->info)) { @@ -262,9 +250,7 @@ xdr_rpcb_stat(xdrs, objp) * being monitored. */ bool_t -xdr_rpcb_stat_byvers(xdrs, objp) - XDR *xdrs; - rpcb_stat_byvers objp; +xdr_rpcb_stat_byvers(XDR *xdrs, rpcb_stat_byvers objp) { if (!xdr_vector(xdrs, (char *)(void *)objp, RPCBVERS_STAT, sizeof (rpcb_stat), (xdrproc_t)xdr_rpcb_stat)) { diff --git a/lib/libc/rpc/rpcdname.c b/lib/libc/rpc/rpcdname.c index d6a21c9a9461b..f214b2122d5df 100644 --- a/lib/libc/rpc/rpcdname.c +++ b/lib/libc/rpc/rpcdname.c @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); static char *default_domain = 0; static char * -get_default_domain() +get_default_domain(void) { char temp[256]; @@ -71,8 +71,7 @@ get_default_domain() * get rejected elsewhere in the NIS client package. */ int -__rpc_get_default_domain(domain) - char **domain; +__rpc_get_default_domain(char **domain) { if ((*domain = get_default_domain()) != 0) return (0); diff --git a/lib/libc/rpc/rtime.c b/lib/libc/rpc/rtime.c index 807b14c7240ce..37bc9a38faab9 100644 --- a/lib/libc/rpc/rtime.c +++ b/lib/libc/rpc/rtime.c @@ -67,10 +67,8 @@ extern int _rpc_dtablesize( void ); static void do_close( int ); int -rtime(addrp, timep, timeout) - struct sockaddr_in *addrp; - struct timeval *timep; - struct timeval *timeout; +rtime(struct sockaddr_in *addrp, struct timeval *timep, + struct timeval *timeout) { int s; fd_set readfds; @@ -148,8 +146,7 @@ rtime(addrp, timep, timeout) } static void -do_close(s) - int s; +do_close(int s) { int save; diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c index 8203bd9f12f92..38cbb797f83e2 100644 --- a/lib/libc/rpc/svc.c +++ b/lib/libc/rpc/svc.c @@ -97,8 +97,7 @@ static void __xprt_do_unregister (SVCXPRT *xprt, bool_t dolock); * Activate a transport handle. */ void -xprt_register(xprt) - SVCXPRT *xprt; +xprt_register(SVCXPRT *xprt) { int sock; @@ -140,9 +139,7 @@ __xprt_unregister_unlocked(SVCXPRT *xprt) * De-activate a transport handle. */ static void -__xprt_do_unregister(xprt, dolock) - SVCXPRT *xprt; - bool_t dolock; +__xprt_do_unregister(SVCXPRT *xprt, bool_t dolock) { int sock; @@ -171,12 +168,9 @@ __xprt_do_unregister(xprt, dolock) * program number comes in. */ bool_t -svc_reg(xprt, prog, vers, dispatch, nconf) - SVCXPRT *xprt; - const rpcprog_t prog; - const rpcvers_t vers; - void (*dispatch)(struct svc_req *, SVCXPRT *); - const struct netconfig *nconf; +svc_reg(SVCXPRT *xprt, const rpcprog_t prog, const rpcvers_t vers, + void (*dispatch)(struct svc_req *, SVCXPRT *), + const struct netconfig *nconf) { bool_t dummy; struct svc_callout *prev; @@ -245,9 +239,7 @@ rpcb_it: * Remove a service program from the callout list. */ void -svc_unreg(prog, vers) - const rpcprog_t prog; - const rpcvers_t vers; +svc_unreg(const rpcprog_t prog, const rpcvers_t vers) { struct svc_callout *prev; struct svc_callout *s; @@ -278,12 +270,9 @@ svc_unreg(prog, vers) * program number comes in. */ bool_t -svc_register(xprt, prog, vers, dispatch, protocol) - SVCXPRT *xprt; - u_long prog; - u_long vers; - void (*dispatch)(struct svc_req *, SVCXPRT *); - int protocol; +svc_register(SVCXPRT *xprt, u_long prog, u_long vers, + void (*dispatch)(struct svc_req *, SVCXPRT *), + int protocol) { struct svc_callout *prev; struct svc_callout *s; @@ -318,9 +307,7 @@ pmap_it: * Remove a service program from the callout list. */ void -svc_unregister(prog, vers) - u_long prog; - u_long vers; +svc_unregister(u_long prog, u_long vers) { struct svc_callout *prev; struct svc_callout *s; @@ -345,11 +332,8 @@ svc_unregister(prog, vers) * struct. */ static struct svc_callout * -svc_find(prog, vers, prev, netid) - rpcprog_t prog; - rpcvers_t vers; - struct svc_callout **prev; - char *netid; +svc_find(rpcprog_t prog, rpcvers_t vers, struct svc_callout **prev, + char *netid) { struct svc_callout *s, *p; @@ -373,10 +357,8 @@ svc_find(prog, vers, prev, netid) * Send a reply to an rpc request */ bool_t -svc_sendreply(xprt, xdr_results, xdr_location) - SVCXPRT *xprt; - xdrproc_t xdr_results; - void * xdr_location; +svc_sendreply(SVCXPRT *xprt, xdrproc_t xdr_results, + void * xdr_location) { struct rpc_msg rply; @@ -395,8 +377,7 @@ svc_sendreply(xprt, xdr_results, xdr_location) * No procedure error reply */ void -svcerr_noproc(xprt) - SVCXPRT *xprt; +svcerr_noproc(SVCXPRT *xprt) { struct rpc_msg rply; @@ -413,8 +394,7 @@ svcerr_noproc(xprt) * Can't decode args error reply */ void -svcerr_decode(xprt) - SVCXPRT *xprt; +svcerr_decode(SVCXPRT *xprt) { struct rpc_msg rply; @@ -431,8 +411,7 @@ svcerr_decode(xprt) * Some system error */ void -svcerr_systemerr(xprt) - SVCXPRT *xprt; +svcerr_systemerr(SVCXPRT *xprt) { struct rpc_msg rply; @@ -453,31 +432,27 @@ svcerr_systemerr(xprt) * protocol: the portmapper (or rpc binder). */ void -__svc_versquiet_on(xprt) - SVCXPRT *xprt; +__svc_versquiet_on(SVCXPRT *xprt) { SVC_EXT(xprt)->xp_flags |= SVC_VERSQUIET; } void -__svc_versquiet_off(xprt) - SVCXPRT *xprt; +__svc_versquiet_off(SVCXPRT *xprt) { SVC_EXT(xprt)->xp_flags &= ~SVC_VERSQUIET; } void -svc_versquiet(xprt) - SVCXPRT *xprt; +svc_versquiet(SVCXPRT *xprt) { __svc_versquiet_on(xprt); } int -__svc_versquiet_get(xprt) - SVCXPRT *xprt; +__svc_versquiet_get(SVCXPRT *xprt) { return (SVC_EXT(xprt)->xp_flags & SVC_VERSQUIET); @@ -488,9 +463,7 @@ __svc_versquiet_get(xprt) * Authentication error reply */ void -svcerr_auth(xprt, why) - SVCXPRT *xprt; - enum auth_stat why; +svcerr_auth(SVCXPRT *xprt, enum auth_stat why) { struct rpc_msg rply; @@ -507,8 +480,7 @@ svcerr_auth(xprt, why) * Auth too weak error reply */ void -svcerr_weakauth(xprt) - SVCXPRT *xprt; +svcerr_weakauth(SVCXPRT *xprt) { assert(xprt != NULL); @@ -520,8 +492,7 @@ svcerr_weakauth(xprt) * Program unavailable error reply */ void -svcerr_noprog(xprt) - SVCXPRT *xprt; +svcerr_noprog(SVCXPRT *xprt) { struct rpc_msg rply; @@ -538,10 +509,7 @@ svcerr_noprog(xprt) * Program version mismatch error reply */ void -svcerr_progvers(xprt, low_vers, high_vers) - SVCXPRT *xprt; - rpcvers_t low_vers; - rpcvers_t high_vers; +svcerr_progvers(SVCXPRT *xprt, rpcvers_t low_vers, rpcvers_t high_vers) { struct rpc_msg rply; @@ -563,7 +531,7 @@ svcerr_progvers(xprt, low_vers, high_vers) * parameters. */ SVCXPRT * -svc_xprt_alloc() +svc_xprt_alloc(void) { SVCXPRT *xprt; SVCXPRT_EXT *ext; @@ -588,8 +556,7 @@ svc_xprt_alloc() * Free a server transport structure. */ void -svc_xprt_free(xprt) - SVCXPRT *xprt; +svc_xprt_free(SVCXPRT *xprt) { mem_free(xprt->xp_p3, sizeof(SVCXPRT_EXT)); @@ -615,8 +582,7 @@ svc_xprt_free(xprt) */ void -svc_getreq(rdfds) - int rdfds; +svc_getreq(int rdfds) { fd_set readfds; @@ -626,8 +592,7 @@ svc_getreq(rdfds) } void -svc_getreqset(readfds) - fd_set *readfds; +svc_getreqset(fd_set *readfds) { int bit, fd; fd_mask mask, *maskp; @@ -647,8 +612,7 @@ svc_getreqset(readfds) } void -svc_getreq_common(fd) - int fd; +svc_getreq_common(int fd) { SVCXPRT *xprt; struct svc_req r; @@ -743,9 +707,7 @@ call_done: void -svc_getreq_poll(pfdp, pollretval) - struct pollfd *pfdp; - int pollretval; +svc_getreq_poll(struct pollfd *pfdp, int pollretval) { int i; int fds_found; diff --git a/lib/libc/rpc/svc_auth.c b/lib/libc/rpc/svc_auth.c index 20685298474ab..58435af0c13bc 100644 --- a/lib/libc/rpc/svc_auth.c +++ b/lib/libc/rpc/svc_auth.c @@ -95,9 +95,7 @@ struct svc_auth_ops svc_auth_null_ops; * invalid. */ enum auth_stat -_authenticate(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; +_authenticate(struct svc_req *rqst, struct rpc_msg *msg) { int cred_flavor; struct authsvc *asp; @@ -151,11 +149,7 @@ _authenticate(rqst, msg) * that don't need to inspect or modify the message body. */ static bool_t -svcauth_null_wrap(auth, xdrs, xdr_func, xdr_ptr) - SVCAUTH *auth; - XDR *xdrs; - xdrproc_t xdr_func; - caddr_t xdr_ptr; +svcauth_null_wrap(SVCAUTH *auth, XDR *xdrs, xdrproc_t xdr_func, caddr_t xdr_ptr) { return (xdr_func(xdrs, xdr_ptr)); @@ -168,9 +162,7 @@ struct svc_auth_ops svc_auth_null_ops = { /*ARGSUSED*/ enum auth_stat -_svcauth_null(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; +_svcauth_null(struct svc_req *rqst, struct rpc_msg *msg) { return (AUTH_OK); } @@ -190,9 +182,8 @@ _svcauth_null(rqst, msg) */ int -svc_auth_reg(cred_flavor, handler) - int cred_flavor; - enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *); +svc_auth_reg(int cred_flavor, + enum auth_stat (*handler)(struct svc_req *, struct rpc_msg *)) { struct authsvc *asp; diff --git a/lib/libc/rpc/svc_auth_des.c b/lib/libc/rpc/svc_auth_des.c index d6fb6afa60d49..7a24c06e34e01 100644 --- a/lib/libc/rpc/svc_auth_des.c +++ b/lib/libc/rpc/svc_auth_des.c @@ -90,11 +90,11 @@ struct cache_entry { static struct cache_entry *authdes_cache/* [AUTHDES_CACHESZ] */; static short *authdes_lru/* [AUTHDES_CACHESZ] */; -static void cache_init(); /* initialize the cache */ -static short cache_spot(); /* find an entry in the cache */ -static void cache_ref(/*short sid*/); /* note that sid was ref'd */ +static void cache_init(void); /* initialize the cache */ +static short cache_spot(des_block *, char *, struct timeval *); /* find an entry in the cache */ +static void cache_ref(short sid); /* note that sid was ref'd */ -static void invalidate(); /* invalidate entry in cache */ +static void invalidate(char *); /* invalidate entry in cache */ /* * cache statistics @@ -109,9 +109,7 @@ static struct { * Service side authenticator for AUTH_DES */ enum auth_stat -_svcauth_des(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; +_svcauth_des(struct svc_req *rqst, struct rpc_msg *msg) { long *ixdr; @@ -355,7 +353,7 @@ _svcauth_des(rqst, msg) * Initialize the cache */ static void -cache_init() +cache_init(void) { int i; @@ -378,7 +376,7 @@ cache_init() * Find the lru victim */ static short -cache_victim() +cache_victim(void) { return (authdes_lru[AUTHDES_CACHESZ-1]); } @@ -387,8 +385,7 @@ cache_victim() * Note that sid was referenced */ static void -cache_ref(sid) - short sid; +cache_ref(short sid) { int i; short curr; @@ -410,10 +407,7 @@ cache_ref(sid) * return the spot in the cache. */ static short -cache_spot(key, name, timestamp) - des_block *key; - char *name; - struct timeval *timestamp; +cache_spot(des_block *key, char *name, struct timeval *timestamp) { struct cache_entry *cp; int i; @@ -461,12 +455,8 @@ struct bsdcred { * the credential. */ int -authdes_getucred(adc, uid, gid, grouplen, groups) - struct authdes_cred *adc; - uid_t *uid; - gid_t *gid; - int *grouplen; - gid_t *groups; +authdes_getucred(struct authdes_cred *adc, uid_t *uid, gid_t *gid, + int *grouplen, gid_t *groups) { unsigned sid; int i; @@ -525,8 +515,7 @@ authdes_getucred(adc, uid, gid, grouplen, groups) } static void -invalidate(cred) - char *cred; +invalidate(char *cred) { if (cred == NULL) { return; diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index 7e837d319df54..8e5118356dcda 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -56,9 +56,7 @@ __FBSDID("$FreeBSD$"); * Unix longhand authenticator */ enum auth_stat -_svcauth_unix(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; +_svcauth_unix(struct svc_req *rqst, struct rpc_msg *msg) { enum auth_stat stat; XDR xdrs; @@ -147,9 +145,7 @@ done: */ /*ARGSUSED*/ enum auth_stat -_svcauth_short(rqst, msg) - struct svc_req *rqst; - struct rpc_msg *msg; +_svcauth_short(struct svc_req *rqst, struct rpc_msg *msg) { return (AUTH_REJECTEDCRED); } diff --git a/lib/libc/rpc/svc_dg.c b/lib/libc/rpc/svc_dg.c index 980e39f1b894a..1957d64b4ea3f 100644 --- a/lib/libc/rpc/svc_dg.c +++ b/lib/libc/rpc/svc_dg.c @@ -102,10 +102,7 @@ static const char svc_dg_err4[] = "cannot set IP_RECVDSTADDR"; static const char __no_mem_str[] = "out of memory"; SVCXPRT * -svc_dg_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svc_dg_create(int fd, u_int sendsize, u_int recvsize) { SVCXPRT *xprt; struct svc_dg_data *su = NULL; @@ -188,8 +185,7 @@ freedata_nowarn: /*ARGSUSED*/ static enum xprt_stat -svc_dg_stat(xprt) - SVCXPRT *xprt; +svc_dg_stat(SVCXPRT *xprt) { return (XPRT_IDLE); } @@ -250,9 +246,7 @@ svc_dg_recvfrom(int fd, char *buf, int buflen, } static bool_t -svc_dg_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_dg_recv(SVCXPRT *xprt, struct rpc_msg *msg) { struct svc_dg_data *su = su_data(xprt); XDR *xdrs = &(su->su_xdrs); @@ -335,9 +329,7 @@ svc_dg_sendto(int fd, char *buf, int buflen, } static bool_t -svc_dg_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_dg_reply(SVCXPRT *xprt, struct rpc_msg *msg) { struct svc_dg_data *su = su_data(xprt); XDR *xdrs = &(su->su_xdrs); @@ -378,10 +370,7 @@ svc_dg_reply(xprt, msg) } static bool_t -svc_dg_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_dg_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { struct svc_dg_data *su; @@ -392,10 +381,7 @@ svc_dg_getargs(xprt, xdr_args, args_ptr) } static bool_t -svc_dg_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_dg_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { XDR *xdrs = &(su_data(xprt)->su_xdrs); @@ -404,8 +390,7 @@ svc_dg_freeargs(xprt, xdr_args, args_ptr) } static void -svc_dg_destroy(xprt) - SVCXPRT *xprt; +svc_dg_destroy(SVCXPRT *xprt) { struct svc_dg_data *su = su_data(xprt); @@ -428,17 +413,13 @@ svc_dg_destroy(xprt) static bool_t /*ARGSUSED*/ -svc_dg_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; +svc_dg_control(SVCXPRT *xprt, const u_int rq, void *in) { return (FALSE); } static void -svc_dg_ops(xprt) - SVCXPRT *xprt; +svc_dg_ops(SVCXPRT *xprt) { static struct xp_ops ops; static struct xp_ops2 ops2; @@ -536,9 +517,7 @@ static const char alloc_err[] = "could not allocate cache "; static const char enable_err[] = "cache already enabled"; int -svc_dg_enablecache(transp, size) - SVCXPRT *transp; - u_int size; +svc_dg_enablecache(SVCXPRT *transp, u_int size) { struct svc_dg_data *su = su_data(transp); struct cl_cache *uc; @@ -593,9 +572,7 @@ static const char cache_set_err2[] = "victim alloc failed"; static const char cache_set_err3[] = "could not allocate new rpc buffer"; static void -cache_set(xprt, replylen) - SVCXPRT *xprt; - size_t replylen; +cache_set(SVCXPRT *xprt, size_t replylen) { cache_ptr victim; cache_ptr *vicp; @@ -683,11 +660,7 @@ cache_set(xprt, replylen) * return 1 if found, 0 if not found and set the stage for cache_set() */ static int -cache_get(xprt, msg, replyp, replylenp) - SVCXPRT *xprt; - struct rpc_msg *msg; - char **replyp; - size_t *replylenp; +cache_get(SVCXPRT *xprt, struct rpc_msg *msg, char **replyp, size_t *replylenp) { u_int loc; cache_ptr ent; diff --git a/lib/libc/rpc/svc_generic.c b/lib/libc/rpc/svc_generic.c index 21569c04214f7..d3db61277fce4 100644 --- a/lib/libc/rpc/svc_generic.c +++ b/lib/libc/rpc/svc_generic.c @@ -72,13 +72,14 @@ extern int __svc_vc_setflag(SVCXPRT *, int); * It creates a link list of all the handles it could create. * If svc_create() is called multiple times, it uses the handle * created earlier instead of creating a new handle every time. + * + * prognum - Program number + * versnum - Version number + * nettype - Networktype token */ int -svc_create(dispatch, prognum, versnum, nettype) - void (*dispatch)(struct svc_req *, SVCXPRT *); - rpcprog_t prognum; /* Program number */ - rpcvers_t versnum; /* Version number */ - const char *nettype; /* Networktype token */ +svc_create(void (*dispatch)(struct svc_req *, SVCXPRT *), + rpcprog_t prognum, rpcvers_t versnum, const char *nettype) { struct xlist { SVCXPRT *xprt; /* Server handle */ @@ -143,13 +144,14 @@ svc_create(dispatch, prognum, versnum, nettype) * The high level interface to svc_tli_create(). * It tries to create a server for "nconf" and registers the service * with the rpcbind. It calls svc_tli_create(); + * + * prognum - Program number + * versnum - Version number + * ncofn - Netconfig structure for the network */ SVCXPRT * -svc_tp_create(dispatch, prognum, versnum, nconf) - void (*dispatch)(struct svc_req *, SVCXPRT *); - rpcprog_t prognum; /* Program number */ - rpcvers_t versnum; /* Version number */ - const struct netconfig *nconf; /* Netconfig structure for the network */ +svc_tp_create(void (*dispatch)(struct svc_req *, SVCXPRT *), + rpcprog_t prognum, rpcvers_t versnum, const struct netconfig *nconf) { SVCXPRT *xprt; @@ -184,14 +186,16 @@ svc_tp_create(dispatch, prognum, versnum, nconf) * is set to 8. * * If sendsz or recvsz are zero, their default values are chosen. + * + * fd - Connection end point + * nconf - Netconfig struct for nettoken + * bindaddr - Local bind address + * sendsz - Max sendsize + * recvxz - Max recvsize */ SVCXPRT * -svc_tli_create(fd, nconf, bindaddr, sendsz, recvsz) - int fd; /* Connection end point */ - const struct netconfig *nconf; /* Netconfig struct for nettoken */ - const struct t_bind *bindaddr; /* Local bind address */ - u_int sendsz; /* Max sendsize */ - u_int recvsz; /* Max recvsize */ +svc_tli_create(int fd, const struct netconfig *nconf, + const struct t_bind *bindaddr, u_int sendsz, u_int recvsz) { SVCXPRT *xprt = NULL; /* service handle */ bool_t madefd = FALSE; /* whether fd opened here */ diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c index ffa912293d05c..91593350453c2 100644 --- a/lib/libc/rpc/svc_raw.c +++ b/lib/libc/rpc/svc_raw.c @@ -82,7 +82,7 @@ static bool_t svc_raw_control(SVCXPRT *, const u_int, void *); char *__rpc_rawcombuf = NULL; SVCXPRT * -svc_raw_create() +svc_raw_create(void) { struct svc_raw_private *srp; /* VARIABLES PROTECTED BY svcraw_lock: svc_raw_private, srp */ @@ -125,17 +125,14 @@ svc_raw_create() /*ARGSUSED*/ static enum xprt_stat -svc_raw_stat(xprt) -SVCXPRT *xprt; /* args needed to satisfy ANSI-C typechecking */ +svc_raw_stat(SVCXPRT *xprt) { return (XPRT_IDLE); } /*ARGSUSED*/ static bool_t -svc_raw_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_raw_recv(SVCXPRT *xprt, struct rpc_msg *msg) { struct svc_raw_private *srp; XDR *xdrs; @@ -159,9 +156,7 @@ svc_raw_recv(xprt, msg) /*ARGSUSED*/ static bool_t -svc_raw_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_raw_reply(SVCXPRT *xprt, struct rpc_msg *msg) { struct svc_raw_private *srp; XDR *xdrs; @@ -201,10 +196,7 @@ svc_raw_reply(xprt, msg) /*ARGSUSED*/ static bool_t -svc_raw_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_raw_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { struct svc_raw_private *srp; @@ -222,10 +214,7 @@ svc_raw_getargs(xprt, xdr_args, args_ptr) /*ARGSUSED*/ static bool_t -svc_raw_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_raw_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { struct svc_raw_private *srp; XDR *xdrs; @@ -245,24 +234,19 @@ svc_raw_freeargs(xprt, xdr_args, args_ptr) /*ARGSUSED*/ static void -svc_raw_destroy(xprt) -SVCXPRT *xprt; +svc_raw_destroy(SVCXPRT *xprt) { } /*ARGSUSED*/ static bool_t -svc_raw_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; +svc_raw_control(SVCXPRT *xprt, const u_int rq, void *in) { return (FALSE); } static void -svc_raw_ops(xprt) - SVCXPRT *xprt; +svc_raw_ops(SVCXPRT *xprt) { static struct xp_ops ops; static struct xp_ops2 ops2; diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index 08c8a8427050a..9b0089b3dd3f6 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include "mt_misc.h" void -svc_run() +svc_run(void) { fd_set readfds, cleanfds; struct timeval timeout; @@ -89,7 +89,7 @@ svc_run() * more work to do. */ void -svc_exit() +svc_exit(void) { rwlock_wrlock(&svc_fd_lock); FD_ZERO(&svc_fdset); diff --git a/lib/libc/rpc/svc_simple.c b/lib/libc/rpc/svc_simple.c index b97f974a2998a..4713efcfc558a 100644 --- a/lib/libc/rpc/svc_simple.c +++ b/lib/libc/rpc/svc_simple.c @@ -92,16 +92,18 @@ static const char __no_mem_str[] = "out of memory"; * is also limited by the recvsize for that transport, even if it is * a COTS transport. This may be wrong, but for cases like these, they * should not use the simplified interfaces like this. + * + * prognum - program number + * versnum - version number + * procnum - procedure number + * progname - Server routine + * inproc, outproc - in/out XDR procedures + * nettype - nettype */ - int -rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype) - rpcprog_t prognum; /* program number */ - rpcvers_t versnum; /* version number */ - rpcproc_t procnum; /* procedure number */ - char *(*progname)(char *); /* Server routine */ - xdrproc_t inproc, outproc; /* in/out XDR procedures */ - char *nettype; /* nettype */ +rpc_reg(rpcprog_t prognum, rpcvers_t versnum, rpcproc_t procnum, + char *(*progname)(char *), xdrproc_t inproc, xdrproc_t outproc, + char *nettype) { struct netconfig *nconf; int done = FALSE; @@ -242,9 +244,7 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype) */ static void -universal(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; +universal(struct svc_req *rqstp, SVCXPRT *transp) { rpcprog_t prog; rpcvers_t vers; diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c index aa45396667898..ca4b93e4fbf7c 100644 --- a/lib/libc/rpc/svc_vc.c +++ b/lib/libc/rpc/svc_vc.c @@ -123,10 +123,7 @@ struct cf_conn { /* kept in xprt->xp_p1 for actual connection */ * 0 => use the system default. */ SVCXPRT * -svc_vc_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svc_vc_create(int fd, u_int sendsize, u_int recvsize) { SVCXPRT *xprt = NULL; struct cf_rendezvous *r = NULL; @@ -186,10 +183,7 @@ cleanup_svc_vc_create: * descriptor as its first input. */ SVCXPRT * -svc_fd_create(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +svc_fd_create(int fd, u_int sendsize, u_int recvsize) { struct sockaddr_storage ss; socklen_t slen; @@ -243,10 +237,7 @@ freedata: } static SVCXPRT * -makefd_xprt(fd, sendsize, recvsize) - int fd; - u_int sendsize; - u_int recvsize; +makefd_xprt(int fd, u_int sendsize, u_int recvsize) { SVCXPRT *xprt; struct cf_conn *cd; @@ -285,9 +276,7 @@ done: /*ARGSUSED*/ static bool_t -rendezvous_request(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +rendezvous_request(SVCXPRT *xprt, struct rpc_msg *msg) { int sock, flags; struct cf_rendezvous *r; @@ -366,16 +355,14 @@ again: /*ARGSUSED*/ static enum xprt_stat -rendezvous_stat(xprt) - SVCXPRT *xprt; +rendezvous_stat(SVCXPRT *xprt) { return (XPRT_IDLE); } static void -svc_vc_destroy(xprt) - SVCXPRT *xprt; +svc_vc_destroy(SVCXPRT *xprt) { assert(xprt != NULL); @@ -384,8 +371,7 @@ svc_vc_destroy(xprt) } static void -__svc_vc_dodestroy(xprt) - SVCXPRT *xprt; +__svc_vc_dodestroy(SVCXPRT *xprt) { struct cf_conn *cd; struct cf_rendezvous *r; @@ -417,19 +403,13 @@ __svc_vc_dodestroy(xprt) /*ARGSUSED*/ static bool_t -svc_vc_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; +svc_vc_control(SVCXPRT *xprt, const u_int rq, void *in) { return (FALSE); } static bool_t -svc_vc_rendezvous_control(xprt, rq, in) - SVCXPRT *xprt; - const u_int rq; - void *in; +svc_vc_rendezvous_control(SVCXPRT *xprt, const u_int rq, void *in) { struct cf_rendezvous *cfp; @@ -457,10 +437,7 @@ svc_vc_rendezvous_control(xprt, rq, in) * fatal for the connection. */ static int -read_vc(xprtp, buf, len) - void *xprtp; - void *buf; - int len; +read_vc(void *xprtp, void *buf, int len) { SVCXPRT *xprt; int sock; @@ -520,10 +497,7 @@ fatal_err: * Any error is fatal and the connection is closed. */ static int -write_vc(xprtp, buf, len) - void *xprtp; - void *buf; - int len; +write_vc(void *xprtp, void *buf, int len) { SVCXPRT *xprt; int i, cnt; @@ -567,8 +541,7 @@ write_vc(xprtp, buf, len) } static enum xprt_stat -svc_vc_stat(xprt) - SVCXPRT *xprt; +svc_vc_stat(SVCXPRT *xprt) { struct cf_conn *cd; @@ -584,9 +557,7 @@ svc_vc_stat(xprt) } static bool_t -svc_vc_recv(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg) { struct cf_conn *cd; XDR *xdrs; @@ -614,10 +585,7 @@ svc_vc_recv(xprt, msg) } static bool_t -svc_vc_getargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_vc_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { struct cf_conn *cd; @@ -628,10 +596,7 @@ svc_vc_getargs(xprt, xdr_args, args_ptr) } static bool_t -svc_vc_freeargs(xprt, xdr_args, args_ptr) - SVCXPRT *xprt; - xdrproc_t xdr_args; - void *args_ptr; +svc_vc_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr) { XDR *xdrs; @@ -645,9 +610,7 @@ svc_vc_freeargs(xprt, xdr_args, args_ptr) } static bool_t -svc_vc_reply(xprt, msg) - SVCXPRT *xprt; - struct rpc_msg *msg; +svc_vc_reply(SVCXPRT *xprt, struct rpc_msg *msg) { struct cf_conn *cd; XDR *xdrs; @@ -689,8 +652,7 @@ svc_vc_reply(xprt, msg) } static void -svc_vc_ops(xprt) - SVCXPRT *xprt; +svc_vc_ops(SVCXPRT *xprt) { static struct xp_ops ops; static struct xp_ops2 ops2; @@ -713,8 +675,7 @@ svc_vc_ops(xprt) } static void -svc_vc_rendezvous_ops(xprt) - SVCXPRT *xprt; +svc_vc_rendezvous_ops(SVCXPRT *xprt) { static struct xp_ops ops; static struct xp_ops2 ops2; diff --git a/lib/libc/sparc64/gen/_set_tp.c b/lib/libc/sparc64/gen/_set_tp.c index cf9db2676937e..7632951c4b8cd 100644 --- a/lib/libc/sparc64/gen/_set_tp.c +++ b/lib/libc/sparc64/gen/_set_tp.c @@ -25,6 +25,7 @@ * * $FreeBSD$ */ +#include "libc_private.h" void _set_tp(void *tpval) diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c index 0b61315dbfc3a..f53df35da0784 100644 --- a/lib/libc/stdio/_flock_stub.c +++ b/lib/libc/stdio/_flock_stub.c @@ -55,6 +55,9 @@ __weak_reference(_flockfile_debug_stub, _flockfile_debug); __weak_reference(_ftrylockfile, ftrylockfile); __weak_reference(_funlockfile, funlockfile); +void _flockfile_debug_stub(FILE *, char *, int); +int _ftrylockfile(FILE *); + void _flockfile(FILE *fp) { diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c index 6d9087b09c8f5..84394960363c7 100644 --- a/lib/libc/stdio/fgetwln.c +++ b/lib/libc/stdio/fgetwln.c @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include "local.h" #include "xlocale_private.h" +wchar_t *fgetwln_l(FILE * __restrict, size_t *, locale_t); + wchar_t * fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale) { diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c index be196b73c687b..0eabe82d753fb 100644 --- a/lib/libc/stdio/findfp.c +++ b/lib/libc/stdio/findfp.c @@ -113,7 +113,7 @@ moreglue(int n) * Find a free FILE for fopen et al. */ FILE * -__sfp() +__sfp(void) { FILE *fp; int n; @@ -164,6 +164,7 @@ found: */ __warn_references(f_prealloc, "warning: this program uses f_prealloc(), which is not recommended."); +void f_prealloc(void); void f_prealloc(void) @@ -195,7 +196,7 @@ f_prealloc(void) * The name `_cleanup' is, alas, fairly well known outside stdio. */ void -_cleanup() +_cleanup(void) { /* (void) _fwalk(fclose); */ (void) _fwalk(__sflush); /* `cheating' */ @@ -205,7 +206,7 @@ _cleanup() * __sinit() is called whenever stdio's internal variables must be set up. */ void -__sinit() +__sinit(void) { /* Make sure we clean up on exit. */ diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c index 21040bc8c4163..2815072f866ed 100644 --- a/lib/libc/stdio/getchar.c +++ b/lib/libc/stdio/getchar.c @@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$"); #undef getchar_unlocked int -getchar() +getchar(void) { int retval; FLOCKFILE(stdin); diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c index c67d1e456a343..e5a2be1d97be9 100644 --- a/lib/libc/stdio/tmpfile.c +++ b/lib/libc/stdio/tmpfile.c @@ -46,9 +46,10 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <paths.h> #include "un-namespace.h" +#include "libc_private.h" FILE * -tmpfile() +tmpfile(void) { sigset_t set, oset; FILE *fp; @@ -69,7 +70,7 @@ tmpfile() return (NULL); sigfillset(&set); - (void)_sigprocmask(SIG_BLOCK, &set, &oset); + (void)__libc_sigprocmask(SIG_BLOCK, &set, &oset); fd = mkstemp(buf); if (fd != -1) @@ -77,7 +78,7 @@ tmpfile() free(buf); - (void)_sigprocmask(SIG_SETMASK, &oset, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oset, NULL); if (fd == -1) return (NULL); diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 50f0690b66782..b5372631840b8 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -814,9 +814,7 @@ match_failure: * considered part of the scanset. */ static const u_char * -__sccl(tab, fmt) - char *tab; - const u_char *fmt; +__sccl(char *tab, const u_char *fmt) { int c, n, v, i; struct xlocale_collate *table = diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index b137e490eb2f7..2335c400da776 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" void -abort() +abort(void) { struct sigaction act; @@ -61,7 +61,7 @@ abort() * any errors -- ISO C doesn't allow abort to return anyway. */ sigdelset(&act.sa_mask, SIGABRT); - (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); (void)raise(SIGABRT); /* @@ -71,9 +71,9 @@ abort() act.sa_handler = SIG_DFL; act.sa_flags = 0; sigfillset(&act.sa_mask); - (void)_sigaction(SIGABRT, &act, NULL); + (void)__libc_sigaction(SIGABRT, &act, NULL); sigdelset(&act.sa_mask, SIGABRT); - (void)_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &act.sa_mask, NULL); (void)raise(SIGABRT); exit(1); } diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c index 87589474eb3c4..367b114f745de 100644 --- a/lib/libc/stdlib/abs.c +++ b/lib/libc/stdlib/abs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> int -abs(j) - int j; +abs(int j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c index 0a5048a97018a..eda57032f670c 100644 --- a/lib/libc/stdlib/atexit.c +++ b/lib/libc/stdlib/atexit.c @@ -82,6 +82,9 @@ struct atexit { static struct atexit *__atexit; /* points to head of LIFO stack */ typedef DECLARE_BLOCK(void, atexit_block, void); +int atexit_b(atexit_block); +int __cxa_atexit(void (*)(void *), void *, void *); + /* * Register the function described by 'fptr' to be called at application * exit or owning shared object unload time. This is a helper function diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c index 3514ae3b69277..0458eb968331e 100644 --- a/lib/libc/stdlib/atof.c +++ b/lib/libc/stdlib/atof.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> double -atof(ascii) - const char *ascii; +atof(const char *ascii) { return strtod(ascii, (char **)NULL); } double -atof_l(ascii, locale) - const char *ascii; - locale_t locale; +atof_l(const char *ascii, locale_t locale) { return strtod_l(ascii, (char **)NULL, locale); } diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c index 564273e952cf4..9f92fcdad4be8 100644 --- a/lib/libc/stdlib/atoi.c +++ b/lib/libc/stdlib/atoi.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> int -atoi(str) - const char *str; +atoi(const char *str) { return (int)strtol(str, (char **)NULL, 10); } int -atoi_l(str, locale) - const char *str; - locale_t locale; +atoi_l(const char *str, locale_t locale) { return (int)strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c index d30aa18a83985..bd8ef07c544d3 100644 --- a/lib/libc/stdlib/atol.c +++ b/lib/libc/stdlib/atol.c @@ -42,16 +42,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long -atol(str) - const char *str; +atol(const char *str) { return strtol(str, (char **)NULL, 10); } long -atol_l(str, locale) - const char *str; - locale_t locale; +atol_l(const char *str, locale_t locale) { return strtol_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c index af528382bd7c3..093fde5d9f919 100644 --- a/lib/libc/stdlib/atoll.c +++ b/lib/libc/stdlib/atoll.c @@ -39,16 +39,13 @@ __FBSDID("$FreeBSD$"); #include <xlocale.h> long long -atoll(str) - const char *str; +atoll(const char *str) { return strtoll(str, (char **)NULL, 10); } long long -atoll_l(str, locale) - const char *str; - locale_t locale; +atoll_l(const char *str, locale_t locale) { return strtoll_l(str, (char **)NULL, 10, locale); } diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c index 4a1dd525a67de..8303f971b5623 100644 --- a/lib/libc/stdlib/bsearch.c +++ b/lib/libc/stdlib/bsearch.c @@ -61,20 +61,12 @@ __FBSDID("$FreeBSD$"); */ #ifdef I_AM_BSEARCH_B void * -bsearch_b(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - DECLARE_BLOCK(int, compar, const void *, const void *); +bsearch_b(const void *key, const void *base0, size_t nmemb, size_t size, + DECLARE_BLOCK(int, compar, const void *, const void *)) #else void * -bsearch(key, base0, nmemb, size, compar) - const void *key; - const void *base0; - size_t nmemb; - size_t size; - int (*compar)(const void *, const void *); +bsearch(const void *key, const void *base0, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { const char *base = base0; diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c index 145eb9d7c7cb7..a656e04586c04 100644 --- a/lib/libc/stdlib/exit.c +++ b/lib/libc/stdlib/exit.c @@ -56,8 +56,7 @@ int __isthreaded = 0; * Exit, flushing stdio buffers if necessary. */ void -exit(status) - int status; +exit(int status) { /* Ensure that the auto-initialization routine is linked in: */ extern int _thread_autoinit_dummy_decl; diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c index 673a6a17e322b..a7a4a26e2a116 100644 --- a/lib/libc/stdlib/heapsort.c +++ b/lib/libc/stdlib/heapsort.c @@ -138,6 +138,12 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); } \ } +#ifdef I_AM_HEAPSORT_B +int heapsort_b(void *, size_t, size_t, heapsort_block); +#else +int heapsort(void *, size_t, size_t, + int (*)(const void *, const void *)); +#endif /* * Heapsort -- Knuth, Vol. 3, page 145. Runs in O (N lg N), both average * and worst. While heapsort is faster than the worst case of quicksort, @@ -147,16 +153,11 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); */ #ifdef I_AM_HEAPSORT_B int -heapsort_b(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - heapsort_block compar; +heapsort_b(void *vbase, size_t nmemb, size_t size, heapsort_block compar) #else int -heapsort(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - int (*compar)(const void *, const void *); +heapsort(void *vbase, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { size_t cnt, i, j, l; diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c index 816370eee2b2f..ef068826c2f30 100644 --- a/lib/libc/stdlib/labs.c +++ b/lib/libc/stdlib/labs.c @@ -36,8 +36,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> long -labs(j) - long j; +labs(long j) { return(j < 0 ? -j : j); } diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 6b368c34f21e4..55b3a0c4fae1d 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -99,19 +99,21 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t); ((u_char *)0 + \ (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) +#ifdef I_AM_MERGESORT_B +int mergesort_b(void *, size_t, size_t, cmp_t); +#else +int mergesort(void *, size_t, size_t, cmp_t); +#endif + /* * Arguments are as for qsort. */ int #ifdef I_AM_MERGESORT_B -mergesort_b(base, nmemb, size, cmp) +mergesort_b(void *base, size_t nmemb, size_t size, cmp_t cmp) #else -mergesort(base, nmemb, size, cmp) +mergesort(void *base, size_t nmemb, size_t size, cmp_t cmp) #endif - void *base; - size_t nmemb; - size_t size; - cmp_t cmp; { size_t i; int sense; @@ -271,10 +273,7 @@ COPY: b = t; * is defined. Otherwise simple pairwise merging is used.) */ void -setup(list1, list2, n, size, cmp) - size_t n, size; - u_char *list1, *list2; - cmp_t cmp; +setup(u_char *list1, u_char *list2, size_t n, size_t size, cmp_t cmp) { int i, length, size2, tmp, sense; u_char *f1, *f2, *s, *l2, *last, *p2; @@ -345,10 +344,7 @@ setup(list1, list2, n, size, cmp) * last 4 elements. */ static void -insertionsort(a, n, size, cmp) - u_char *a; - size_t n, size; - cmp_t cmp; +insertionsort(u_char *a, size_t n, size_t size, cmp_t cmp) { u_char *ai, *s, *t, *u, tmp; int i; diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index e97ea9272dd69..08816887cf79f 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -64,9 +64,7 @@ static inline void swapfunc(char *, char *, int, int, int); es % sizeof(TYPE) ? 2 : es == sizeof(TYPE) ? 0 : 1; static inline void -swapfunc(a, b, n, swaptype_long, swaptype_int) - char *a, *b; - int n, swaptype_long, swaptype_int; +swapfunc( char *a, char *b, int n, int swaptype_long, int swaptype_int) { if (swaptype_long <= 1) swapcode(long, a, b, n) diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index 8310e6dea16c5..205f7765a444f 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -88,10 +88,7 @@ static void r_sort_b(const u_char **, const u_char **, int, int, } int -radixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +radixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr; int c; @@ -103,10 +100,7 @@ radixsort(a, n, tab, endch) } int -sradixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +sradixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr, **ta; int c; @@ -131,11 +125,7 @@ sradixsort(a, n, tab, endch) /* Unstable, in-place sort. */ static void -r_sort_a(a, n, i, tr, endch) - const u_char **a; - int n, i; - const u_char *tr; - u_int endch; +r_sort_a(const u_char **a, int n, int i, const u_char *tr, u_int endch) { static int count[256], nc, bmin; int c; @@ -233,11 +223,8 @@ r_sort_a(a, n, i, tr, endch) /* Stable sort, requiring additional memory. */ static void -r_sort_b(a, ta, n, i, tr, endch) - const u_char **a, **ta; - int n, i; - const u_char *tr; - u_int endch; +r_sort_b(const u_char **a, const u_char **ta, int n, int i, const u_char *tr, + u_int endch) { static int count[256], nc, bmin; int c; @@ -304,12 +291,9 @@ r_sort_b(a, ta, n, i, tr, endch) } } +/* insertion sort */ static inline void -simplesort(a, n, b, tr, endch) /* insertion sort */ - const u_char **a; - int n, b; - const u_char *tr; - u_int endch; +simplesort(const u_char **a, int n, int b, const u_char *tr, u_int endch) { u_char ch; const u_char **ak, **ai, *s, *t; diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c index 4f4aa8dc2d912..b8871a2a4a46a 100644 --- a/lib/libc/stdlib/rand.c +++ b/lib/libc/stdlib/rand.c @@ -111,14 +111,13 @@ static u_long next = #endif int -rand() +rand(void) { return (do_rand(&next)); } void -srand(seed) -u_int seed; +srand(u_int seed) { next = seed; #ifndef USE_WEAK_SEEDING @@ -136,7 +135,7 @@ u_int seed; * data from the kernel. */ void -sranddev() +sranddev(void) { int mib[2]; size_t len; diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index bd9ea5a30fdc8..2b298e45a6d63 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -70,16 +70,20 @@ __libc_system(const char *command) (void)sigaddset(&newsigblock, SIGCHLD); (void)sigaddset(&newsigblock, SIGINT); (void)sigaddset(&newsigblock, SIGQUIT); - (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); + (void)__libc_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); switch(pid = vfork()) { + /* + * In the child, use unwrapped syscalls. libthr is in + * undefined state after vfork(). + */ case -1: /* error */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); return (-1); case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + (void)__sys_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); _exit(127); } @@ -92,16 +96,16 @@ __libc_system(const char *command) memset(&ign, 0, sizeof(ign)); ign.sa_handler = SIG_IGN; (void)sigemptyset(&ign.sa_mask); - (void)_sigaction(SIGINT, &ign, &intact); - (void)_sigaction(SIGQUIT, &ign, &quitact); + (void)__libc_sigaction(SIGINT, &ign, &intact); + (void)__libc_sigaction(SIGQUIT, &ign, &quitact); savedpid = pid; do { pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); - return(pid == -1 ? -1 : pstat); + (void)__libc_sigaction(SIGINT, &intact, NULL); + (void)__libc_sigaction(SIGQUIT, &quitact, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); + return (pid == -1 ? -1 : pstat); } __weak_reference(__libc_system, __system); diff --git a/lib/libc/stdlib/tfind.c b/lib/libc/stdlib/tfind.c index c5d66cf41612c..0ad391e799814 100644 --- a/lib/libc/stdlib/tfind.c +++ b/lib/libc/stdlib/tfind.c @@ -23,12 +23,15 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <search.h> -/* find a node, or return 0 */ +/* + * find a node, or return 0 + * + * vkey - key to be found + * vrootp - address of the tree root + */ void * -tfind(vkey, vrootp, compar) - const void *vkey; /* key to be found */ - void * const *vrootp; /* address of the tree root */ - int (*compar)(const void *, const void *); +tfind(const void *vkey, void * const *vrootp, + int (*compar)(const void *, const void *)) { node_t **rootp = (node_t **)vrootp; diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 898101136ea5d..838ebdde3e5be 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -127,13 +127,8 @@ strftime(char * __restrict s, size_t maxsize, const char * __restrict format, } static char * -_fmt(format, t, pt, ptlim, warnp, loc) -const char * format; -const struct tm * const t; -char * pt; -const char * const ptlim; -int * warnp; -locale_t loc; +_fmt(const char *format, const struct tm * const t, char *pt, + const char * const ptlim, int *warnp, locale_t loc) { int Ealternative, Oalternative, PadIndex; struct lc_time_T *tptr = __get_current_time_locale(loc); @@ -592,12 +587,8 @@ label: } static char * -_conv(n, format, pt, ptlim, loc) -const int n; -const char * const format; -char * const pt; -const char * const ptlim; -locale_t loc; +_conv(const int n, const char * const format, char * const pt, + const char * const ptlim, locale_t loc) { char buf[INT_STRLEN_MAXIMUM(int) + 1]; @@ -606,10 +597,7 @@ locale_t loc; } static char * -_add(str, pt, ptlim) -const char * str; -char * pt; -const char * const ptlim; +_add(const char *str, char *pt, const char * const ptlim) { while (pt < ptlim && (*pt = *str++) != '\0') ++pt; @@ -625,14 +613,8 @@ const char * const ptlim; */ static char * -_yconv(a, b, convert_top, convert_yy, pt, ptlim, loc) -const int a; -const int b; -const int convert_top; -const int convert_yy; -char * pt; -const char * const ptlim; -locale_t loc; +_yconv(const int a, const int b, const int convert_top, const int convert_yy, + char *pt, const char * const ptlim, locale_t loc) { register int lead; register int trail; diff --git a/lib/libc/string/strchrnul.c b/lib/libc/string/strchrnul.c index 98e652db83c5b..893468cbdcbc9 100644 --- a/lib/libc/string/strchrnul.c +++ b/lib/libc/string/strchrnul.c @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); __weak_reference(__strchrnul, strchrnul); +char *__strchrnul(const char *, int); + char * __strchrnul(const char *p, int ch) { diff --git a/lib/libc/string/strndup.c b/lib/libc/string/strndup.c index 2897e933193c8..bee944db167a2 100644 --- a/lib/libc/string/strndup.c +++ b/lib/libc/string/strndup.c @@ -1,32 +1,19 @@ -/* $NetBSD: strndup.c,v 1.3 2007/01/14 23:41:24 cbiere Exp $ */ +/* $OpenBSD: strndup.c,v 1.1 2010/05/18 22:24:55 tedu Exp $ */ /* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com> * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/cdefs.h> @@ -37,15 +24,17 @@ __FBSDID("$FreeBSD$"); #include <string.h> char * -strndup(const char *str, size_t n) +strndup(const char *str, size_t maxlen) { - size_t len; char *copy; + size_t len; + + len = strnlen(str, maxlen); + copy = malloc(len + 1); + if (copy != NULL) { + (void)memcpy(copy, str, len); + copy[len] = '\0'; + } - len = strnlen(str, n); - if ((copy = malloc(len + 1)) == NULL) - return (NULL); - memcpy(copy, str, len); - copy[len] = '\0'; - return (copy); + return copy; } diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index fad970c22f5ea..e4fe1b20f8a32 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -90,8 +90,6 @@ ASM+=$(_asm) .endif .endfor -OBJS+= ${ASM} ${PSEUDO} - SASM= ${ASM:S/.o/.S/} SPSEUDO= ${PSEUDO:S/.o/.S/} @@ -104,7 +102,7 @@ SYM_MAPS+= ${LIBC_SRCTOP}/sys/Symbol.map CLEANFILES+= ${SASM} ${SPSEUDO} .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \ - ${MACHINE_CPUARCH} == "powerpc" + ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_ARCH:Marmv6*} NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n' .else NOTE_GNU_STACK='' diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c index 28cc31dde1775..8a065bf720024 100644 --- a/lib/libc/sys/__error.c +++ b/lib/libc/sys/__error.c @@ -30,6 +30,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "libc_private.h" + extern int errno; static int * diff --git a/lib/libc/sys/close.c b/lib/libc/sys/close.c index 02e74c633001d..f7b36f85ddd57 100644 --- a/lib/libc/sys/close.c +++ b/lib/libc/sys/close.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <unistd.h> #include "libc_private.h" __weak_reference(__sys_close, __close); diff --git a/lib/libc/sys/fsync.c b/lib/libc/sys/fsync.c index 3fff428f1ab78..5f1512932baa9 100644 --- a/lib/libc/sys/fsync.c +++ b/lib/libc/sys/fsync.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <unistd.h> #include "libc_private.h" __weak_reference(__sys_fsync, __fsync); diff --git a/lib/libc/sys/msync.c b/lib/libc/sys/msync.c index 3c6879f04c647..d86cc0462dd8a 100644 --- a/lib/libc/sys/msync.c +++ b/lib/libc/sys/msync.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/fcntl.h> +#include <sys/mman.h> #include "libc_private.h" __weak_reference(__sys_msync, __msync); diff --git a/lib/libc/sys/posix_fadvise.2 b/lib/libc/sys/posix_fadvise.2 index 8691f6b2b7568..641bc9bff5ef1 100644 --- a/lib/libc/sys/posix_fadvise.2 +++ b/lib/libc/sys/posix_fadvise.2 @@ -28,7 +28,7 @@ .\" @(#)madvise.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd January 30, 2014 +.Dd October 3, 2015 .Dt POSIX_FADVISE 2 .Os .Sh NAME @@ -89,11 +89,13 @@ read or written. Future access to this data may require a read operation. .El .Sh RETURN VALUES -.Rv -std posix_fadvise -.Sh ERRORS -The +If successful, .Fn posix_fadvise -system call returns zero on success, and an error on failure: +returns zero. +It returns an error on failure, without setting +.Va errno . +.Sh ERRORS +Possible failure conditions: .Bl -tag -width Er .It Bq Er EBADF The diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 71b432f4e70f9..5c93438d67de4 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd July 3, 2015 +.Dd October 6, 2015 .Dt PTRACE 2 .Os .Sh NAME @@ -307,6 +307,8 @@ struct ptrace_lwpinfo { siginfo_t pl_siginfo; char pl_tdname[MAXCOMLEN + 1]; int pl_child_pid; + u_int pl_syscall_code; + u_int pl_syscall_narg; }; .Ed .Pp @@ -395,6 +397,27 @@ stop when .Dv PL_FLAG_FORKED is set in .Va pl_flags . +.It pl_syscall_code +The ABI-specific identifier of the current system call. +Note that for indirect system calls this field reports the indirected +system call. +Only valid when +.Dv PL_FLAG_SCE +or +.Dv PL_FLAG_SCX +is set in +.Va pl_flags. +.It pl_syscall_narg +The number of arguments passed to the current system call not counting +the system call identifier. +Note that for indirect system calls this field reports the arguments +passed to the indirected system call. +Only valid when +.Dv PL_FLAG_SCE +or +.Dv PL_FLAG_SCX +is set in +.Va pl_flags. .El .It PT_GETNUMLWPS This request returns the number of kernel threads associated with the diff --git a/lib/libc/sys/readv.c b/lib/libc/sys/readv.c index 8c82040367cc7..567292750da02 100644 --- a/lib/libc/sys/readv.c +++ b/lib/libc/sys/readv.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/syscall.h> +#include <sys/uio.h> #include <unistd.h> #include "libc_private.h" diff --git a/lib/libc/sys/reboot.2 b/lib/libc/sys/reboot.2 index caaba5848bc4f..df4a0ecb56ef5 100644 --- a/lib/libc/sys/reboot.2 +++ b/lib/libc/sys/reboot.2 @@ -28,7 +28,7 @@ .\" @(#)reboot.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 18, 2015 .Dt REBOOT 2 .Os .Sh NAME @@ -113,6 +113,13 @@ Normally, the disks are sync'd (see before the processor is halted or rebooted. This option may be useful if file system changes have been made manually or if the processor is on fire. +.It Dv RB_REROOT +Instead of rebooting, unmount all filesystems except the one containing +currently-running executable, and mount root filesystem using the same +mechanism which is used during normal boot, based on +vfs.root.mountfrom +.Xr kenv 8 +variable. .It Dv RB_RDONLY Initially mount the root file system read-only. This is currently the default, and this option has been deprecated. @@ -159,8 +166,3 @@ The .Fn reboot system call appeared in .Bx 4.0 . -.Sh BUGS -The HP300 implementation supports neither -.Dv RB_DFLTROOT -nor -.Dv RB_KDB . diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2 index 4c7d5ad0c67a9..54d89bcc7464f 100644 --- a/lib/libc/sys/setuid.2 +++ b/lib/libc/sys/setuid.2 @@ -28,7 +28,7 @@ .\" @(#)setuid.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 13, 2015 .Dt SETUID 2 .Os .Sh NAME @@ -178,15 +178,10 @@ pseudocode(void) int fd; /* ... */ - fd = open("/path/to/sensitive/data", O_RDWR); + fd = open("/path/to/sensitive/data", O_RDWR | O_CLOEXEC); if (fd == -1) err(1, "open"); - /* - * Set close-on-exec flag; see fcntl(2) for more information. - */ - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - err(1, "fcntl(F_SETFD)"); /* ... */ execve(path, argv, environ); } diff --git a/lib/libc/sys/shmctl.2 b/lib/libc/sys/shmctl.2 index 98ddf13e8ec44..788e79f1900d4 100644 --- a/lib/libc/sys/shmctl.2 +++ b/lib/libc/sys/shmctl.2 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 17, 1995 +.Dd October 10, 2015 .Dt SHMCTL 2 .Os .Sh NAME @@ -72,15 +72,18 @@ or it must have superuser privileges. .It Dv IPC_RMID Removes the segment from the system. The removal will not take -effect until all processes having attached the segment have exited; -however, once the IPC_RMID operation has taken place, no further -processes will be allowed to attach the segment. +effect until all processes having attached the segment have exited. For the operation to succeed, the calling process's effective uid must match .Fa shm_perm.uid or .Fa shm_perm.cuid , or the process must have superuser privileges. +If the +.Va kern.ipc.shm_allow_removed +.Xr sysctl 3 +variable is set to 0, once the IPC_RMID operation has taken place, +no further processes will be allowed to attach the segment. .\" .It Dv SHM_LOCK .\" Locks the segment in memory. The calling process must have .\" superuser privileges. Not implemented in FreeBSD. diff --git a/lib/libc/sys/sigaction.c b/lib/libc/sys/sigaction.c index 7645538cf3b99..b4d65639b816e 100644 --- a/lib/libc/sys/sigaction.c +++ b/lib/libc/sys/sigaction.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" __weak_reference(__sys_sigaction, __sigaction); +__weak_reference(sigaction, __libc_sigaction); #pragma weak sigaction int diff --git a/lib/libc/sys/sigprocmask.c b/lib/libc/sys/sigprocmask.c index 40dba95563be7..d24bb89c1f790 100644 --- a/lib/libc/sys/sigprocmask.c +++ b/lib/libc/sys/sigprocmask.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" __weak_reference(__sys_sigprocmask, __sigprocmask); +__weak_reference(sigprocmask, __libc_sigprocmask); #pragma weak sigprocmask int diff --git a/lib/libc/sys/sigsuspend.c b/lib/libc/sys/sigsuspend.c index 6e47368c49c3d..1f980a117a1bb 100644 --- a/lib/libc/sys/sigsuspend.c +++ b/lib/libc/sys/sigsuspend.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" __weak_reference(__sys_sigsuspend, __sigsuspend); +__weak_reference(sigsuspend, __libc_sigsuspend); #pragma weak sigsuspend int diff --git a/lib/libc/sys/utrace.2 b/lib/libc/sys/utrace.2 index 9d24f2071c3c1..345c1fd9f49c5 100644 --- a/lib/libc/sys/utrace.2 +++ b/lib/libc/sys/utrace.2 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2014 +.Dd October 5, 2015 .Dt UTRACE 2 .Os .Sh NAME @@ -70,7 +70,8 @@ support .Sh SEE ALSO .Xr kdump 1 , .Xr ktrace 1 , -.Xr ktrace 2 +.Xr ktrace 2 , +.Xr truss 1 .Sh HISTORY The .Fn utrace diff --git a/lib/libc/sys/writev.c b/lib/libc/sys/writev.c index 6be74b3c31d18..20b10053dc59f 100644 --- a/lib/libc/sys/writev.c +++ b/lib/libc/sys/writev.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/syscall.h> +#include <sys/uio.h> #include <unistd.h> #include "libc_private.h" diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 3036ce93f8ef5..2e97151836499 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -2,8 +2,6 @@ .include <src.opts.mk> -TESTSDIR= ${TESTSBASE}/lib/libc - SUBDIR= tls_dso TESTS_SUBDIRS= c063 diff --git a/lib/libc/tests/Makefile.netbsd-tests b/lib/libc/tests/Makefile.netbsd-tests index f364b1c1b486c..32385186425fd 100644 --- a/lib/libc/tests/Makefile.netbsd-tests +++ b/lib/libc/tests/Makefile.netbsd-tests @@ -1,7 +1,7 @@ # $FreeBSD$ -OBJTOP?= ${.OBJDIR:H:H:H:H} -SRCTOP?= ${.CURDIR:H:H:H:H} -TESTSRC?= ${SRCTOP}/contrib/netbsd-tests/lib/libc/${.CURDIR:T} +TESTSRC:= ${SRCTOP}/contrib/netbsd-tests/${RELDIR:C/libc\/tests/libc/} + +TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/} .include <netbsd-tests.test.mk> diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index 5f4e1ca9c31fd..2e4565cdf318a 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/c063 - #TODO: t_o_search NETBSD_ATF_TESTS_C= faccessat diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index ed1d6caadbf2f..eb0ce395e28af 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/db - BINDIR= ${TESTSDIR} PROGS= h_db diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index f9a0bd42b6dd6..90f65736c5089 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen - ATF_TESTS_C= arc4random_test ATF_TESTS_C+= fpclassify2_test diff --git a/lib/libc/tests/gen/execve/Makefile b/lib/libc/tests/gen/execve/Makefile index 2106a1582358b..5e8bc6fb7640b 100644 --- a/lib/libc/tests/gen/execve/Makefile +++ b/lib/libc/tests/gen/execve/Makefile @@ -1,13 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen/execve - NETBSD_ATF_TESTS_C= execve_test .include "../../Makefile.netbsd-tests" diff --git a/lib/libc/tests/gen/posix_spawn/Makefile b/lib/libc/tests/gen/posix_spawn/Makefile index a1c9b9e7cd1e3..9bb2cf1cbd57e 100644 --- a/lib/libc/tests/gen/posix_spawn/Makefile +++ b/lib/libc/tests/gen/posix_spawn/Makefile @@ -1,18 +1,12 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen/posix_spawn - BINDIR= ${TESTSDIR} -# TODO: t_spawnattr (fix from pho@ needs additional review) NETBSD_ATF_TESTS_C= fileactions_test NETBSD_ATF_TESTS_C+= spawn_test +NETBSD_ATF_TESTS_C+= spawnattr_test PROGS= h_fileactions PROGS+= h_spawn @@ -21,6 +15,8 @@ PROGS+= h_spawnattr SCRIPTS= h_nonexec SCRIPTS+= h_zero +CLEANFILES+= h_nonexec + .include "../../Makefile.netbsd-tests" h_zero: diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile index 52fd569dfaaf8..688725345fe6a 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -2,8 +2,6 @@ .include <src.opts.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/hash - NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" @@ -29,8 +27,8 @@ LDADD+= -lmd DPADD.sha2_test+= ${LIBCRYPTO} LDADD.sha2_test+= -lcrypto -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh/openbsd-compat -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh/openbsd-compat +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile index a15b96ae35af8..ee6f98e2f71f7 100644 --- a/lib/libc/tests/inet/Makefile +++ b/lib/libc/tests/inet/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/inet - NETBSD_ATF_TESTS_C= inet_network_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile index e4dc553c46ae8..c0e037857d4cf 100644 --- a/lib/libc/tests/locale/Makefile +++ b/lib/libc/tests/locale/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/locale - NETBSD_ATF_TESTS_C= io_test NETBSD_ATF_TESTS_C+= mbrtowc_test NETBSD_ATF_TESTS_C+= mbstowcs_test diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile index eb199f09b8d75..5a0d77546752e 100644 --- a/lib/libc/tests/net/Makefile +++ b/lib/libc/tests/net/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/net - BINDIR= ${TESTSDIR} NETBSD_ATF_TESTS_C= getprotoent_test diff --git a/lib/libc/tests/net/getaddrinfo/Makefile b/lib/libc/tests/net/getaddrinfo/Makefile index a6b9eb197e995..d21d336559423 100644 --- a/lib/libc/tests/net/getaddrinfo/Makefile +++ b/lib/libc/tests/net/getaddrinfo/Makefile @@ -1,13 +1,9 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T} .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/net/getaddrinfo - BINDIR= ${TESTSDIR} .error "This testcase needs to be ported to FreeBSD (the output from getaddrinfo_test differs from NetBSD)" diff --git a/lib/libc/tests/regex/Makefile b/lib/libc/tests/regex/Makefile index 37b3277e57c40..fa60f6ec4cc84 100644 --- a/lib/libc/tests/regex/Makefile +++ b/lib/libc/tests/regex/Makefile @@ -4,8 +4,6 @@ BINDIR= ${TESTSDIR} -TESTSDIR= ${TESTSBASE}/lib/libc/regex - IMPLEMENTATION?= -DREGEX_SPENCER CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex diff --git a/lib/libc/tests/rpc/Makefile b/lib/libc/tests/rpc/Makefile index 03802945cc686..e6e58e76b905f 100644 --- a/lib/libc/tests/rpc/Makefile +++ b/lib/libc/tests/rpc/Makefile @@ -1,6 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/rpc SRCS.xdr_test= ${RPCSRC:.x=_xdr.c} t_xdr.c ${RPCSRC:.x=.h} NETBSD_ATF_TESTS_C= rpc_test diff --git a/lib/libc/tests/setjmp/Makefile b/lib/libc/tests/setjmp/Makefile index e4c7ae5144a63..0ca25774beef3 100644 --- a/lib/libc/tests/setjmp/Makefile +++ b/lib/libc/tests/setjmp/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/setjmp - NETBSD_ATF_TESTS_C= t_setjmp NETBSD_ATF_TESTS_C+= t_threadjmp @@ -10,4 +8,6 @@ LDADD.t_threadjmp+= -lpthread WARNS?= 4 +.include "../Makefile.netbsd-tests" + .include <bsd.test.mk> diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index 7bc866035be0a..ec7a82a48885e 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/ssp - NO_WERROR= WARNS?= 2 diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile index 23d5c1ef8664c..f2d686b52027f 100644 --- a/lib/libc/tests/stdio/Makefile +++ b/lib/libc/tests/stdio/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/stdio - ATF_TESTS_C= fmemopen2_test NETBSD_ATF_TESTS_C= clearerr_test diff --git a/lib/libc/tests/stdio/fmemopen2_test.c b/lib/libc/tests/stdio/fmemopen2_test.c index d137780f1ce1c..9555173a3861e 100644 --- a/lib/libc/tests/stdio/fmemopen2_test.c +++ b/lib/libc/tests/stdio/fmemopen2_test.c @@ -97,6 +97,7 @@ ATF_TC_BODY(test_preexisting, tc) /* Close the FILE *. */ rc = fclose(fp); + ATF_REQUIRE(rc == 0); /* Check that the string was not modified after the first 4 bytes. */ ATF_REQUIRE(strcmp(str, str3) == 0); diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index 917160112f6a6..187ca5be96698 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/stdlib - # TODO: t_getenv_thread, t_mi_vector_hash NETBSD_ATF_TESTS_C= abs_test NETBSD_ATF_TESTS_C+= atoi_test diff --git a/lib/libc/tests/string/Makefile b/lib/libc/tests/string/Makefile index 3c30ab67ec73a..d91af08a27f1b 100644 --- a/lib/libc/tests/string/Makefile +++ b/lib/libc/tests/string/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/string - # TODO: popcount, stresep NETBSD_ATF_TESTS_C+= memchr diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index 7ecf1d69c6168..5cd596d077fbd 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/sys - # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, # swapcontext NETBSD_ATF_TESTS_C+= access_test @@ -25,10 +23,7 @@ NETBSD_ATF_TESTS_C+= kevent_test NETBSD_ATF_TESTS_C+= kill_test NETBSD_ATF_TESTS_C+= link_test NETBSD_ATF_TESTS_C+= listen_test -# On arm64 triggers panic ARM64TODO: pmap_mincore (PR202307). -.if ${MACHINE_CPUARCH} != "aarch64" NETBSD_ATF_TESTS_C+= mincore_test -.endif NETBSD_ATF_TESTS_C+= mkdir_test NETBSD_ATF_TESTS_C+= mkfifo_test NETBSD_ATF_TESTS_C+= mknod_test diff --git a/lib/libc/tests/termios/Makefile b/lib/libc/tests/termios/Makefile index 9a3fd66a5aacc..0495d684b505a 100644 --- a/lib/libc/tests/termios/Makefile +++ b/lib/libc/tests/termios/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/termios - NETBSD_ATF_TESTS_C= tcsetpgrp_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/time/Makefile b/lib/libc/tests/time/Makefile index c2a55df15be5a..feb543dad2433 100644 --- a/lib/libc/tests/time/Makefile +++ b/lib/libc/tests/time/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/time - NETBSD_ATF_TESTS_C= mktime_test NETBSD_ATF_TESTS_C+= strptime_test diff --git a/lib/libc/tests/tls/Makefile b/lib/libc/tests/tls/Makefile index e2248959ab149..b6b671914e79c 100644 --- a/lib/libc/tests/tls/Makefile +++ b/lib/libc/tests/tls/Makefile @@ -2,7 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/tls .if !defined(NO_PIC) SUBDIR+= dso .endif diff --git a/lib/libc/tests/tls/dso/Makefile b/lib/libc/tests/tls/dso/Makefile index 466f950061f82..9b698cd5f5c27 100644 --- a/lib/libc/tests/tls/dso/Makefile +++ b/lib/libc/tests/tls/dso/Makefile @@ -1,7 +1,6 @@ # $FreeBSD$ OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/tls/${.CURDIR:T} LIB= h_tls_dlopen diff --git a/lib/libc/tests/tls_dso/Makefile b/lib/libc/tests/tls_dso/Makefile index 5449799de96c4..b37ffec766590 100644 --- a/lib/libc/tests/tls_dso/Makefile +++ b/lib/libc/tests/tls_dso/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +SRCDIR= ${SRCTOP}/contrib/netbsd/ + .include <bsd.own.mk> LIB= h_tls_dynamic diff --git a/lib/libc/tests/ttyio/Makefile b/lib/libc/tests/ttyio/Makefile index a1f320d6fd4d0..242f33258e41d 100644 --- a/lib/libc/tests/ttyio/Makefile +++ b/lib/libc/tests/ttyio/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/ttyio - # TODO: ptm_test NETBSD_ATF_TESTS_C= ttyio_test diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c index fc024fcd03318..63ecd03be7246 100644 --- a/lib/libc/xdr/xdr_float.c +++ b/lib/libc/xdr/xdr_float.c @@ -102,9 +102,7 @@ static struct sgl_limits { #endif /* vax */ bool_t -xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; +xdr_float(XDR *xdrs, float *fp) { #ifndef IEEEFP struct ieee_single is; |
