Print this page
11227 smb code needs smatch fixes

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/smbsrv/testoplock/tol_main.c
          +++ new/usr/src/cmd/smbsrv/testoplock/tol_main.c
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
       14 + * Copyright 2019 Joyent, Inc.
  14   15   */
  15   16  
  16   17  /*
  17   18   * Test & debug program for oplocks
  18   19   *
  19   20   * This implements a simple command reader which accepts
  20   21   * commands to simulate oplock events, and prints the
  21   22   * state changes and actions that would happen after
  22   23   * each event.
  23   24   */
↓ open down ↓ 134 lines elided ↑ open up ↑
 158  159          smb_ofile_t *ofile = &ofile_array[fid];
 159  160  
 160  161          /*
 161  162           * Simulate an open (minimal init)
 162  163           */
 163  164          if (ofile->f_refcnt) {
 164  165                  printf("open fid %d already opened\n");
 165  166                  return;
 166  167          }
 167  168  
 168      -        if (arg2 != NULL)
 169      -                strlcpy((char *)ofile->TargetOplockKey, arg2,
      169 +        if (arg2 != NULL) {
      170 +                (void) strlcpy((char *)ofile->TargetOplockKey, arg2,
 170  171                      SMB_LEASE_KEY_SZ);
      172 +        }
 171  173  
 172  174          ofile->f_refcnt++;
 173  175          node->n_open_count++;
 174  176          smb_llist_insert_tail(&node->n_ofile_list, ofile);
 175  177          printf(" open %d OK\n", fid);
 176  178  }
 177  179  
 178  180  static void
 179  181  do_close(int fid)
 180  182  {
↓ open down ↓ 209 lines elided ↑ open up ↑
 390  392  
 391  393                  f->f_magic = SMB_OFILE_MAGIC;
 392  394                  mutex_init(&f->f_mutex, NULL, MUTEX_DEFAULT, NULL);
 393  395                  f->f_fid = fid;
 394  396                  f->f_ftype = SMB_FTYPE_DISK;
 395  397                  f->f_node = &test_node;
 396  398          }
 397  399  
 398  400          for (;;) {
 399  401                  if (prompt) {
 400      -                        fputs(prompt, stdout);
      402 +                        (void) fputs(prompt, stdout);
 401  403                          fflush(stdout);
 402  404                  }
 403  405  
 404  406                  cmd = fgets(cmdbuf, sizeof (cmdbuf), stdin);
 405  407                  if (cmd == NULL)
 406  408                          break;
 407  409                  if (cmd[0] == '#')
 408  410                          continue;
 409  411  
 410  412                  if (prompt == NULL) {
 411  413                          /* Put commands in the output too. */
 412      -                        fputs(cmdbuf, stdout);
      414 +                        (void) fputs(cmdbuf, stdout);
 413  415                  }
 414  416                  cmd = strtok_r(cmd, sep, &savep);
 415  417                  if (cmd == NULL)
 416  418                          continue;
 417  419  
 418  420                  /*
 419  421                   * Commands with no args
 420  422                   */
 421  423                  if (0 == strcmp(cmd, "help")) {
 422      -                        fputs(helpstr, stdout);
      424 +                        (void) fputs(helpstr, stdout);
 423  425                          continue;
 424  426                  }
 425  427  
 426  428                  if (0 == strcmp(cmd, "show")) {
 427  429                          do_show();
 428  430                          continue;
 429  431                  }
 430  432  
 431  433                  /*
 432  434                   * Commands with one arg (the FID)
↓ open down ↓ 209 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX