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>


   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 /*
  23  *      Copyright (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.


  27  */
  28 
  29 /*
  30  * Map file parsing (Shared Core Code).
  31  */
  32 #include        <fcntl.h>
  33 #include        <stdio.h>
  34 #include        <unistd.h>
  35 #include        <sys/stat.h>
  36 #include        <errno.h>
  37 #include        <limits.h>
  38 #include        <dirent.h>
  39 #include        <ctype.h>
  40 #include        <debug.h>
  41 #include        "msg.h"
  42 #include        "_libld.h"
  43 #include        "_map.h"
  44 
  45 /*
  46  * There are two styles of mapfile supported by the link-editor:


2056                 case TK_OP_NUM: /* Decimal, hex(0x...), or octal (0...) value */
2057                         if (!ld_map_getint(mf, tkv, FALSE))
2058                                 return (TK_ERROR);
2059                         return (TK_INT);
2060 
2061                 case TK_OP_ID:          /* Unquoted identifier */
2062                         return (gettoken_ident(mf, flags, tkv));
2063 
2064                 case TK_OP_CEQUAL:      /* += or -= */
2065                         if (*(mf->mf_next + 1) != '=')
2066                                 goto tk_op_badchr;
2067                         tok = (ch == '+') ? TK_PLUSEQ : TK_MINUSEQ;
2068                         mf->mf_next += 2;
2069                         return (tok);
2070 
2071                 default:        /* Non-OP token */
2072                         mf->mf_next++;
2073                         return (tok);
2074                 }
2075         }
2076 
2077         /*NOTREACHED*/
2078         assert(0);
2079         return (TK_ERROR);
2080 }
2081 
2082 /*
2083  * Given a token and value returned by ld_map_gettoken(), return a string
2084  * representation of it suitable for use in an error message.
2085  *
2086  * entry:
2087  *      tok - Token code. Must not be an OP-token
2088  *      tkv - Token value
2089  */
2090 const char *
2091 ld_map_tokenstr(Token tok, ld_map_tkval_t *tkv, Conv_inv_buf_t *inv_buf)
2092 {
2093         size_t  cnt;
2094 
2095         switch (tok) {
2096         case TK_ERROR:
2097                 return (MSG_ORIG(MSG_STR_ERROR));
2098         case TK_EOF:
2099                 return (MSG_ORIG(MSG_STR_EOF));




   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 /*
  23  *      Copyright (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  27  *
  28  * Copyright 2019 Joyent, Inc.
  29  */
  30 
  31 /*
  32  * Map file parsing (Shared Core Code).
  33  */
  34 #include        <fcntl.h>
  35 #include        <stdio.h>
  36 #include        <unistd.h>
  37 #include        <sys/stat.h>
  38 #include        <errno.h>
  39 #include        <limits.h>
  40 #include        <dirent.h>
  41 #include        <ctype.h>
  42 #include        <debug.h>
  43 #include        "msg.h"
  44 #include        "_libld.h"
  45 #include        "_map.h"
  46 
  47 /*
  48  * There are two styles of mapfile supported by the link-editor:


2058                 case TK_OP_NUM: /* Decimal, hex(0x...), or octal (0...) value */
2059                         if (!ld_map_getint(mf, tkv, FALSE))
2060                                 return (TK_ERROR);
2061                         return (TK_INT);
2062 
2063                 case TK_OP_ID:          /* Unquoted identifier */
2064                         return (gettoken_ident(mf, flags, tkv));
2065 
2066                 case TK_OP_CEQUAL:      /* += or -= */
2067                         if (*(mf->mf_next + 1) != '=')
2068                                 goto tk_op_badchr;
2069                         tok = (ch == '+') ? TK_PLUSEQ : TK_MINUSEQ;
2070                         mf->mf_next += 2;
2071                         return (tok);
2072 
2073                 default:        /* Non-OP token */
2074                         mf->mf_next++;
2075                         return (tok);
2076                 }
2077         }




2078 }
2079 
2080 /*
2081  * Given a token and value returned by ld_map_gettoken(), return a string
2082  * representation of it suitable for use in an error message.
2083  *
2084  * entry:
2085  *      tok - Token code. Must not be an OP-token
2086  *      tkv - Token value
2087  */
2088 const char *
2089 ld_map_tokenstr(Token tok, ld_map_tkval_t *tkv, Conv_inv_buf_t *inv_buf)
2090 {
2091         size_t  cnt;
2092 
2093         switch (tok) {
2094         case TK_ERROR:
2095                 return (MSG_ORIG(MSG_STR_ERROR));
2096         case TK_EOF:
2097                 return (MSG_ORIG(MSG_STR_EOF));