diff options
author | John Levon <john.levon@joyent.com> | 2018-12-19 18:38:05 +0000 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2019-01-30 18:31:43 -0500 |
commit | d75f3745ad3c36431063bb316666f4d316eabc8c (patch) | |
tree | 00cfbb59bedf21989e3fcd05525be8c726a0bb4c | |
parent | 9850293dd7e478722798fcf0c1e690339cd94590 (diff) | |
download | illumos-joyent-d75f3745ad3c36431063bb316666f4d316eabc8c.tar.gz |
10132 smatch fixes for MDB
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r-- | usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c | 3 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_cmds.c | 10 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_nm.c | 6 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_proc.c | 3 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_tab.c | 53 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/crypto/spi.c | 6 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/fcp/fcp.c | 11 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/fctl/fctl.c | 9 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/genunix/ndievents.c | 31 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/libumem/umem.c | 4 | ||||
-rw-r--r-- | usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c | 2 | ||||
-rw-r--r-- | usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c | 4 |
13 files changed, 72 insertions, 74 deletions
diff --git a/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c b/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c index 316ed77e8e..f581d1dbad 100644 --- a/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c +++ b/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c @@ -2388,8 +2388,7 @@ kmt_destroy(mdb_tgt_t *t) if (kmt->kmt_trapmap != NULL) mdb_free(kmt->kmt_trapmap, BT_SIZEOFMAP(kmt->kmt_trapmax)); - if (kmt != NULL) - mdb_free(kmt, sizeof (kmt_data_t)); + mdb_free(kmt, sizeof (kmt_data_t)); } static const mdb_tgt_ops_t kmt_ops = { diff --git a/usr/src/cmd/mdb/common/mdb/mdb.c b/usr/src/cmd/mdb/common/mdb/mdb.c index 5c1c5fc84a..eb6b46083f 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb.c +++ b/usr/src/cmd/mdb/common/mdb/mdb.c @@ -24,7 +24,7 @@ */ /* * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright (c) 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. */ /* @@ -1155,7 +1155,7 @@ mdb_call_tab(mdb_idcmd_t *idcp, mdb_tab_cookie_t *mcp, uint_t flags, if (idcp->idc_tabp == NULL) return; - idcp->idc_tabp(mcp, flags, argc, argv); + (void) idcp->idc_tabp(mcp, flags, argc, argv); } /* diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c index fbd404a107..a543aafb09 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c @@ -26,7 +26,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright (c) 2018 Joyent, Inc. All rights reserved. + * Copyright (c) 2019 Joyent, Inc. All rights reserved. * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * Copyright (c) 2015, 2017 by Delphix. All rights reserved. * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. @@ -1520,9 +1520,9 @@ map_name(const mdb_map_t *map, const char *name) return ("[ stack ]"); if (map->map_flags & MDB_TGT_MAP_ANON) return ("[ anon ]"); - if (map->map_name != NULL) - return (map->map_name); - return ("[ unknown ]"); + if (map->map_name[0] == '\0') + return ("[ unknown ]"); + return (map->map_name); } /*ARGSUSED*/ @@ -2343,7 +2343,7 @@ cmd_head(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) const char *c; mdb_pipe_t p; - if (!flags & DCMD_PIPE) + if (!(flags & DCMD_PIPE)) return (DCMD_USAGE); if (argc == 1 || argc == 2) { diff --git a/usr/src/cmd/mdb/common/mdb/mdb_nm.c b/usr/src/cmd/mdb/common/mdb/mdb_nm.c index 2c427d1f59..0653075e54 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_nm.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_nm.c @@ -23,6 +23,10 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2018, Joyent, Inc. + */ + #include <sys/elf.h> #include <sys/elf_SPARC.h> @@ -785,7 +789,7 @@ cmd_nm(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) for (symp = syms; nsyms-- != 0; symp++) { nii.nii_fp = symp->nm_fp; - callback(&nii, &symp->nm_sym, symp->nm_name, + (void) callback(&nii, &symp->nm_sym, symp->nm_name, &symp->nm_si, symp->nm_object); } diff --git a/usr/src/cmd/mdb/common/mdb/mdb_proc.c b/usr/src/cmd/mdb/common/mdb/mdb_proc.c index 33994c11e6..48f241b222 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_proc.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_proc.c @@ -1990,8 +1990,7 @@ pt_env_set(pt_data_t *pt, const char *nameval) (void) mdb_nv_insert(&pt->p_env, name, NULL, (uintptr_t)val, MDB_NV_EXTNAME); - if (equals) - *equals = '='; + *equals = '='; } /* diff --git a/usr/src/cmd/mdb/common/mdb/mdb_tab.c b/usr/src/cmd/mdb/common/mdb/mdb_tab.c index af32623470..8addc11a46 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_tab.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_tab.c @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2013 by Delphix. All rights reserved. - * Copyright (c) 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> */ /* @@ -57,7 +57,7 @@ /* * find_command_start -- * - * Given a buffer find the start of the last command. + * Given a buffer find the start of the last command. */ static char * tab_find_command_start(char *buf) @@ -82,11 +82,11 @@ tab_find_command_start(char *buf) /* * get_dcmd -- * - * Given a buffer containing a command and its argument return - * the name of the command and the offset in the buffer where - * the command arguments start. + * Given a buffer containing a command and its argument return + * the name of the command and the offset in the buffer where + * the command arguments start. * - * Note: This will modify the buffer. + * Note: This will modify the buffer. */ char * tab_get_dcmd(char *buf, char **args, uint_t *flags) @@ -118,11 +118,11 @@ tab_get_dcmd(char *buf, char **args, uint_t *flags) /* * count_args -- * - * Given a buffer containing dmcd arguments return the total number - * of arguments. + * Given a buffer containing dmcd arguments return the total number + * of arguments. * - * While parsing arguments we need to keep track of whether or not the last - * arguments ends with a trailing space. + * While parsing arguments we need to keep track of whether or not the last + * arguments ends with a trailing space. */ static int tab_count_args(const char *input, uint_t *flags) @@ -158,10 +158,10 @@ tab_count_args(const char *input, uint_t *flags) /* * copy_args -- * - * Given a buffer containing dcmd arguments and an array of mdb_arg_t's - * initialize the string value of each mdb_arg_t. + * Given a buffer containing dcmd arguments and an array of mdb_arg_t's + * initialize the string value of each mdb_arg_t. * - * Note: This will modify the buffer. + * Note: This will modify the buffer. */ static int tab_copy_args(char *input, int argc, mdb_arg_t *argv) @@ -204,12 +204,12 @@ tab_copy_args(char *input, int argc, mdb_arg_t *argv) /* * parse-buf -- * - * Parse the given buffer and return the specified dcmd, the number - * of arguments, and array of mdb_arg_t containing the argument - * values. + * Parse the given buffer and return the specified dcmd, the number + * of arguments, and array of mdb_arg_t containing the argument + * values. * - * Note: this will modify the specified buffer. Caller is responisble - * for freeing argvp. + * Note: this will modify the specified buffer. Caller is responisble + * for freeing argvp. */ static int tab_parse_buf(char *buf, char **dcmdp, int *argcp, mdb_arg_t **argvp, @@ -253,9 +253,9 @@ tab_parse_buf(char *buf, char **dcmdp, int *argcp, mdb_arg_t **argvp, /* * tab_command -- * - * This function is executed anytime a tab is entered. It checks - * the current buffer to determine if there is a valid dmcd, - * if that dcmd has a tab completion handler it will invoke it. + * This function is executed anytime a tab is entered. It checks + * the current buffer to determine if there is a valid dmcd, + * if that dcmd has a tab completion handler it will invoke it. * * This function returns the string (if any) that should be added to the * existing buffer to complete it. @@ -403,8 +403,7 @@ mdb_tab_insert(mdb_tab_cookie_t *mcp, const char *name) * If we have a match set, then we want to verify that we actually match * it. */ - if (mcp->mtc_base != NULL && - strncmp(name, mcp->mtc_base, strlen(mcp->mtc_base)) != 0) + if (strncmp(name, mcp->mtc_base, strlen(mcp->mtc_base)) != 0) return; v = mdb_nv_lookup(&mcp->mtc_nv, name); @@ -443,13 +442,7 @@ mdb_tab_print(mdb_tab_cookie_t *mcp) const char * mdb_tab_match(mdb_tab_cookie_t *mcp) { - size_t blen; - - if (mcp->mtc_base == NULL) - blen = 0; - else - blen = strlen(mcp->mtc_base); - return (mcp->mtc_match + blen); + return (mcp->mtc_match + strlen(mcp->mtc_base)); } void diff --git a/usr/src/cmd/mdb/common/modules/crypto/spi.c b/usr/src/cmd/mdb/common/modules/crypto/spi.c index 775884f358..2c28720110 100644 --- a/usr/src/cmd/mdb/common/modules/crypto/spi.c +++ b/usr/src/cmd/mdb/common/modules/crypto/spi.c @@ -24,6 +24,10 @@ */ /* + * Copyright (c) 2018, Joyent, Inc. + */ + +/* * mdb dcmds for selected structures from * usr/src/uts/common/sys/crypto/spi.h * @@ -191,7 +195,7 @@ crypto_mech_info(uintptr_t addr, uint_t flags, int argc, crypto_mech_info_t minfo; const char *unit = "bits"; - if (! flags & DCMD_ADDRSPEC) + if (!(flags & DCMD_ADDRSPEC)) return (DCMD_USAGE); if (mdb_vread(&minfo, sizeof (crypto_mech_info_t), addr) diff --git a/usr/src/cmd/mdb/common/modules/fcp/fcp.c b/usr/src/cmd/mdb/common/modules/fcp/fcp.c index 0b9f2dc90f..a16e3a1308 100644 --- a/usr/src/cmd/mdb/common/modules/fcp/fcp.c +++ b/usr/src/cmd/mdb/common/modules/fcp/fcp.c @@ -22,7 +22,7 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * - * FCP mdb module + * Copyright (c) 2018, Joyent, Inc. */ @@ -328,8 +328,8 @@ targets_walk_i(mdb_walk_state_t *wsp) tgt_hash_index = 0; - while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) && - (tgt_hash_index < FCP_NUM_HASH)) { + while (tgt_hash_index < FCP_NUM_HASH && + port.port_tgt_hash_table[tgt_hash_index] == NULL) { tgt_hash_index++; } @@ -369,10 +369,9 @@ targets_walk_s(mdb_walk_state_t *wsp) tgt_hash_index++; - while ((port.port_tgt_hash_table[tgt_hash_index] == NULL) && - (tgt_hash_index < FCP_NUM_HASH)) { + while (tgt_hash_index < FCP_NUM_HASH && + port.port_tgt_hash_table[tgt_hash_index] == NULL) tgt_hash_index++; - } if (tgt_hash_index == FCP_NUM_HASH) { /* You're done */ diff --git a/usr/src/cmd/mdb/common/modules/fctl/fctl.c b/usr/src/cmd/mdb/common/modules/fctl/fctl.c index 8e135fbf34..89a8139c83 100644 --- a/usr/src/cmd/mdb/common/modules/fctl/fctl.c +++ b/usr/src/cmd/mdb/common/modules/fctl/fctl.c @@ -23,6 +23,9 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2018, Joyent, Inc. + */ #include <sys/mdb_modapi.h> #include <sys/mutex.h> @@ -244,7 +247,7 @@ ulp_walk_f(mdb_walk_state_t *wsp) static int ulps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { - fc_ulp_list_t ulplist; + fc_ulp_list_t ulplist; fc_ulp_modinfo_t ulp; char ulp_name[30]; @@ -354,7 +357,7 @@ ulpmod_walk_f(mdb_walk_state_t *wsp) static int ulpmods(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { - fc_ulp_module_t modlist; + fc_ulp_module_t modlist; fc_ulp_modinfo_t modinfo; fc_ulp_ports_t ulp_port; @@ -1109,7 +1112,7 @@ fc_trace_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) return (DCMD_USAGE); } - if (logq.il_flags & FC_TRACE_LOGQ_V2 != 0) { + if ((logq.il_flags & FC_TRACE_LOGQ_V2) != 0) { rval = fc_dump_logmsg((fc_trace_dmsg_t *)logq.il_msgh, pktstart, pktend, &printed); } else { diff --git a/usr/src/cmd/mdb/common/modules/genunix/ndievents.c b/usr/src/cmd/mdb/common/modules/genunix/ndievents.c index 764250520e..ed31a9c559 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/ndievents.c +++ b/usr/src/cmd/mdb/common/modules/genunix/ndievents.c @@ -24,7 +24,9 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2018, Joyent, Inc. + */ #include "ndievents.h" #include <sys/sunndi.h> @@ -36,8 +38,8 @@ int -dip_to_pathname(struct dev_info *device, char *path, int buflen) { - +dip_to_pathname(struct dev_info *device, char *path, int buflen) +{ char *bp; char *addr; char addr_str[32]; @@ -52,7 +54,7 @@ dip_to_pathname(struct dev_info *device, char *path, int buflen) { if (device->devi_parent == NULL) { if (mdb_readstr(nodename, sizeof (nodename), (uintptr_t)device->devi_node_name) == -1) { - return (-1); + return (-1); } if (sizeof (nodename) > (buflen - strlen(path))) { @@ -80,7 +82,7 @@ dip_to_pathname(struct dev_info *device, char *path, int buflen) { } if (device->devi_node_state < DS_INITIALIZED) { - strncpy(addr_str, '\0', sizeof ('\0')); + addr_str[0] = '\0'; } else { addr = device->devi_addr; if (mdb_readstr(addr_str, sizeof (addr_str), @@ -119,7 +121,7 @@ ndi_callback_print(struct ndi_event_cookie *cookie, uint_t flags) while (callback_list != NULL) { if (mdb_vread(&cb, sizeof (struct ndi_event_callbacks), - (uintptr_t)callback_list) == -1) { + (uintptr_t)callback_list) == -1) { mdb_warn("Could not read callback structure at" " %p", callback_list); return (DCMD_ERR); @@ -156,10 +158,10 @@ int ndi_event_print(struct ndi_event_hdl *hdl, uint_t flags) { - struct ndi_event_definition def; - struct ndi_event_cookie cookie; - struct ndi_event_cookie *cookie_list; - char ndi_event_name[256]; + struct ndi_event_definition def; + struct ndi_event_cookie cookie; + struct ndi_event_cookie *cookie_list; + char ndi_event_name[256]; if (!hdl) return (DCMD_ERR); @@ -222,8 +224,7 @@ ndi_event_hdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) } if (mdb_vread(&devi, sizeof (struct dev_info), - (uintptr_t)handle.ndi_evthdl_dip) - == -1) { + (uintptr_t)handle.ndi_evthdl_dip) == -1) { mdb_warn("failed to read devinfo node at %p", handle.ndi_evthdl_dip); return (DCMD_ERR); @@ -250,9 +251,9 @@ ndi_event_hdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) addr = (uintptr_t)handle.ndi_next_hdl; if (mdb_vread(&handle, sizeof (struct ndi_event_hdl), (uintptr_t)addr) == -1) { - mdb_warn("failed to read ndi_event_hdl at %p", - addr); - break; + mdb_warn("failed to read ndi_event_hdl at %p", + addr); + break; } } diff --git a/usr/src/cmd/mdb/common/modules/libumem/umem.c b/usr/src/cmd/mdb/common/modules/libumem/umem.c index 65a06cb31c..43b6ea3458 100644 --- a/usr/src/cmd/mdb/common/modules/libumem/umem.c +++ b/usr/src/cmd/mdb/common/modules/libumem/umem.c @@ -24,7 +24,7 @@ */ /* - * Copyright 2012 Joyent, Inc. All rights reserved. + * Copyright (c) 2018, Joyent, Inc. * Copyright (c) 2013, 2015 by Delphix. All rights reserved. */ @@ -2116,7 +2116,7 @@ whatis_walk_seg(uintptr_t addr, const vmem_seg_t *vs, whatis_info_t *wi) (vs->vs_type == VMEM_ALLOC) ? "allocated" : "freed", wi->wi_vmem->vm_name); - if (!mdb_whatis_flags(w) & WHATIS_QUIET) + if (!(mdb_whatis_flags(w) & WHATIS_QUIET)) whatis_call_printer(vmem_seg, addr); else mdb_printf("\n"); diff --git a/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c b/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c index d86c1b79f8..2e374c0fc3 100644 --- a/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c +++ b/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c @@ -309,8 +309,6 @@ fpcw2str(uint32_t cw, char *buf, size_t nbytes) /* * Decode precision, rounding, and infinity options in control word. */ - if (cw & FPSIG24) - p += mdb_snprintf(p, (size_t)(end - p), "|SIG24"); if (cw & FPSIG53) p += mdb_snprintf(p, (size_t)(end - p), "|SIG53"); if (cw & FPSIG64) diff --git a/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c b/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c index 5ebe2df9f4..4433a36705 100644 --- a/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c +++ b/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ /* - * Copyright 2015 Joyent, Inc. + * Copyright (c) 2018, Joyent, Inc. */ /* @@ -250,8 +250,6 @@ fpcw2str(uint32_t cw, char *buf, size_t nbytes) /* * Decode precision, rounding, and infinity options in control word. */ - if (cw & FPSIG24) - p += mdb_snprintf(p, (size_t)(end - p), "|SIG24"); if (cw & FPSIG53) p += mdb_snprintf(p, (size_t)(end - p), "|SIG53"); if (cw & FPSIG64) |