Print this page
10078 smatch fixes for UCB

Split Close
Expand all
Collapse all
          --- old/usr/src/ucblib/libdbm/dbm.c
          +++ new/usr/src/ucblib/libdbm/dbm.c
↓ open down ↓ 23 lines elided ↑ open up ↑
  24   24   */
  25   25  
  26   26  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   27  /*        All Rights Reserved   */
  28   28  
  29   29  /*
  30   30   * Portions of this source code were derived from Berkeley 4.3 BSD
  31   31   * under license from the Regents of the University of California.
  32   32   */
  33   33  
       34 +/*
       35 + * Copyright (c) 2018, Joyent, Inc.
       36 + */
       37 +
  34   38  /*LINTLIBRARY*/
  35   39  
  36   40  #include        <sys/types.h>
  37   41  #include        <stdio.h>
  38   42  #include        <unistd.h>
  39   43  #include        <stdlib.h>
  40   44  #include        <strings.h>
  41   45  #include        <malloc.h>
  42   46  #include        <sys/stat.h>
  43   47  #include        <sys/fcntl.h>
↓ open down ↓ 473 lines elided ↑ open up ↑
 517  521  
 518  522          sp = (short *)buf;
 519  523          if (n < 0 || n >= sp[0])
 520  524                  goto bad;
 521  525          i1 = sp[n+1];
 522  526          i2 = PBLKSIZ;
 523  527          if (n > 0)
 524  528                  i2 = sp[n+1-1];
 525  529          i3 = sp[sp[0]+1-1];
 526  530          if (i2 > i1)
 527      -        while (i1 > i3) {
 528      -                i1--;
 529      -                i2--;
 530      -                buf[i2] = buf[i1];
 531      -                buf[i1] = 0;
 532      -        }
      531 +                while (i1 > i3) {
      532 +                        i1--;
      533 +                        i2--;
      534 +                        buf[i2] = buf[i1];
      535 +                        buf[i1] = 0;
      536 +                }
 533  537          i2 -= i1;
 534  538          for (i1 = n+1; i1 < sp[0]; i1++)
 535  539                  sp[i1+1-1] = sp[i1+1] + i2;
 536  540          sp[0]--;
 537  541          sp[sp[0]+1] = 0;
 538  542          return;
 539  543  
 540  544  bad:
 541  545          (void) printf("bad delitem\n");
 542  546          abort();
↓ open down ↓ 47 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX