Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Portions of this source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 
  34 /*
  35  * Copyright (c) 2018, Joyent, Inc.
  36  */
  37 
  38 /*LINTLIBRARY*/
  39 
  40 #include        <sys/types.h>
  41 #include        <stdio.h>
  42 #include        <unistd.h>
  43 #include        <stdlib.h>
  44 #include        <strings.h>
  45 #include        <malloc.h>
  46 #include        <sys/stat.h>
  47 #include        <sys/fcntl.h>
  48 #include        <dbm.h>
  49 #include        <errno.h>
  50 
  51 /* forward declarations */
  52 /* could be all static if not were for older *.a releases */
  53 void chkblk(char buf[PBLKSIZ]);
  54 void delitem(char buf[PBLKSIZ], int n);
  55 void dbm_access(long hash);


 425         item.dsize = 0;
 426         return (item);
 427 }
 428 
 429 int
 430 cmpdatum(datum d1, datum d2)
 431 {
 432         int n;
 433         char *p1, *p2;
 434 
 435         n = d1.dsize;
 436         if (n != d2.dsize)
 437                 return (n - d2.dsize);
 438         if (n == 0)
 439                 return (0);
 440         p1 = d1.dptr;
 441         p2 = d2.dptr;
 442         do
 443                 if (*p1++ != *p2++)
 444                         return (*--p1 - *--p2);
 445         while (--n);

 446         return (0);
 447 }
 448 
 449 int     hitab[16]
 450 /*
 451  * ken's
 452  * {
 453  *      055,043,036,054,063,014,004,005,
 454  *      010,064,077,000,035,027,025,071,
 455  * };
 456  */
 457         = {     61, 57, 53, 49, 45, 41, 37, 33,
 458                 29, 25, 21, 17, 13,  9,  5,  1,
 459         };
 460 long    hltab[64] = {
 461         06100151277L, 06106161736L, 06452611562L, 05001724107L,
 462         02614772546L, 04120731531L, 04665262210L, 07347467531L,
 463         06735253126L, 06042345173L, 03072226605L, 01464164730L,
 464         03247435524L, 07652510057L, 01546775256L, 05714532133L,
 465         06173260402L, 07517101630L, 02431460343L, 01743245566L,


 572 void
 573 chkblk(char buf[PBLKSIZ])
 574 {
 575         short *sp;
 576         int t, i;
 577 
 578         sp = (short *)buf;
 579         t = PBLKSIZ;
 580         for (i = 0; i < sp[0]; i++) {
 581                 if (sp[i+1] > t)
 582                         goto bad;
 583                 t = sp[i+1];
 584         }
 585         if (t < (sp[0]+1)*sizeof (short))
 586                 goto bad;
 587         return;
 588 
 589 bad:
 590         (void) printf("bad block\n");
 591         abort();
 592         bzero(buf, PBLKSIZ);
 593 }


  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Portions of this source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 
  34 /*
  35  * Copyright 2019 Joyent, Inc.
  36  */
  37 
  38 /*LINTLIBRARY*/
  39 
  40 #include        <sys/types.h>
  41 #include        <stdio.h>
  42 #include        <unistd.h>
  43 #include        <stdlib.h>
  44 #include        <strings.h>
  45 #include        <malloc.h>
  46 #include        <sys/stat.h>
  47 #include        <sys/fcntl.h>
  48 #include        <dbm.h>
  49 #include        <errno.h>
  50 
  51 /* forward declarations */
  52 /* could be all static if not were for older *.a releases */
  53 void chkblk(char buf[PBLKSIZ]);
  54 void delitem(char buf[PBLKSIZ], int n);
  55 void dbm_access(long hash);


 425         item.dsize = 0;
 426         return (item);
 427 }
 428 
 429 int
 430 cmpdatum(datum d1, datum d2)
 431 {
 432         int n;
 433         char *p1, *p2;
 434 
 435         n = d1.dsize;
 436         if (n != d2.dsize)
 437                 return (n - d2.dsize);
 438         if (n == 0)
 439                 return (0);
 440         p1 = d1.dptr;
 441         p2 = d2.dptr;
 442         do
 443                 if (*p1++ != *p2++)
 444                         return (*--p1 - *--p2);
 445         while (--n)
 446                 ;
 447         return (0);
 448 }
 449 
 450 int     hitab[16]
 451 /*
 452  * ken's
 453  * {
 454  *      055,043,036,054,063,014,004,005,
 455  *      010,064,077,000,035,027,025,071,
 456  * };
 457  */
 458         = {     61, 57, 53, 49, 45, 41, 37, 33,
 459                 29, 25, 21, 17, 13,  9,  5,  1,
 460         };
 461 long    hltab[64] = {
 462         06100151277L, 06106161736L, 06452611562L, 05001724107L,
 463         02614772546L, 04120731531L, 04665262210L, 07347467531L,
 464         06735253126L, 06042345173L, 03072226605L, 01464164730L,
 465         03247435524L, 07652510057L, 01546775256L, 05714532133L,
 466         06173260402L, 07517101630L, 02431460343L, 01743245566L,


 573 void
 574 chkblk(char buf[PBLKSIZ])
 575 {
 576         short *sp;
 577         int t, i;
 578 
 579         sp = (short *)buf;
 580         t = PBLKSIZ;
 581         for (i = 0; i < sp[0]; i++) {
 582                 if (sp[i+1] > t)
 583                         goto bad;
 584                 t = sp[i+1];
 585         }
 586         if (t < (sp[0]+1)*sizeof (short))
 587                 goto bad;
 588         return;
 589 
 590 bad:
 591         (void) printf("bad block\n");
 592         abort();

 593 }