Print this page
10132 smatch fixes for MDB
Reviewed by: Andy Fiddaman <andy@omniosce.org>


   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*




  27  * mdb dcmds for selected structures from
  28  * usr/src/uts/common/sys/crypto/spi.h
  29  *
  30  * Also the mdb module housekeeping
  31  */
  32 
  33 #include <sys/mdb_modapi.h>
  34 #include <sys/modctl.h>
  35 #include <sys/crypto/api.h>
  36 #include <sys/crypto/common.h>
  37 #include <sys/crypto/spi.h>
  38 #include <sys/crypto/impl.h>
  39 #include "crypto_cmds.h"
  40 
  41 
  42 const mdb_bitmask_t extf_flags[] = {
  43         { "NIL", (ulong_t)-1, 0L },
  44         { "CRYPTO_EXTF_RNG", CRYPTO_EXTF_RNG, CRYPTO_EXTF_RNG },
  45         { "CRYPTO_EXTF_WRITE_PROTECTED", CRYPTO_EXTF_WRITE_PROTECTED,
  46                 CRYPTO_EXTF_WRITE_PROTECTED },


 174         { "CRYPTO_FG_VERIFY_ATOMIC", CRYPTO_FG_VERIFY_ATOMIC,
 175                 CRYPTO_FG_VERIFY_ATOMIC },
 176         { "CRYPTO_FG_VERIFY_RECOVER_ATOMIC", CRYPTO_FG_VERIFY_RECOVER_ATOMIC,
 177                 CRYPTO_FG_VERIFY_RECOVER_ATOMIC },
 178         { "CRYPTO_FG_ENCRYPT_MAC_ATOMIC", CRYPTO_FG_ENCRYPT_MAC_ATOMIC,
 179                 CRYPTO_FG_ENCRYPT_MAC_ATOMIC },
 180         { "CRYPTO_FG_MAC_DECRYPT_ATOMIC", CRYPTO_FG_MAC_DECRYPT_ATOMIC,
 181                 CRYPTO_FG_MAC_DECRYPT_ATOMIC },
 182         { "CRYPTO_FG_RANDOM", CRYPTO_FG_RANDOM, CRYPTO_FG_RANDOM},
 183         { NULL, 0, 0 }
 184 };
 185 
 186 /*ARGSUSED*/
 187 int
 188 crypto_mech_info(uintptr_t addr, uint_t flags, int argc,
 189     const mdb_arg_t *argv)
 190 {
 191         crypto_mech_info_t minfo;
 192         const char *unit = "bits";
 193 
 194         if (! flags & DCMD_ADDRSPEC)
 195                 return (DCMD_USAGE);
 196 
 197         if (mdb_vread(&minfo, sizeof (crypto_mech_info_t), addr)
 198             == -1) {
 199                 mdb_warn("cannot read addr %p", addr);
 200                 return (DCMD_ERR);
 201         }
 202         mdb_printf("cm_mech_name_t\t%s\n", minfo.cm_mech_name);
 203         mdb_printf("cm_mech_number\t%lld\n", minfo.cm_mech_number);
 204         mdb_printf("cm_func_group_mask\t0x%x:\t<%b>\n",
 205             minfo.cm_func_group_mask, minfo.cm_func_group_mask, mech_bits);
 206         if (minfo.cm_keysize_unit & CRYPTO_KEYSIZE_UNIT_IN_BYTES)
 207                 unit = "bytes";
 208         mdb_printf("cm_min_key_length\t%lu %s\n", minfo.cm_min_key_length,
 209             unit);
 210         mdb_printf("cm_max_key_length\t%lu %s\n", minfo.cm_max_key_length,
 211             unit);
 212 
 213         return (DCMD_OK);
 214 }




   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 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 /*
  31  * mdb dcmds for selected structures from
  32  * usr/src/uts/common/sys/crypto/spi.h
  33  *
  34  * Also the mdb module housekeeping
  35  */
  36 
  37 #include <sys/mdb_modapi.h>
  38 #include <sys/modctl.h>
  39 #include <sys/crypto/api.h>
  40 #include <sys/crypto/common.h>
  41 #include <sys/crypto/spi.h>
  42 #include <sys/crypto/impl.h>
  43 #include "crypto_cmds.h"
  44 
  45 
  46 const mdb_bitmask_t extf_flags[] = {
  47         { "NIL", (ulong_t)-1, 0L },
  48         { "CRYPTO_EXTF_RNG", CRYPTO_EXTF_RNG, CRYPTO_EXTF_RNG },
  49         { "CRYPTO_EXTF_WRITE_PROTECTED", CRYPTO_EXTF_WRITE_PROTECTED,
  50                 CRYPTO_EXTF_WRITE_PROTECTED },


 178         { "CRYPTO_FG_VERIFY_ATOMIC", CRYPTO_FG_VERIFY_ATOMIC,
 179                 CRYPTO_FG_VERIFY_ATOMIC },
 180         { "CRYPTO_FG_VERIFY_RECOVER_ATOMIC", CRYPTO_FG_VERIFY_RECOVER_ATOMIC,
 181                 CRYPTO_FG_VERIFY_RECOVER_ATOMIC },
 182         { "CRYPTO_FG_ENCRYPT_MAC_ATOMIC", CRYPTO_FG_ENCRYPT_MAC_ATOMIC,
 183                 CRYPTO_FG_ENCRYPT_MAC_ATOMIC },
 184         { "CRYPTO_FG_MAC_DECRYPT_ATOMIC", CRYPTO_FG_MAC_DECRYPT_ATOMIC,
 185                 CRYPTO_FG_MAC_DECRYPT_ATOMIC },
 186         { "CRYPTO_FG_RANDOM", CRYPTO_FG_RANDOM, CRYPTO_FG_RANDOM},
 187         { NULL, 0, 0 }
 188 };
 189 
 190 /*ARGSUSED*/
 191 int
 192 crypto_mech_info(uintptr_t addr, uint_t flags, int argc,
 193     const mdb_arg_t *argv)
 194 {
 195         crypto_mech_info_t minfo;
 196         const char *unit = "bits";
 197 
 198         if (!(flags & DCMD_ADDRSPEC))
 199                 return (DCMD_USAGE);
 200 
 201         if (mdb_vread(&minfo, sizeof (crypto_mech_info_t), addr)
 202             == -1) {
 203                 mdb_warn("cannot read addr %p", addr);
 204                 return (DCMD_ERR);
 205         }
 206         mdb_printf("cm_mech_name_t\t%s\n", minfo.cm_mech_name);
 207         mdb_printf("cm_mech_number\t%lld\n", minfo.cm_mech_number);
 208         mdb_printf("cm_func_group_mask\t0x%x:\t<%b>\n",
 209             minfo.cm_func_group_mask, minfo.cm_func_group_mask, mech_bits);
 210         if (minfo.cm_keysize_unit & CRYPTO_KEYSIZE_UNIT_IN_BYTES)
 211                 unit = "bytes";
 212         mdb_printf("cm_min_key_length\t%lu %s\n", minfo.cm_min_key_length,
 213             unit);
 214         mdb_printf("cm_max_key_length\t%lu %s\n", minfo.cm_max_key_length,
 215             unit);
 216 
 217         return (DCMD_OK);
 218 }