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>
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 /*




  17  * od - octal dump.  Not really just octal anymore; read the POSIX
  18  * specification for it -- its more complex than you think!
  19  *
  20  * NB: We followed the POSIX semantics fairly strictly, where the
  21  * legacy code's behavior was in conflict.  In many cases the legacy
  22  * Solaris code was so completely broken as to be completely unusable.
  23  * (For example, the long double support was broken beyond
  24  * imagination!)  Note that GNU coreutils violates POSIX in a few
  25  * interesting ways, such as changing the numbering of the addresses
  26  * when skipping.  (Address starts should always be at 0, according to
  27  * the sample output in the Open Group man page.)
  28  */
  29 
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <sys/types.h>
  33 #include <string.h>
  34 #include <err.h>
  35 #include <wchar.h>
  36 #include <locale.h>


 516                         if (strchr(STR1, *typestr)) {
 517                                 typestr++;
 518                                 add_out(&output_hex_b);
 519                         } else if (strchr(STR2, *typestr)) {
 520                                 typestr++;
 521                                 add_out(&output_hex_w);
 522                         } else if (strchr(STR4, *typestr)) {
 523                                 typestr++;
 524                                 add_out(&output_hex_d);
 525                         } else if (strchr(STR8, *typestr)) {
 526                                 typestr++;
 527                                 add_out(&output_hex_q);
 528                         } else {
 529                                 add_out(&output_hex_d);
 530                         }
 531                         break;
 532 
 533                 default:
 534                         errx(1, _("unrecognized type string character: %c"),
 535                             *typestr);
 536                         exit(1);
 537                 }
 538         }
 539 }
 540 
 541 int
 542 main(int argc, char **argv)
 543 {
 544         int             c;
 545         int             i;
 546         buffer_t        buffer;
 547         boolean_t       first = B_TRUE;
 548         boolean_t       doall = B_FALSE;
 549         boolean_t       same = B_FALSE;
 550         boolean_t       newarg = B_FALSE;
 551         off_t           offset = 0;
 552         off_t           skip = 0;
 553         char            *eptr;
 554         char            *offstr = 0;
 555 
 556         input = stdin;


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  14  */
  15 
  16 /*
  17  * Copyright 2019 Joyent, Inc.
  18  */
  19 
  20 /*
  21  * od - octal dump.  Not really just octal anymore; read the POSIX
  22  * specification for it -- its more complex than you think!
  23  *
  24  * NB: We followed the POSIX semantics fairly strictly, where the
  25  * legacy code's behavior was in conflict.  In many cases the legacy
  26  * Solaris code was so completely broken as to be completely unusable.
  27  * (For example, the long double support was broken beyond
  28  * imagination!)  Note that GNU coreutils violates POSIX in a few
  29  * interesting ways, such as changing the numbering of the addresses
  30  * when skipping.  (Address starts should always be at 0, according to
  31  * the sample output in the Open Group man page.)
  32  */
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <sys/types.h>
  37 #include <string.h>
  38 #include <err.h>
  39 #include <wchar.h>
  40 #include <locale.h>


 520                         if (strchr(STR1, *typestr)) {
 521                                 typestr++;
 522                                 add_out(&output_hex_b);
 523                         } else if (strchr(STR2, *typestr)) {
 524                                 typestr++;
 525                                 add_out(&output_hex_w);
 526                         } else if (strchr(STR4, *typestr)) {
 527                                 typestr++;
 528                                 add_out(&output_hex_d);
 529                         } else if (strchr(STR8, *typestr)) {
 530                                 typestr++;
 531                                 add_out(&output_hex_q);
 532                         } else {
 533                                 add_out(&output_hex_d);
 534                         }
 535                         break;
 536 
 537                 default:
 538                         errx(1, _("unrecognized type string character: %c"),
 539                             *typestr);

 540                 }
 541         }
 542 }
 543 
 544 int
 545 main(int argc, char **argv)
 546 {
 547         int             c;
 548         int             i;
 549         buffer_t        buffer;
 550         boolean_t       first = B_TRUE;
 551         boolean_t       doall = B_FALSE;
 552         boolean_t       same = B_FALSE;
 553         boolean_t       newarg = B_FALSE;
 554         off_t           offset = 0;
 555         off_t           skip = 0;
 556         char            *eptr;
 557         char            *offstr = 0;
 558 
 559         input = stdin;