On Fri, Sep 27, 2013 at 03:24:25PM +0200, Alexander Bluhm wrote: > The error return codes for the enc interface seem quite inconsistent. > Always return the appropriate errno. > > ok? >
OK Reyk > bluhm > > Index: net/if_enc.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_enc.c,v > retrieving revision 1.52 > diff -u -p -u -p -r1.52 if_enc.c > --- net/if_enc.c 3 Jul 2010 04:44:51 -0000 1.52 > +++ net/if_enc.c 27 Sep 2013 13:01:19 -0000 > @@ -72,13 +72,14 @@ enc_clone_create(struct if_clone *ifc, i > struct ifnet *ifp; > struct ifnet **new; > size_t newlen; > + int error; > > if (unit > ENC_MAX_UNITS) > return (EINVAL); > > if ((sc = malloc(sizeof(struct enc_softc), > M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) > - return (ENOMEM); > + return (ENOBUFS); > > sc->sc_unit = unit; > > @@ -102,17 +103,17 @@ enc_clone_create(struct if_clone *ifc, i > bpfattach(&ifp->if_bpf, ifp, DLT_ENC, ENC_HDRLEN); > #endif > > - if (enc_setif(ifp, 0) != 0) { > + if ((error = enc_setif(ifp, 0)) != 0) { > if_detach(ifp); > free(sc, M_DEVBUF); > - return (-1); > + return (error); > } > > if (unit == 0 || unit > enc_max_unit) { > newlen = sizeof(struct ifnet *) * (unit + 1); > > if ((new = malloc(newlen, M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) > - return (-1); > + return (ENOBUFS); > if (enc_allifps != NULL) { > memcpy(new, enc_allifps, > sizeof(struct ifnet *) * (enc_max_unit + 1)); > @@ -172,7 +173,7 @@ int > enc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) > { > struct ifreq *ifr = (struct ifreq *)data; > - int error = 0; > + int error; > > switch (cmd) { > case SIOCAIFADDR: > @@ -238,13 +239,13 @@ enc_setif(struct ifnet *ifp, u_int id) > return (0); > > if (id > RT_TABLEID_MAX) > - return (-1); > + return (EINVAL); > > if (id == 0 || id > enc_max_id) { > newlen = sizeof(struct ifnet *) * (id + 1); > > if ((new = malloc(newlen, M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) > - return (-1); > + return (ENOBUFS); > if (enc_ifps != NULL) { > memcpy(new, enc_ifps, > sizeof(struct ifnet *) * (enc_max_id + 1)); >