diff options
author | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2005-10-03 02:14:51 +0000 |
---|---|---|
committer | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2005-10-03 02:14:51 +0000 |
commit | b5c8bd592412d0deb3c2aa843b93d08907747fa5 (patch) | |
tree | 436deb331c457cd1d1044ecb8d94b45008fb9b74 /sys/net/if.c | |
parent | 7aebc5e86e09fa082b50a3ae4e8f2733b02e35c6 (diff) | |
download | src-b5c8bd592412d0deb3c2aa843b93d08907747fa5.tar.gz src-b5c8bd592412d0deb3c2aa843b93d08907747fa5.zip |
Clean up consistency checks in if_setflag():
. use KASSERT for all checks so that the source of an error can be detected;
. use __func__ instead of spelling function name each time;
. fix a typo.
Notes
Notes:
svn path=/head/; revision=150845
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index bc51abea2138..31d286b30481 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1594,7 +1594,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) /* * The code common to handling reference counted flags, * e.g., in ifpromisc() and if_allmulti(). - * The "pflag" argument can specify a permanent mode flag, + * The "pflag" argument can specify a permanent mode flag to check, * such as IFF_PPROMISC for promiscuous mode; should be 0 if none. * * Only to be used on stack-owned flags, not driver-owned flags. @@ -1606,25 +1606,18 @@ if_setflag(struct ifnet *ifp, int flag, int pflag, int *refcount, int onswitch) int error; int oldflags, oldcount; + /* Sanity checks to catch programming errors */ KASSERT((flag & (IFF_DRV_OACTIVE|IFF_DRV_RUNNING)) == 0, - ("if_setflag: setting driver-ownded flag %d", flag)); + ("%s: setting driver-owned flag %d", __func__, flag)); - /* Sanity checks to catch programming errors */ - if (onswitch) { - if (*refcount < 0) { - if_printf(ifp, - "refusing to increment negative refcount %d " - "for interface flag %d\n", *refcount, flag); - return (EINVAL); - } - } else { - if (*refcount <= 0) { - if_printf(ifp, - "refusing to decrement non-positive refcount %d" - "for interface flag %d\n", *refcount, flag); - return (EINVAL); - } - } + if (onswitch) + KASSERT(*refcount >= 0, + ("%s: increment negative refcount %d for flag %d", + __func__, *refcount, flag)); + else + KASSERT(*refcount > 0, + ("%s: decrement non-positive refcount %d for flag %d", + __func__, *refcount, flag)); /* In case this mode is permanent, just touch refcount */ if (ifp->if_flags & pflag) { |