Print this page
10076 make usr/src/test smatch clean

Split Close
Expand all
Collapse all
          --- old/usr/src/test/smbclient-tests/cmd/mkfile_mmap/mkfile_mmap.c
          +++ new/usr/src/test/smbclient-tests/cmd/mkfile_mmap/mkfile_mmap.c
↓ open down ↓ 4 lines elided ↑ open up ↑
   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 2012 Jilin Xpd <jilinxpd@gmail.com>
  14   14   * Copyright 2018 Nexenta Systems, Inc.
       15 + * Copyright (c) 2018, Joyent, Inc.
  15   16   */
  16   17  
  17   18  /*
  18   19   * Using mmap, make a file and padding it with random chars.
  19   20   */
  20   21  
  21   22  #include <sys/mman.h>
  22   23  #include <sys/types.h>
  23   24  #include <sys/stat.h>
  24   25  #include <fcntl.h>
↓ open down ↓ 107 lines elided ↑ open up ↑
 132  133  
 133  134                  /* map file */
 134  135                  file_addr = mmap(NULL, blksize,
 135  136                      PROT_READ | PROT_WRITE, MAP_SHARED, fid, offset);
 136  137                  if (file_addr == MAP_FAILED) {
 137  138                          fprintf(stderr, "mmap %s error=%d\n", filename, errno);
 138  139                          mret = 1;
 139  140                          break;
 140  141                  }
 141  142  
 142      -        /* tag each block (to aid debug) */
 143      -        p = file_addr;
 144      -        q = file_addr + blksize - K;
 145      -        memset(p, ' ', K);
 146      -        snprintf(p, K, "\nblk=%d\n\n", i);
 147      -        p += K;
 148      -
 149      -                /* fill something into mapped addr */
 150      -        while (p < q) {
      143 +                /* tag each block (to aid debug) */
      144 +                p = file_addr;
      145 +                q = file_addr + blksize - K;
 151  146                  memset(p, ' ', K);
 152      -                snprintf(p, K, "\noff=0x%x\n\n",
 153      -                    (i * blksize) + (p - file_addr));
      147 +                snprintf(p, K, "\nblk=%d\n\n", i);
 154  148                  p += K;
 155      -        }
 156  149  
      150 +                /* fill something into mapped addr */
      151 +                while (p < q) {
      152 +                        memset(p, ' ', K);
      153 +                        snprintf(p, K, "\noff=0x%x\n\n",
      154 +                            (i * blksize) + (p - file_addr));
      155 +                        p += K;
      156 +                }
      157 +
 157  158                  /* sync mapped pages to file */
 158  159                  if (msync(file_addr, blksize, MS_SYNC) == -1) {
 159  160                          fprintf(stderr, "msync %s error=%d\n", filename, errno);
 160  161                          mret = 1;
 161  162                  }
 162  163  
 163  164                  /* unmap file */
 164  165                  if (munmap(file_addr, blksize) == -1) {
 165  166                          fprintf(stderr, "unmap %s error=%d\n", filename, errno);
 166  167                          mret = 1;
 167  168                  }
 168  169          }
 169  170  
 170  171          /* close file */
 171  172  exit2:
 172  173          close(fid);
 173  174  exit3:
 174  175          return (mret);
 175  176  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX