Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 /*
  25  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 /*
  29  * Layered driver support.
  30  */
  31 
  32 #include <sys/atomic.h>
  33 #include <sys/types.h>
  34 #include <sys/t_lock.h>
  35 #include <sys/param.h>
  36 #include <sys/conf.h>
  37 #include <sys/systm.h>
  38 #include <sys/sysmacros.h>
  39 #include <sys/buf.h>
  40 #include <sys/cred.h>
  41 #include <sys/uio.h>
  42 #include <sys/vnode.h>
  43 #include <sys/fs/snode.h>
  44 #include <sys/open.h>
  45 #include <sys/kmem.h>


3476 ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type,
3477     ldi_ev_cookie_t cookie, void *ev_data)
3478 {
3479         char            *evname = ldi_ev_get_type(cookie);
3480         uint_t          ct_evtype;
3481         dev_t           dev;
3482         major_t         major;
3483         int             retc;
3484         int             retl;
3485 
3486         ASSERT(spec_type == S_IFBLK || spec_type == S_IFCHR);
3487         ASSERT(dip);
3488         ASSERT(ldi_native_cookie(cookie));
3489 
3490         LDI_EVDBG((CE_NOTE, "ldi_ev_notify(): entered: event=%s, dip=%p",
3491             evname, (void *)dip));
3492 
3493         if (!ldi_ev_sync_event(evname)) {
3494                 cmn_err(CE_PANIC, "ldi_ev_notify(): %s not a "
3495                     "negotiatable event", evname);
3496                 return (LDI_EV_SUCCESS);
3497         }
3498 
3499         major = ddi_driver_major(dip);
3500         if (major == DDI_MAJOR_T_NONE) {
3501                 char *path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
3502                 (void) ddi_pathname(dip, path);
3503                 cmn_err(CE_WARN, "ldi_ev_notify: cannot derive major number "
3504                     "for device %s", path);
3505                 kmem_free(path, MAXPATHLEN);
3506                 return (LDI_EV_FAILURE);
3507         }
3508         dev = makedevice(major, minor);
3509 
3510         /*
3511          * Generate negotiation contract events on contracts (if any) associated
3512          * with this minor.
3513          */
3514         LDI_EVDBG((CE_NOTE, "ldi_ev_notify(): calling contract nego."));
3515         ct_evtype = ldi_contract_event(evname);
3516         retc = contract_device_negotiate(dip, dev, spec_type, ct_evtype);




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 /*
  25  * Copyright 2019 Joyent, Inc.
  26  */
  27 
  28 /*
  29  * Layered driver support.
  30  */
  31 
  32 #include <sys/atomic.h>
  33 #include <sys/types.h>
  34 #include <sys/t_lock.h>
  35 #include <sys/param.h>
  36 #include <sys/conf.h>
  37 #include <sys/systm.h>
  38 #include <sys/sysmacros.h>
  39 #include <sys/buf.h>
  40 #include <sys/cred.h>
  41 #include <sys/uio.h>
  42 #include <sys/vnode.h>
  43 #include <sys/fs/snode.h>
  44 #include <sys/open.h>
  45 #include <sys/kmem.h>


3476 ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type,
3477     ldi_ev_cookie_t cookie, void *ev_data)
3478 {
3479         char            *evname = ldi_ev_get_type(cookie);
3480         uint_t          ct_evtype;
3481         dev_t           dev;
3482         major_t         major;
3483         int             retc;
3484         int             retl;
3485 
3486         ASSERT(spec_type == S_IFBLK || spec_type == S_IFCHR);
3487         ASSERT(dip);
3488         ASSERT(ldi_native_cookie(cookie));
3489 
3490         LDI_EVDBG((CE_NOTE, "ldi_ev_notify(): entered: event=%s, dip=%p",
3491             evname, (void *)dip));
3492 
3493         if (!ldi_ev_sync_event(evname)) {
3494                 cmn_err(CE_PANIC, "ldi_ev_notify(): %s not a "
3495                     "negotiatable event", evname);

3496         }
3497 
3498         major = ddi_driver_major(dip);
3499         if (major == DDI_MAJOR_T_NONE) {
3500                 char *path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
3501                 (void) ddi_pathname(dip, path);
3502                 cmn_err(CE_WARN, "ldi_ev_notify: cannot derive major number "
3503                     "for device %s", path);
3504                 kmem_free(path, MAXPATHLEN);
3505                 return (LDI_EV_FAILURE);
3506         }
3507         dev = makedevice(major, minor);
3508 
3509         /*
3510          * Generate negotiation contract events on contracts (if any) associated
3511          * with this minor.
3512          */
3513         LDI_EVDBG((CE_NOTE, "ldi_ev_notify(): calling contract nego."));
3514         ct_evtype = ldi_contract_event(evname);
3515         retc = contract_device_negotiate(dip, dev, spec_type, ct_evtype);