CVS commit: [prg-localcount2] src/sys/external/bsd/ipf/netinet
Module Name:src Committed By: pgoyette Date: Tue May 2 05:17:56 UTC 2017 Modified Files: src/sys/external/bsd/ipf/netinet [prg-localcount2]: ip_fil_netbsd.c Log Message: Keep NetBSD version in sync with sys/params.h XXX When localcount is finally committed to HEAD, it will need a version XXX bump, so we'll need to make the bump here, too To generate a diff of this commit: cvs rdiff -u -r1.22.4.4 -r1.22.4.5 \ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c diff -u src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.22.4.4 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.22.4.5 --- src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.22.4.4 Sat Apr 29 11:12:15 2017 +++ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Tue May 2 05:17:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_fil_netbsd.c,v 1.22.4.4 2017/04/29 11:12:15 pgoyette Exp $ */ +/* $NetBSD: ip_fil_netbsd.c,v 1.22.4.5 2017/05/02 05:17:56 pgoyette Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -8,7 +8,7 @@ #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.22.4.4 2017/04/29 11:12:15 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.22.4.5 2017/05/02 05:17:56 pgoyette Exp $"); #else static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed"; static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp"; @@ -138,7 +138,7 @@ static int ipfpoll(dev_t, int event static void ipf_timer_func(void *ptr); const struct cdevsw ipl_cdevsw = { -#if (__NetBSD_Version__ >= 799007100) +#if (__NetBSD_Version__ >= 799007200) DEVSW_MODULE_INIT #endif .d_open = ipfopen,
CVS commit: src/usr.bin/mail
Module Name:src Committed By: christos Date: Tue May 2 03:29:14 UTC 2017 Modified Files: src/usr.bin/mail: collect.c Log Message: reset signal handler before returning. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/usr.bin/mail/collect.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/mail/collect.c diff -u src/usr.bin/mail/collect.c:1.47 src/usr.bin/mail/collect.c:1.48 --- src/usr.bin/mail/collect.c:1.47 Fri Jun 28 13:36:18 2013 +++ src/usr.bin/mail/collect.c Mon May 1 23:29:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: collect.c,v 1.47 2013/06/28 17:36:18 christos Exp $ */ +/* $NetBSD: collect.c,v 1.48 2017/05/02 03:29:14 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else -__RCSID("$NetBSD: collect.c,v 1.47 2013/06/28 17:36:18 christos Exp $"); +__RCSID("$NetBSD: collect.c,v 1.48 2017/05/02 03:29:14 christos Exp $"); #endif #endif /* not lint */ @@ -314,9 +314,11 @@ coll_int(int signo) (void)puts("@"); (void)fflush(stdout); clearerr(stdin); + signal(SIGINT, o); return; } hadintr = 1; + signal(SIGINT, o); longjmp(reset_jmpbuf, signo); } if (collf) {
CVS commit: src/sys/opencrypto
Module Name:src Committed By: knakahara Date: Tue May 2 03:17:43 UTC 2017 Modified Files: src/sys/opencrypto: crypto.c Log Message: add some assertion. tested by ATF net/ipsec/ and crypto/. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/opencrypto/crypto.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/opencrypto/crypto.c diff -u src/sys/opencrypto/crypto.c:1.58 src/sys/opencrypto/crypto.c:1.59 --- src/sys/opencrypto/crypto.c:1.58 Wed Apr 26 03:29:36 2017 +++ src/sys/opencrypto/crypto.c Tue May 2 03:17:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: crypto.c,v 1.58 2017/04/26 03:29:36 knakahara Exp $ */ +/* $NetBSD: crypto.c,v 1.59 2017/05/02 03:17:43 knakahara Exp $ */ /* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */ /* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */ @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.58 2017/04/26 03:29:36 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.59 2017/05/02 03:17:43 knakahara Exp $"); #include #include @@ -739,9 +739,13 @@ crypto_unblock(u_int32_t driverid, int w int crypto_dispatch(struct cryptop *crp) { - u_int32_t hid = CRYPTO_SESID2HID(crp->crp_sid); + u_int32_t hid; int result; + KASSERT(crp != NULL); + + hid = CRYPTO_SESID2HID(crp->crp_sid); + mutex_spin_enter(_q_mtx); DPRINTF(("crypto_dispatch: crp %p, alg %d\n", crp, crp->crp_desc->crd_alg)); @@ -825,6 +829,8 @@ crypto_kdispatch(struct cryptkop *krp) struct cryptocap *cap; int result; + KASSERT(krp != NULL); + mutex_spin_enter(_q_mtx); cryptostats.cs_kops++; @@ -873,9 +879,9 @@ crypto_kinvoke(struct cryptkop *krp, int u_int32_t hid; int error; + KASSERT(krp != NULL); + /* Sanity checks. */ - if (krp == NULL) - return EINVAL; if (krp->krp_callback == NULL) { cv_destroy(>krp_cv); pool_put(_pool, krp); @@ -947,13 +953,13 @@ crypto_invoke(struct cryptop *crp, int h { u_int32_t hid; + KASSERT(crp != NULL); + #ifdef CRYPTO_TIMING if (crypto_timing) crypto_tstat(_invoke, >crp_tstamp); #endif /* Sanity checks. */ - if (crp == NULL) - return EINVAL; if (crp->crp_callback == NULL) { return EINVAL; } @@ -1063,6 +1069,8 @@ crypto_done(struct cryptop *crp) { int wasempty; + KASSERT(crp != NULL); + if (crp->crp_etype != 0) cryptostats.cs_errs++; #ifdef CRYPTO_TIMING @@ -1145,6 +1153,8 @@ crypto_kdone(struct cryptkop *krp) { int wasempty; + KASSERT(krp != NULL); + if (krp->krp_status != 0) cryptostats.cs_kerrs++;
CVS commit: src/distrib/sets/lists/comp
Module Name:src Committed By: pgoyette Date: Mon May 1 23:33:07 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi Log Message: Remove yet another entry for localcount - we're not ready yet To generate a diff of this commit: cvs rdiff -u -r1.2129 -r1.2130 src/distrib/sets/lists/comp/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2129 src/distrib/sets/lists/comp/mi:1.2130 --- src/distrib/sets/lists/comp/mi:1.2129 Mon May 1 23:08:11 2017 +++ src/distrib/sets/lists/comp/mi Mon May 1 23:33:07 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2129 2017/05/01 23:08:11 pgoyette Exp $ +# $NetBSD: mi,v 1.2130 2017/05/01 23:33:07 pgoyette Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -25784,7 +25784,6 @@ ./usr/share/man/man9/le64enc.9 comp-sys-man .man ./usr/share/man/man9/le64toh.9 comp-sys-man .man ./usr/share/man/man9/linedisc.9 comp-sys-man .man -./usr/share/man/man9/localcount.9 comp-sys-man .man ./usr/share/man/man9/lock.9 comp-sys-man .man ./usr/share/man/man9/locking.9 comp-sys-man .man ./usr/share/man/man9/lockinit.9 comp-sys-man .man
CVS commit: src/distrib/sets/lists/comp
Module Name:src Committed By: pgoyette Date: Mon May 1 23:08:12 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi Log Message: Too early for including localcount here, too To generate a diff of this commit: cvs rdiff -u -r1.2128 -r1.2129 src/distrib/sets/lists/comp/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2128 src/distrib/sets/lists/comp/mi:1.2129 --- src/distrib/sets/lists/comp/mi:1.2128 Mon May 1 21:36:33 2017 +++ src/distrib/sets/lists/comp/mi Mon May 1 23:08:11 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2128 2017/05/01 21:36:33 pgoyette Exp $ +# $NetBSD: mi,v 1.2129 2017/05/01 23:08:11 pgoyette Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -2873,7 +2873,6 @@ ./usr/include/sys/ksyms.h comp-c-include ./usr/include/sys/ktrace.h comp-c-include ./usr/include/sys/lkm.hcomp-obsolete obsolete -./usr/include/sys/localcount.h comp-c-include ./usr/include/sys/localedef.h comp-c-include ./usr/include/sys/lock.h comp-c-include ./usr/include/sys/lockf.h comp-c-include @@ -10743,7 +10742,6 @@ ./usr/share/man/cat9/le64enc.0 comp-sys-catman .cat ./usr/share/man/cat9/le64toh.0 comp-sys-catman .cat ./usr/share/man/cat9/linedisc.0 comp-sys-catman .cat -./usr/share/man/cat9/localcount.0 comp-sys-catman .cat ./usr/share/man/cat9/lock.0 comp-sys-catman .cat ./usr/share/man/cat9/locking.0 comp-sys-catman .cat ./usr/share/man/cat9/lockinit.0 comp-sys-catman .cat @@ -18188,7 +18186,6 @@ ./usr/share/man/html9/le64enc.html comp-sys-htmlman html ./usr/share/man/html9/le64toh.html comp-sys-htmlman html ./usr/share/man/html9/linedisc.html comp-sys-htmlman html -./usr/share/man/html9/localcount.html comp-sys-htmlman html ./usr/share/man/html9/lock.html comp-sys-htmlman html ./usr/share/man/html9/locking.html comp-sys-htmlman html ./usr/share/man/html9/lockinit.html comp-sys-htmlman html
CVS commit: src/share/man/man9
Module Name:src Committed By: pgoyette Date: Mon May 1 23:07:14 UTC 2017 Modified Files: src/share/man/man9: Makefile Log Message: Ooops, localcount.9 was not supposed to be included here! To generate a diff of this commit: cvs rdiff -u -r1.411 -r1.412 src/share/man/man9/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.411 src/share/man/man9/Makefile:1.412 --- src/share/man/man9/Makefile:1.411 Mon May 1 21:36:01 2017 +++ src/share/man/man9/Makefile Mon May 1 23:07:14 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.411 2017/05/01 21:36:01 pgoyette Exp $ +# $NetBSD: Makefile,v 1.412 2017/05/01 23:07:14 pgoyette Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -32,7 +32,7 @@ MAN= accept_filter.9 accf_data.9 accf_ht kcpuset.9 kernhist.9 klua_lock.9 klua_mod_register.9 kmem.9 kpause.9 \ kfilter_register.9 knote.9 \ kprintf.9 kthread.9 linedisc.9 lock.9 locking.9 log.9 ltsleep.9 \ - localcount.9 LWP_CACHE_CREDS.9 \ + LWP_CACHE_CREDS.9 \ makeiplcookie.9 \ malloc.9 mb.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \ memmove.9 memset.9 \
CVS commit: src/distrib/sets/lists/comp
Module Name:src Committed By: pgoyette Date: Mon May 1 21:36:33 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi Log Message: Sets list for new mutex_ownable(9) entry To generate a diff of this commit: cvs rdiff -u -r1.2127 -r1.2128 src/distrib/sets/lists/comp/mi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2127 src/distrib/sets/lists/comp/mi:1.2128 --- src/distrib/sets/lists/comp/mi:1.2127 Sun Apr 30 12:30:55 2017 +++ src/distrib/sets/lists/comp/mi Mon May 1 21:36:33 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2127 2017/04/30 12:30:55 pgoyette Exp $ +# $NetBSD: mi,v 1.2128 2017/05/01 21:36:33 pgoyette Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -2873,6 +2873,7 @@ ./usr/include/sys/ksyms.h comp-c-include ./usr/include/sys/ktrace.h comp-c-include ./usr/include/sys/lkm.hcomp-obsolete obsolete +./usr/include/sys/localcount.h comp-c-include ./usr/include/sys/localedef.h comp-c-include ./usr/include/sys/lock.h comp-c-include ./usr/include/sys/lockf.h comp-c-include @@ -10312,6 +10313,7 @@ ./usr/share/man/cat9/config_defer.0 comp-sys-catman .cat ./usr/share/man/cat9/config_detach.0 comp-sys-catman .cat ./usr/share/man/cat9/config_detach_children.0 comp-sys-catman .cat +./usr/share/man/cat9/config_detach_release.0 comp-sys-catman .cat ./usr/share/man/cat9/config_finalize_register.0 comp-sys-catman .cat ./usr/share/man/cat9/config_found.0 comp-sys-catman .cat ./usr/share/man/cat9/config_found_ia.0 comp-sys-catman .cat @@ -10741,6 +10743,7 @@ ./usr/share/man/cat9/le64enc.0 comp-sys-catman .cat ./usr/share/man/cat9/le64toh.0 comp-sys-catman .cat ./usr/share/man/cat9/linedisc.0 comp-sys-catman .cat +./usr/share/man/cat9/localcount.0 comp-sys-catman .cat ./usr/share/man/cat9/lock.0 comp-sys-catman .cat ./usr/share/man/cat9/locking.0 comp-sys-catman .cat ./usr/share/man/cat9/lockinit.0 comp-sys-catman .cat @@ -10834,6 +10837,7 @@ ./usr/share/man/cat9/mutex_enter.0 comp-sys-catman .cat ./usr/share/man/cat9/mutex_exit.0 comp-sys-catman .cat ./usr/share/man/cat9/mutex_init.0 comp-sys-catman .cat +./usr/share/man/cat9/mutex_ownable.0 comp-sys-catman .cat ./usr/share/man/cat9/mutex_owned.0 comp-sys-catman .cat ./usr/share/man/cat9/mutex_spin_enter.0 comp-sys-catman .cat ./usr/share/man/cat9/mutex_spin_exit.0 comp-sys-catman .cat @@ -17775,6 +17779,7 @@ ./usr/share/man/html9/config_defer.html comp-sys-htmlman html ./usr/share/man/html9/config_detach.html comp-sys-htmlman html ./usr/share/man/html9/config_detach_children.html comp-sys-htmlman html +./usr/share/man/html9/config_detach_release.html comp-sys-htmlman html ./usr/share/man/html9/config_finalize_register.html comp-sys-htmlman html ./usr/share/man/html9/config_found.html comp-sys-htmlman html ./usr/share/man/html9/config_found_ia.html comp-sys-htmlman html @@ -18183,6 +18188,7 @@ ./usr/share/man/html9/le64enc.html comp-sys-htmlman html ./usr/share/man/html9/le64toh.html comp-sys-htmlman html ./usr/share/man/html9/linedisc.html comp-sys-htmlman html +./usr/share/man/html9/localcount.html comp-sys-htmlman html ./usr/share/man/html9/lock.html comp-sys-htmlman html ./usr/share/man/html9/locking.html comp-sys-htmlman html ./usr/share/man/html9/lockinit.html comp-sys-htmlman html @@ -18275,6 +18281,7 @@ ./usr/share/man/html9/mutex_enter.html comp-sys-htmlman html ./usr/share/man/html9/mutex_exit.html comp-sys-htmlman html ./usr/share/man/html9/mutex_init.html comp-sys-htmlman html +./usr/share/man/html9/mutex_ownable.html comp-sys-htmlman html ./usr/share/man/html9/mutex_owned.html comp-sys-htmlman html ./usr/share/man/html9/mutex_spin_enter.html comp-sys-htmlman html ./usr/share/man/html9/mutex_spin_exit.html comp-sys-htmlman html @@ -25350,6 +25357,7 @@ ./usr/share/man/man9/config_defer.9 comp-sys-man .man ./usr/share/man/man9/config_detach.9 comp-sys-man .man ./usr/share/man/man9/config_detach_children.9 comp-sys-man .man +./usr/share/man/man9/config_detach_release.9 comp-sys-man .man ./usr/share/man/man9/config_finalize_register.9 comp-sys-man .man ./usr/share/man/man9/config_found.9 comp-sys-man .man ./usr/share/man/man9/config_found_ia.9 comp-sys-man .man @@ -25779,6 +25787,7 @@ ./usr/share/man/man9/le64enc.9 comp-sys-man .man ./usr/share/man/man9/le64toh.9 comp-sys-man .man ./usr/share/man/man9/linedisc.9 comp-sys-man .man +./usr/share/man/man9/localcount.9 comp-sys-man .man ./usr/share/man/man9/lock.9 comp-sys-man .man ./usr/share/man/man9/locking.9 comp-sys-man .man ./usr/share/man/man9/lockinit.9 comp-sys-man .man @@ -25872,6 +25881,7 @@ ./usr/share/man/man9/mutex_enter.9 comp-sys-man .man ./usr/share/man/man9/mutex_exit.9
CVS commit: src/share/man/man9
Module Name:src Committed By: pgoyette Date: Mon May 1 21:36:01 UTC 2017 Modified Files: src/share/man/man9: Makefile mutex.9 Log Message: Update mutex(9) for mutex_ownable() To generate a diff of this commit: cvs rdiff -u -r1.410 -r1.411 src/share/man/man9/Makefile cvs rdiff -u -r1.26 -r1.27 src/share/man/man9/mutex.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.410 src/share/man/man9/Makefile:1.411 --- src/share/man/man9/Makefile:1.410 Sun Apr 30 12:30:00 2017 +++ src/share/man/man9/Makefile Mon May 1 21:36:01 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.410 2017/04/30 12:30:00 pgoyette Exp $ +# $NetBSD: Makefile,v 1.411 2017/05/01 21:36:01 pgoyette Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -32,7 +32,7 @@ MAN= accept_filter.9 accf_data.9 accf_ht kcpuset.9 kernhist.9 klua_lock.9 klua_mod_register.9 kmem.9 kpause.9 \ kfilter_register.9 knote.9 \ kprintf.9 kthread.9 linedisc.9 lock.9 locking.9 log.9 ltsleep.9 \ - LWP_CACHE_CREDS.9 \ + localcount.9 LWP_CACHE_CREDS.9 \ makeiplcookie.9 \ malloc.9 mb.9 mbuf.9 mca.9 memcmp.9 memcpy.9 memoryallocators.9 \ memmove.9 memset.9 \ @@ -119,6 +119,7 @@ MLINKS+=autoconf.9 config_search_loc.9 \ autoconf.9 config_attach_pseudo.9 \ autoconf.9 config_detach.9 \ autoconf.9 config_detach_children.9 \ + autoconf.9 config_detach_release.9 \ autoconf.9 config_deactivate.9 \ autoconf.9 config_defer.9 \ autoconf.9 config_interrupts.9 \ @@ -516,6 +517,7 @@ MLINKS+=module.9 module_autoload.9 \ MLINKS+=mstohz.9 hztoms.9 MLINKS+=mutex.9 mutex_init.9 mutex.9 mutex_destroy.9 mutex.9 mutex_enter.9 \ mutex.9 mutex_exit.9 mutex.9 mutex_tryenter.9 mutex.9 mutex_owned.9 \ + mutex.9 mutex_ownable.9 \ mutex.9 mutex_spin_enter.9 mutex.9 mutex_spin_exit.9 MLINKS+=m_tag.9 m_tag_copy.9 \ m_tag.9 m_tag_copy_chain.9 \ Index: src/share/man/man9/mutex.9 diff -u src/share/man/man9/mutex.9:1.26 src/share/man/man9/mutex.9:1.27 --- src/share/man/man9/mutex.9:1.26 Wed Sep 4 10:17:58 2013 +++ src/share/man/man9/mutex.9 Mon May 1 21:36:01 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: mutex.9,v 1.26 2013/09/04 10:17:58 skrll Exp $ +.\" $NetBSD: mutex.9,v 1.27 2017/05/01 21:36:01 pgoyette Exp $ .\" .\" Copyright (c) 2007, 2009 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -36,6 +36,7 @@ .Nm mutex_destroy , .Nm mutex_enter , .Nm mutex_exit , +.Nm mutex_ownable , .Nm mutex_owned , .Nm mutex_spin_enter , .Nm mutex_spin_exit , @@ -52,6 +53,8 @@ .Ft void .Fn mutex_exit "kmutex_t *mtx" .Ft int +.Fn mutex_ownable "kmutex_t *mtx" +.Ft int .Fn mutex_owned "kmutex_t *mtx" .Ft void .Fn mutex_spin_enter "kmutex_t *mtx" @@ -172,6 +175,21 @@ if it is not already equal or higher. Release a mutex. The mutex must have been previously acquired by the caller. Mutexes may be released out of order as needed. +.It Fn mutex_ownable "mtx" +.Pp +When compiled with LOCKDEBUG (see +.Xr options 4 ) , +ensure that the current process can successfully acquire mtx. +If mtx is already owned by the current process, the system will panic +with a "locking against myself" error. +.Pp +This function is needed because +.Fn mutex_owned +does not differentiate if a spin mutex is owned by the current process +vs owned by another process. +.Fn mutex_ownable +is reasonably heavy-weight, and should only be used with +.Xr KDASSERT 9 . .It Fn mutex_owned "mtx" .Pp For adaptive mutexes, return non-zero if the current LWP holds the mutex.
CVS commit: src/sys
Module Name:src Committed By: pgoyette Date: Mon May 1 21:35:26 UTC 2017 Modified Files: src/sys/kern: kern_mutex.c subr_lockdebug.c src/sys/rump/librump/rumpkern: locks.c src/sys/sys: mutex.h Log Message: Introduce mutex_ownable() to determine if it is possible for the current process to acquire a mutex. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/kern/kern_mutex.c cvs rdiff -u -r1.55 -r1.56 src/sys/kern/subr_lockdebug.c cvs rdiff -u -r1.73 -r1.74 src/sys/rump/librump/rumpkern/locks.c cvs rdiff -u -r1.20 -r1.21 src/sys/sys/mutex.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_mutex.c diff -u src/sys/kern/kern_mutex.c:1.64 src/sys/kern/kern_mutex.c:1.65 --- src/sys/kern/kern_mutex.c:1.64 Thu Jan 26 04:11:56 2017 +++ src/sys/kern/kern_mutex.c Mon May 1 21:35:25 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_mutex.c,v 1.64 2017/01/26 04:11:56 christos Exp $ */ +/* $NetBSD: kern_mutex.c,v 1.65 2017/05/01 21:35:25 pgoyette Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #define __MUTEX_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.64 2017/01/26 04:11:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.65 2017/05/01 21:35:25 pgoyette Exp $"); #include #include @@ -75,6 +75,9 @@ __KERNEL_RCSID(0, "$NetBSD: kern_mutex.c #define MUTEX_WANTLOCK(mtx) \ LOCKDEBUG_WANTLOCK(MUTEX_DEBUG_P(mtx), (mtx), \ (uintptr_t)__builtin_return_address(0), 0) +#define MUTEX_TESTLOCK(mtx) \ +LOCKDEBUG_WANTLOCK(MUTEX_DEBUG_P(mtx), (mtx), \ +(uintptr_t)__builtin_return_address(0), -1) #define MUTEX_LOCKED(mtx) \ LOCKDEBUG_LOCKED(MUTEX_DEBUG_P(mtx), (mtx), NULL, \ (uintptr_t)__builtin_return_address(0), 0) @@ -831,6 +834,23 @@ mutex_owner(kmutex_t *mtx) } /* + * mutex_ownable: + * + * When compiled with DEBUG and LOCKDEBUG defined, ensure that + * the mutex is available. We cannot use !mutex_owned() since + * that won't work correctly for spin mutexes. + */ +int +mutex_ownable(kmutex_t *mtx) +{ + +#ifdef LOCKDEBUG + MUTEX_TESTLOCK(mtx); +#endif + return 1; +} + +/* * mutex_tryenter: * * Try to acquire the mutex; return non-zero if we did. Index: src/sys/kern/subr_lockdebug.c diff -u src/sys/kern/subr_lockdebug.c:1.55 src/sys/kern/subr_lockdebug.c:1.56 --- src/sys/kern/subr_lockdebug.c:1.55 Thu Jan 26 04:11:56 2017 +++ src/sys/kern/subr_lockdebug.c Mon May 1 21:35:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_lockdebug.c,v 1.55 2017/01/26 04:11:56 christos Exp $ */ +/* $NetBSD: subr_lockdebug.c,v 1.56 2017/05/01 21:35:26 pgoyette Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.55 2017/01/26 04:11:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.56 2017/05/01 21:35:26 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -417,7 +417,9 @@ lockdebug_more(int s) /* * lockdebug_wantlock: * - * Process the preamble to a lock acquire. + * Process the preamble to a lock acquire. The "shared" + * parameter controls which ld_{ex,sh}want counter is + * updated; a negative value of shared updates neither. */ void lockdebug_wantlock(const char *func, size_t line, @@ -454,9 +456,9 @@ lockdebug_wantlock(const char *func, siz return; } } - if (shared) + if (shared > 0) ld->ld_shwant++; - else + else if (shared == 0) ld->ld_exwant++; if (recurse) { lockdebug_abort1(func, line, ld, s, "locking against myself", Index: src/sys/rump/librump/rumpkern/locks.c diff -u src/sys/rump/librump/rumpkern/locks.c:1.73 src/sys/rump/librump/rumpkern/locks.c:1.74 --- src/sys/rump/librump/rumpkern/locks.c:1.73 Fri Jan 27 09:50:47 2017 +++ src/sys/rump/librump/rumpkern/locks.c Mon May 1 21:35:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locks.c,v 1.73 2017/01/27 09:50:47 ozaki-r Exp $ */ +/* $NetBSD: locks.c,v 1.74 2017/05/01 21:35:26 pgoyette Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.73 2017/01/27 09:50:47 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.74 2017/05/01 21:35:26 pgoyette Exp $"); #include #include @@ -183,6 +183,16 @@ mutex_exit(kmutex_t *mtx) __strong_alias(mutex_spin_exit,mutex_exit); int +mutex_ownable(kmutex_t *mtx) +{ + +#ifdef LOCKDEBUG + WANTLOCK(mtx, -1); +#endif + return 1; +} + +int mutex_owned(kmutex_t *mtx) { Index: src/sys/sys/mutex.h diff -u src/sys/sys/mutex.h:1.20 src/sys/sys/mutex.h:1.21 --- src/sys/sys/mutex.h:1.20 Mon Feb 8 09:54:27 2010 +++ src/sys/sys/mutex.h Mon May 1 21:35:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mutex.h,v 1.20 2010/02/08 09:54:27 skrll Exp $ */ +/* $NetBSD: mutex.h,v 1.21 2017/05/01
CVS commit: src/lib/libterminfo
Module Name:src Committed By: roy Date: Mon May 1 19:09:22 UTC 2017 Modified Files: src/lib/libterminfo: tputs.c Log Message: Fix some compile warnings. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libterminfo/tputs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libterminfo/tputs.c diff -u src/lib/libterminfo/tputs.c:1.3 src/lib/libterminfo/tputs.c:1.4 --- src/lib/libterminfo/tputs.c:1.3 Fri Jun 7 13:16:18 2013 +++ src/lib/libterminfo/tputs.c Mon May 1 19:09:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tputs.c,v 1.3 2013/06/07 13:16:18 roy Exp $ */ +/* $NetBSD: tputs.c,v 1.4 2017/05/01 19:09:22 roy Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include -__RCSID("$NetBSD: tputs.c,v 1.3 2013/06/07 13:16:18 roy Exp $"); +__RCSID("$NetBSD: tputs.c,v 1.4 2017/05/01 19:09:22 roy Exp $"); #include #include @@ -93,7 +93,7 @@ _ti_outputdelay(int delay, short os, cha } static int -_ti_puts(int dodelay, int os, int pc, +_ti_puts(int dodelay, short os, char pc, const char *str, int affcnt, int (*outc)(int, void *), void *args) { int taildelay, delay, mand;
CVS commit: src/lib/libterminfo
Module Name:src Committed By: roy Date: Mon May 1 18:39:02 UTC 2017 Modified Files: src/lib/libterminfo: termcap.c Log Message: Whitespace police. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libterminfo/termcap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libterminfo/termcap.c diff -u src/lib/libterminfo/termcap.c:1.20 src/lib/libterminfo/termcap.c:1.21 --- src/lib/libterminfo/termcap.c:1.20 Wed Jan 11 20:53:52 2017 +++ src/lib/libterminfo/termcap.c Mon May 1 18:39:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: termcap.c,v 1.20 2017/01/11 20:53:52 roy Exp $ */ +/* $NetBSD: termcap.c,v 1.21 2017/05/01 18:39:02 roy Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include -__RCSID("$NetBSD: termcap.c,v 1.20 2017/01/11 20:53:52 roy Exp $"); +__RCSID("$NetBSD: termcap.c,v 1.21 2017/05/01 18:39:02 roy Exp $"); #include #include @@ -200,7 +200,7 @@ numname(const char *key) uint32_t idx; idx = _t_numhash((const unsigned char *)key, strlen(key)); - if (idx < __arraycount(_ti_cap_numids) && + if (idx < __arraycount(_ti_cap_numids) && strcmp(key, _ti_cap_numids[idx].id) == 0) return _ti_numid(_ti_cap_numids[idx].ti); return key; @@ -254,7 +254,7 @@ printchar(char **dst, const char **src) case '2': case '3': v = 0; - while (isdigit((unsigned char) **src)) + while (isdigit((unsigned char) **src)) v = 8 * v + ((unsigned char) *(*src)++ - '0'); (*src)--; break;
CVS commit: src/sys/arch/i386/stand/efiboot
Module Name:src Committed By: nonaka Date: Mon May 1 13:03:02 UTC 2017 Modified Files: src/sys/arch/i386/stand/efiboot: boot.c efiboot.h eficons.c Log Message: efiboot: implement consdev command. no support to change console device for efiboot yet. only pass console parameters to kernel. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/boot.c \ src/sys/arch/i386/stand/efiboot/efiboot.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/eficons.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/boot.c diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.4 src/sys/arch/i386/stand/efiboot/boot.c:1.5 --- src/sys/arch/i386/stand/efiboot/boot.c:1.4 Sun Mar 12 05:33:48 2017 +++ src/sys/arch/i386/stand/efiboot/boot.c Mon May 1 13:03:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.4 2017/03/12 05:33:48 nonaka Exp $ */ +/* $NetBSD: boot.c,v 1.5 2017/05/01 13:03:01 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka@@ -30,6 +30,7 @@ #include #include +#include #include "bootcfg.h" #include "bootmod.h" @@ -340,7 +341,7 @@ command_help(char *arg) "boot [xdNx:][filename] [-12acdqsvxz]\n" " (ex. \"hd0a:netbsd.old -s\"\n" "dev [xd[N[x]]:]\n" - "consdev {pc|com[0123]|com[0123]kbd|auto}\n" + "consdev {pc|com[0123][,{speed}]|com,{ioport}[,{speed}]}\n" "devpath\n" "efivar\n" "gop [{modenum|list}]\n" @@ -436,12 +437,77 @@ command_dev(char *arg) default_devname = savedevname; } -/* ARGSUSED */ +static const struct cons_devs { + const char *name; + u_int tag; + int ioport; +} cons_devs[] = { + { "pc", CONSDEV_PC, 0 }, + { "com0", CONSDEV_COM0, 0 }, + { "com1", CONSDEV_COM1, 0 }, + { "com2", CONSDEV_COM2, 0 }, + { "com3", CONSDEV_COM3, 0 }, + { "com0kbd", CONSDEV_COM0KBD, 0 }, + { "com1kbd", CONSDEV_COM1KBD, 0 }, + { "com2kbd", CONSDEV_COM2KBD, 0 }, + { "com3kbd", CONSDEV_COM3KBD, 0 }, + { "com", CONSDEV_COM0, -1 }, + { "auto", CONSDEV_AUTO, 0 }, + { NULL, 0 } +}; + void command_consdev(char *arg) { - - /* XXX not implemented yet */ + const struct cons_devs *cdp; + char *sep, *sep2 = NULL; + int ioport, speed = 0; + + sep = strchr(arg, ','); + if (sep != NULL) { + *sep++ = '\0'; + sep2 = strchr(sep, ','); + if (sep != NULL) + *sep2++ = '\0'; + } + + for (cdp = cons_devs; cdp->name; cdp++) { + if (strcmp(arg, cdp->name) == 0) { + ioport = cdp->ioport; + if (cdp->tag == CONSDEV_PC || cdp->tag == CONSDEV_AUTO) { +if (sep != NULL || sep2 != NULL) + goto error; + } else { +/* com? */ +if (ioport == -1) { + if (sep != NULL) { + u_long t = strtoul(sep, NULL, 0); + if (t > INT_MAX) + goto error; + ioport = (int)t; + } + if (sep2 != NULL) { + speed = atoi(sep2); + if (speed < 0) + goto error; + } +} else { + if (sep != NULL) { + speed = atoi(sep); + if (speed < 0) + goto error; + } + if (sep2 != NULL) + goto error; +} + } + consinit(cdp->tag, ioport, speed); + print_banner(); + return; + } + } +error: + printf("invalid console device.\n"); } #ifndef SMALL Index: src/sys/arch/i386/stand/efiboot/efiboot.h diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.4 src/sys/arch/i386/stand/efiboot/efiboot.h:1.5 --- src/sys/arch/i386/stand/efiboot/efiboot.h:1.4 Sat Feb 11 10:23:39 2017 +++ src/sys/arch/i386/stand/efiboot/efiboot.h Mon May 1 13:03:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.4 2017/02/11 10:23:39 nonaka Exp $ */ +/* $NetBSD: efiboot.h,v 1.5 2017/05/01 13:03:01 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -55,6 +55,7 @@ void efi_cleanup(void); /* eficons.c */ int cninit(void); +void consinit(int, int, int); void command_text(char *); void command_gop(char *); Index: src/sys/arch/i386/stand/efiboot/eficons.c diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.3 src/sys/arch/i386/stand/efiboot/eficons.c:1.4 --- src/sys/arch/i386/stand/efiboot/eficons.c:1.3 Fri Mar 24 01:25:36 2017 +++ src/sys/arch/i386/stand/efiboot/eficons.c Mon May 1 13:03:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: eficons.c,v 1.3 2017/03/24 01:25:36 nonaka Exp $ */ +/* $NetBSD: eficons.c,v 1.4 2017/05/01 13:03:01 nonaka Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -34,6 +34,8 @@ #include "bootinfo.h" #include "vbe.h" +extern struct x86_boot_params boot_params; + struct btinfo_console btinfo_console; static EFI_GRAPHICS_OUTPUT_PROTOCOL *efi_gop; @@ -46,6 +48,68 @@ static int keybuf_write = 0; static void eficons_init_video(void); static void efi_switch_video_to_text_mode(void); +static int +getcomaddr(int idx) +{ + static const short comioport[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; + + if (idx < __arraycount(comioport))
CVS commit: src/sys/dev/pci
Module Name:src Committed By: jakllsch Date: Mon May 1 12:29:40 UTC 2017 Modified Files: src/sys/dev/pci: if_re_pci.c Log Message: Disable interrupt moderation, as it is it causes watchdog timeouts on some chips/systems. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/dev/pci/if_re_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_re_pci.c diff -u src/sys/dev/pci/if_re_pci.c:1.46 src/sys/dev/pci/if_re_pci.c:1.47 --- src/sys/dev/pci/if_re_pci.c:1.46 Wed Apr 19 00:20:02 2017 +++ src/sys/dev/pci/if_re_pci.c Mon May 1 12:29:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_re_pci.c,v 1.46 2017/04/19 00:20:02 jmcneill Exp $ */ +/* $NetBSD: if_re_pci.c,v 1.47 2017/05/01 12:29:40 jakllsch Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -46,7 +46,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.46 2017/04/19 00:20:02 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_re_pci.c,v 1.47 2017/05/01 12:29:40 jakllsch Exp $"); #include @@ -240,8 +240,11 @@ re_pci_attach(device_t parent, device_t t->rtk_basetype == RTK_8101E) sc->sc_quirk |= RTKQ_PCIE; +#if 0 + /* This causes watchdog timeouts on some chips/systems. */ if (t->rtk_basetype == RTK_8168) sc->sc_quirk |= RTKQ_IM_HW; +#endif if (pci_dma64_available(pa) && (sc->sc_quirk & RTKQ_PCIE)) sc->sc_dmat = pa->pa_dmat64;
CVS commit: src/sys/arch/next68k/dev
Module Name:src Committed By: martin Date: Mon May 1 10:25:47 UTC 2017 Modified Files: src/sys/arch/next68k/dev: zs.c Log Message: PR port-next68k/52205 from Miod Vallat: cosmetic change to print the physical address when attaching zs devices. For the real work, zs_get_chan_addr() will still use the virtual address. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/next68k/dev/zs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/next68k/dev/zs.c diff -u src/sys/arch/next68k/dev/zs.c:1.33 src/sys/arch/next68k/dev/zs.c:1.34 --- src/sys/arch/next68k/dev/zs.c:1.33 Fri Jun 13 12:26:55 2008 +++ src/sys/arch/next68k/dev/zs.c Mon May 1 10:25:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: zs.c,v 1.33 2008/06/13 12:26:55 cegger Exp $ */ +/* $NetBSD: zs.c,v 1.34 2017/05/01 10:25:47 martin Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.33 2008/06/13 12:26:55 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.34 2017/05/01 10:25:47 martin Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -183,7 +183,7 @@ zs_match(device_t parent, cfdata_t cf, v if (zs_attached) return 0; - ia->ia_addr = (void *)IIOV(NEXT_P_SCC); + ia->ia_addr = (void *)NEXT_P_SCC; return 1; }
CVS commit: src/sys/kern
Module Name:src Committed By: ryo Date: Mon May 1 10:00:43 UTC 2017 Modified Files: src/sys/kern: uipc_socket.c Log Message: whitespace police To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/sys/kern/uipc_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.252 src/sys/kern/uipc_socket.c:1.253 --- src/sys/kern/uipc_socket.c:1.252 Thu Oct 13 19:10:23 2016 +++ src/sys/kern/uipc_socket.c Mon May 1 10:00:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.252 2016/10/13 19:10:23 uwe Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.253 2017/05/01 10:00:43 ryo Exp $ */ /*- * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.252 2016/10/13 19:10:23 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.253 2017/05/01 10:00:43 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -295,7 +295,8 @@ sopendfree_thread(void *v) for (; m != NULL; m = next) { next = m->m_next; -KASSERT((~m->m_flags & (M_EXT|M_EXT_PAGES)) == 0); +KASSERT((~m->m_flags & (M_EXT|M_EXT_PAGES)) == +0); KASSERT(m->m_ext.ext_refcnt == 0); rv += m->m_ext.ext_size; @@ -648,7 +649,7 @@ solisten(struct socket *so, int backlog, short oldopt, oldqlimit; solock(so); - if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | + if ((so->so_state & (SS_ISCONNECTED | SS_ISCONNECTING | SS_ISDISCONNECTING)) != 0) { sounlock(so); return EINVAL; @@ -786,7 +787,7 @@ soabort(struct socket *so) { u_int refs; int error; - + KASSERT(solocked(so)); KASSERT(so->so_head == NULL); @@ -1065,8 +1066,8 @@ sosend(struct socket *so, struct sockadd if (resid > 0) so->so_state |= SS_MORETOCOME; if (flags & MSG_OOB) { -error = (*so->so_proto->pr_usrreqs->pr_sendoob)(so, -top, control); +error = (*so->so_proto->pr_usrreqs->pr_sendoob)( +so, top, control); } else { error = (*so->so_proto->pr_usrreqs->pr_send)(so, top, addr, control, l); @@ -1407,7 +1408,7 @@ soreceive(struct socket *so, struct mbuf */ if (dom->dom_dispose != NULL && type == SCM_RIGHTS) { - sounlock(so); + sounlock(so); (*dom->dom_dispose)(cm); solock(so); } @@ -1721,22 +1722,22 @@ sosetopt1(struct socket *so, const struc KASSERT(solocked(so)); break; - case SO_LINGER: - error = sockopt_get(sopt, , sizeof(l)); + case SO_LINGER: + error = sockopt_get(sopt, , sizeof(l)); solock(so); - if (error) - break; - if (l.l_linger < 0 || l.l_linger > USHRT_MAX || - l.l_linger > (INT_MAX / hz)) { + if (error) + break; + if (l.l_linger < 0 || l.l_linger > USHRT_MAX || + l.l_linger > (INT_MAX / hz)) { error = EDOM; break; } - so->so_linger = l.l_linger; - if (l.l_onoff) - so->so_options |= SO_LINGER; - else - so->so_options &= ~SO_LINGER; - break; + so->so_linger = l.l_linger; + if (l.l_onoff) + so->so_options |= SO_LINGER; + else + so->so_options &= ~SO_LINGER; + break; case SO_DEBUG: case SO_KEEPALIVE: @@ -1915,7 +1916,7 @@ so_setsockopt(struct lwp *l, struct sock return error; } - + /* * internal get SOL_SOCKET options */ @@ -2092,7 +2093,7 @@ sockopt_destroy(struct sockopt *sopt) /* * set sockopt value * - value is copied into sockopt - * - memory is allocated when necessary, will not sleep + * - memory is allocated when necessary, will not sleep */ int sockopt_set(struct sockopt *sopt, const void *buf, size_t len) @@ -2244,7 +2245,7 @@ filt_soread(struct knote *kn, long hint) rv = 1; else if (kn->kn_sfflags & NOTE_LOWAT) rv = (kn->kn_data >= kn->kn_sdata); - else + else rv = (kn->kn_data >= so->so_rcv.sb_lowat); if (hint != NOTE_SUBMIT) sounlock(so);
CVS commit: src/usr.sbin/makemandb
Module Name:src Committed By: abhinav Date: Mon May 1 06:56:00 UTC 2017 Modified Files: src/usr.sbin/makemandb: makemandb.c Log Message: Avoid dereferencing pointer at multiple places, instead use a local variable. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/makemandb/makemandb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/makemandb/makemandb.c diff -u src/usr.sbin/makemandb/makemandb.c:1.52 src/usr.sbin/makemandb/makemandb.c:1.53 --- src/usr.sbin/makemandb/makemandb.c:1.52 Mon May 1 06:43:56 2017 +++ src/usr.sbin/makemandb/makemandb.c Mon May 1 06:56:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $ */ +/* $NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $ */ /* * Copyright (c) 2011 Abhinav Upadhyay* Copyright (c) 2011 Kristaps Dzonsons @@ -17,7 +17,7 @@ */ #include -__RCSID("$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $"); +__RCSID("$NetBSD: makemandb.c,v 1.53 2017/05/01 06:56:00 abhinav Exp $"); #include #include @@ -1832,16 +1832,17 @@ insert_into_db(sqlite3 *db, mandb_rec *r * 1: If the hash exists in the database. */ static int -check_md5(const char *file, sqlite3 *db, char **md5sum, void *buf, size_t buflen) +check_md5(const char *file, sqlite3 *db, char **md5, void *buf, size_t buflen) { int rc = 0; int idx = -1; char *sqlstr = NULL; + char *mymd5; sqlite3_stmt *stmt = NULL; + *md5 = NULL; assert(file != NULL); - *md5sum = MD5Data(buf, buflen, NULL); - if (*md5sum == NULL) { + if ((mymd5 = MD5Data(buf, buflen, NULL)) == NULL) { if (mflags.verbosity) warn("md5 failed: %s", file); return -1; @@ -1851,23 +1852,22 @@ check_md5(const char *file, sqlite3 *db, rc = sqlite3_prepare_v2(db, sqlstr, -1, , NULL); if (rc != SQLITE_OK) { free(sqlstr); - free(*md5sum); - *md5sum = NULL; + free(mymd5); return -1; } idx = sqlite3_bind_parameter_index(stmt, ":md5_hash"); - rc = sqlite3_bind_text(stmt, idx, *md5sum, -1, NULL); + rc = sqlite3_bind_text(stmt, idx, mymd5, -1, NULL); if (rc != SQLITE_OK) { if (mflags.verbosity) warnx("%s", sqlite3_errmsg(db)); sqlite3_finalize(stmt); free(sqlstr); - free(*md5sum); - *md5sum = NULL; + free(mymd5); return -1; } + *md5 = mymd5; if (sqlite3_step(stmt) == SQLITE_ROW) { sqlite3_finalize(stmt); free(sqlstr);
CVS commit: src/usr.sbin/makemandb
Module Name:src Committed By: abhinav Date: Mon May 1 06:43:56 UTC 2017 Modified Files: src/usr.sbin/makemandb: makemandb.c Log Message: Remove the table name parameter from the check_md5 function. There is only one table storing the md5 checksums, so we can hardcode the table name instead of passing it as a function argument. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/makemandb/makemandb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/makemandb/makemandb.c diff -u src/usr.sbin/makemandb/makemandb.c:1.51 src/usr.sbin/makemandb/makemandb.c:1.52 --- src/usr.sbin/makemandb/makemandb.c:1.51 Mon May 1 05:52:33 2017 +++ src/usr.sbin/makemandb/makemandb.c Mon May 1 06:43:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $ */ +/* $NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $ */ /* * Copyright (c) 2011 Abhinav Upadhyay* Copyright (c) 2011 Kristaps Dzonsons @@ -17,7 +17,7 @@ */ #include -__RCSID("$NetBSD: makemandb.c,v 1.51 2017/05/01 05:52:33 abhinav Exp $"); +__RCSID("$NetBSD: makemandb.c,v 1.52 2017/05/01 06:43:56 abhinav Exp $"); #include #include @@ -96,7 +96,7 @@ typedef void (*proff_nf)(const struct ro static void append(secbuff *sbuff, const char *src); static void init_secbuffs(mandb_rec *); static void free_secbuffs(mandb_rec *); -static int check_md5(const char *, sqlite3 *, const char *, char **, void *, size_t); +static int check_md5(const char *, sqlite3 *, char **, void *, size_t); static void cleanup(mandb_rec *); static void set_section(const struct roff_man *, mandb_rec *); static void set_machine(const struct roff_man *, mandb_rec *); @@ -804,8 +804,7 @@ update_db(sqlite3 *db, struct mparse *mp err_count++; continue; } - md5_status = check_md5(file, db, "mandb_meta", , buf, - buflen); + md5_status = check_md5(file, db, , buf, buflen); assert(md5sum != NULL); if (md5_status == -1) { if (mflags.verbosity) @@ -1822,7 +1821,7 @@ insert_into_db(sqlite3 *db, mandb_rec *r /* * check_md5-- * Generates the md5 hash of the file and checks if it already doesn't exist - * in the table (passed as the 3rd parameter). + * in the table. * This function is being used to avoid hardlinks. * On successful completion it will also set the value of the fourth parameter * to the md5 hash of the file (computed previously). It is the responsibility @@ -1833,8 +1832,7 @@ insert_into_db(sqlite3 *db, mandb_rec *r * 1: If the hash exists in the database. */ static int -check_md5(const char *file, sqlite3 *db, const char *table, char **md5sum, -void *buf, size_t buflen) +check_md5(const char *file, sqlite3 *db, char **md5sum, void *buf, size_t buflen) { int rc = 0; int idx = -1; @@ -1849,8 +1847,7 @@ check_md5(const char *file, sqlite3 *db, return -1; } - easprintf(, "SELECT * FROM %s WHERE md5_hash = :md5_hash", - table); + easprintf(, "SELECT * FROM mandb_meta WHERE md5_hash = :md5_hash"); rc = sqlite3_prepare_v2(db, sqlstr, -1, , NULL); if (rc != SQLITE_OK) { free(sqlstr);