diff options
author | 2019-07-14 06:37:01 +0000 | |
---|---|---|
committer | 2019-07-14 06:37:01 +0000 | |
commit | 8a8280452c868b3dc0ce1fa0e237ed07c44a5c96 (patch) | |
tree | c56dde4d1193bdb4a784bf996fe56d63f68e3034 | |
parent | Update to libunbound 1.9.2 (diff) | |
download | wireguard-openbsd-8a8280452c868b3dc0ce1fa0e237ed07c44a5c96.tar.xz wireguard-openbsd-8a8280452c868b3dc0ce1fa0e237ed07c44a5c96.zip |
newlen was a dead store, but what we could use is oldlen to
simplify the code.
Pointed out by daniel@ with the help of their friend gcc9
OK kn
-rw-r--r-- | sys/net/if_enc.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index 0fade44065f..aac6f1a9ab2 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_enc.c,v 1.74 2019/06/17 15:13:08 mpi Exp $ */ +/* $OpenBSD: if_enc.c,v 1.75 2019/07/14 06:37:01 florian Exp $ */ /* * Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net> @@ -71,7 +71,7 @@ enc_clone_create(struct if_clone *ifc, int unit) struct enc_softc *sc; struct ifnet *ifp; struct ifnet **new; - size_t newlen; + size_t oldlen; int error; if (unit > ENC_MAX_UNITS) @@ -125,13 +125,11 @@ enc_clone_create(struct if_clone *ifc, int unit) NET_UNLOCK(); return (ENOBUFS); } - newlen = sizeof(struct ifnet *) * (unit + 1); if (enc_allifps != NULL) { - memcpy(new, enc_allifps, - sizeof(struct ifnet *) * (enc_max_unit + 1)); - free(enc_allifps, M_DEVBUF, - sizeof(struct ifnet *) * (enc_max_unit + 1)); + oldlen = sizeof(struct ifnet *) * (enc_max_unit + 1); + memcpy(new, enc_allifps, oldlen); + free(enc_allifps, M_DEVBUF, oldlen); } enc_allifps = new; enc_max_unit = unit; @@ -253,7 +251,7 @@ int enc_setif(struct ifnet *ifp, u_int rdomain) { struct ifnet **new; - size_t newlen; + size_t oldlen; NET_ASSERT_LOCKED(); @@ -275,13 +273,11 @@ enc_setif(struct ifnet *ifp, u_int rdomain) if ((new = mallocarray(rdomain + 1, sizeof(struct ifnet *), M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) return (ENOBUFS); - newlen = sizeof(struct ifnet *) * (rdomain + 1); if (enc_ifps != NULL) { - memcpy(new, enc_ifps, - sizeof(struct ifnet *) * (enc_max_rdomain + 1)); - free(enc_ifps, M_DEVBUF, - sizeof(struct ifnet *) * (enc_max_rdomain + 1)); + oldlen = sizeof(struct ifnet *) * (enc_max_rdomain + 1); + memcpy(new, enc_ifps, oldlen); + free(enc_ifps, M_DEVBUF, oldlen); } enc_ifps = new; enc_max_rdomain = rdomain; |