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>


   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/mman.h>
  33 #include <sys/priocntl.h>
  34 #include <sys/rtpriocntl.h>
  35 #include <sys/resource.h>
  36 #include <sys/termios.h>
  37 #include <sys/param.h>
  38 #include <sys/regset.h>
  39 #include <sys/frame.h>
  40 #include <sys/stack.h>
  41 #include <sys/reg.h>
  42 
  43 #include <libproc.h>
  44 #include <libscf.h>
  45 #include <alloca.h>
  46 #include <unistd.h>
  47 #include <string.h>
  48 #include <stdlib.h>


1081                 mdb_module_load_all(0);
1082 
1083         (void) mdb_signal_sethandler(SIGINT, int_handler, NULL);
1084         while ((status = mdb_run()) == MDB_ERR_ABORT ||
1085             status == MDB_ERR_OUTPUT) {
1086                 /*
1087                  * If a write failed on stdout, give up.  A more informative
1088                  * error message will already have been printed by mdb_run().
1089                  */
1090                 if (status == MDB_ERR_OUTPUT &&
1091                     mdb_iob_getflags(mdb.m_out) & MDB_IOB_ERR) {
1092                         mdb_warn("write to stdout failed, exiting\n");
1093                         break;
1094                 }
1095                 continue;
1096         }
1097 
1098         terminate((status == MDB_ERR_QUIT || status == 0) ?
1099             (eflag != NULL && mdb.m_lastret != 0 ? 1 : 0) : 1);
1100         /*NOTREACHED*/
1101         return (0);
1102 
1103 reexec:
1104         if ((p = strrchr(execname, '/')) == NULL)
1105                 die("cannot determine absolute pathname\n");
1106 #ifdef _LP64
1107 #ifdef __sparc
1108         (void) strcpy(p, "/../sparcv7/");
1109 #else
1110         (void) strcpy(p, "/../i86/");
1111 #endif
1112 #else
1113 #ifdef __sparc
1114         (void) strcpy(p, "/../sparcv9/");
1115 #else
1116         (void) strcpy(p, "/../amd64/");
1117 #endif
1118 #endif
1119         (void) strcat(p, mdb.m_pname);
1120 
1121         if (mdb.m_term != NULL)




   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
  25  */
  26 
  27 /*
  28  * Copyright 2019 Joyent, Inc.
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/mman.h>
  33 #include <sys/priocntl.h>
  34 #include <sys/rtpriocntl.h>
  35 #include <sys/resource.h>
  36 #include <sys/termios.h>
  37 #include <sys/param.h>
  38 #include <sys/regset.h>
  39 #include <sys/frame.h>
  40 #include <sys/stack.h>
  41 #include <sys/reg.h>
  42 
  43 #include <libproc.h>
  44 #include <libscf.h>
  45 #include <alloca.h>
  46 #include <unistd.h>
  47 #include <string.h>
  48 #include <stdlib.h>


1081                 mdb_module_load_all(0);
1082 
1083         (void) mdb_signal_sethandler(SIGINT, int_handler, NULL);
1084         while ((status = mdb_run()) == MDB_ERR_ABORT ||
1085             status == MDB_ERR_OUTPUT) {
1086                 /*
1087                  * If a write failed on stdout, give up.  A more informative
1088                  * error message will already have been printed by mdb_run().
1089                  */
1090                 if (status == MDB_ERR_OUTPUT &&
1091                     mdb_iob_getflags(mdb.m_out) & MDB_IOB_ERR) {
1092                         mdb_warn("write to stdout failed, exiting\n");
1093                         break;
1094                 }
1095                 continue;
1096         }
1097 
1098         terminate((status == MDB_ERR_QUIT || status == 0) ?
1099             (eflag != NULL && mdb.m_lastret != 0 ? 1 : 0) : 1);
1100         /*NOTREACHED*/

1101 
1102 reexec:
1103         if ((p = strrchr(execname, '/')) == NULL)
1104                 die("cannot determine absolute pathname\n");
1105 #ifdef _LP64
1106 #ifdef __sparc
1107         (void) strcpy(p, "/../sparcv7/");
1108 #else
1109         (void) strcpy(p, "/../i86/");
1110 #endif
1111 #else
1112 #ifdef __sparc
1113         (void) strcpy(p, "/../sparcv9/");
1114 #else
1115         (void) strcpy(p, "/../amd64/");
1116 #endif
1117 #endif
1118         (void) strcat(p, mdb.m_pname);
1119 
1120         if (mdb.m_term != NULL)