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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/mdb/mdb_tab.c
          +++ new/usr/src/cmd/mdb/common/mdb/mdb_tab.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2013 by Delphix. All rights reserved.
  23      - * Copyright (c) 2012 Joyent, Inc. All rights reserved.
       23 + * Copyright (c) 2018, Joyent, Inc.
  24   24   * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  25   25   */
  26   26  /*
  27   27   * This file contains all of the interfaces for mdb's tab completion engine.
  28   28   * Currently some interfaces are private to mdb and its internal implementation,
  29   29   * those are in mdb_tab.h. Other pieces are public interfaces. Those are in
  30   30   * mdb_modapi.h.
  31   31   *
  32   32   * Memory allocations in tab completion context have to be done very carefully.
  33   33   * We need to think of ourselves as the same as any other command that is being
↓ open down ↓ 362 lines elided ↑ open up ↑
 396  396  void
 397  397  mdb_tab_insert(mdb_tab_cookie_t *mcp, const char *name)
 398  398  {
 399  399          size_t matches, index;
 400  400          mdb_var_t *v;
 401  401  
 402  402          /*
 403  403           * If we have a match set, then we want to verify that we actually match
 404  404           * it.
 405  405           */
 406      -        if (mcp->mtc_base != NULL &&
 407      -            strncmp(name, mcp->mtc_base, strlen(mcp->mtc_base)) != 0)
      406 +        if (strncmp(name, mcp->mtc_base, strlen(mcp->mtc_base)) != 0)
 408  407                  return;
 409  408  
 410  409          v = mdb_nv_lookup(&mcp->mtc_nv, name);
 411  410          if (v != NULL)
 412  411                  return;
 413  412  
 414  413          (void) mdb_nv_insert(&mcp->mtc_nv, name, NULL, 0, MDB_NV_RDONLY);
 415  414  
 416  415          matches = mdb_tab_size(mcp);
 417  416          if (matches == 1) {
↓ open down ↓ 18 lines elided ↑ open up ↑
 436  435  
 437  436  void
 438  437  mdb_tab_print(mdb_tab_cookie_t *mcp)
 439  438  {
 440  439          mdb_nv_sort_iter(&mcp->mtc_nv, tab_print_cb, NULL, UM_SLEEP | UM_GC);
 441  440  }
 442  441  
 443  442  const char *
 444  443  mdb_tab_match(mdb_tab_cookie_t *mcp)
 445  444  {
 446      -        size_t blen;
 447      -
 448      -        if (mcp->mtc_base == NULL)
 449      -                blen = 0;
 450      -        else
 451      -                blen = strlen(mcp->mtc_base);
 452      -        return (mcp->mtc_match + blen);
      445 +        return (mcp->mtc_match + strlen(mcp->mtc_base));
 453  446  }
 454  447  
 455  448  void
 456  449  mdb_tab_setmbase(mdb_tab_cookie_t *mcp, const char *base)
 457  450  {
 458  451          (void) strlcpy(mcp->mtc_base, base, MDB_SYM_NAMLEN);
 459  452  }
 460  453  
 461  454  /*
 462  455   * This function is currently a no-op due to the fact that we have to GC because
↓ open down ↓ 201 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX