Print this page
11227 smb code needs smatch fixes
   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 at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.

  14  */
  15 
  16 /*
  17  * Test & debug program for smb_msgbuf.c and smb_mbuf_marshaling.c
  18  */
  19 
  20 #include <sys/types.h>
  21 #include <sys/debug.h>
  22 
  23 #include <stdio.h>
  24 #include <stdlib.h>
  25 #include <string.h>
  26 #include <strings.h>
  27 #include <unistd.h>
  28 
  29 #include "test_defs.h"
  30 
  31 
  32 int
  33 main(int argc, char *argv[])


  47         char ascii[24];
  48         char *pa = ascii;
  49 
  50         memset(ascii, '\0', sizeof (ascii));
  51 
  52         idx = 0;
  53         while (len--) {
  54                 if ((idx & 15) == 0) {
  55                         printf("%04X: ", idx);
  56                         pa = ascii;
  57                 }
  58                 if (*buf > ' ' && *buf <= '~')
  59                         *pa++ = *buf;
  60                 else
  61                         *pa++ = '.';
  62                 printf("%02x ", *buf++);
  63 
  64                 idx++;
  65                 if ((idx & 3) == 0) {
  66                         *pa++ = ' ';
  67                         putchar(' ');
  68                 }
  69                 if ((idx & 15) == 0) {
  70                         *pa = '\0';
  71                         printf("%s\n", ascii);
  72                 }
  73         }
  74 
  75         if ((idx & 15) != 0) {
  76                 *pa = '\0';
  77                 /* column align the last ascii row */
  78                 while ((idx & 15) != 0) {
  79                         if ((idx & 3) == 0)
  80                                 putchar(' ');
  81                         printf("   ");
  82                         idx++;
  83                 }
  84                 printf("%s\n", ascii);
  85         }
  86 }
   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 at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  14  * Copyright 2019 Joyent, Inc.
  15  */
  16 
  17 /*
  18  * Test & debug program for smb_msgbuf.c and smb_mbuf_marshaling.c
  19  */
  20 
  21 #include <sys/types.h>
  22 #include <sys/debug.h>
  23 
  24 #include <stdio.h>
  25 #include <stdlib.h>
  26 #include <string.h>
  27 #include <strings.h>
  28 #include <unistd.h>
  29 
  30 #include "test_defs.h"
  31 
  32 
  33 int
  34 main(int argc, char *argv[])


  48         char ascii[24];
  49         char *pa = ascii;
  50 
  51         memset(ascii, '\0', sizeof (ascii));
  52 
  53         idx = 0;
  54         while (len--) {
  55                 if ((idx & 15) == 0) {
  56                         printf("%04X: ", idx);
  57                         pa = ascii;
  58                 }
  59                 if (*buf > ' ' && *buf <= '~')
  60                         *pa++ = *buf;
  61                 else
  62                         *pa++ = '.';
  63                 printf("%02x ", *buf++);
  64 
  65                 idx++;
  66                 if ((idx & 3) == 0) {
  67                         *pa++ = ' ';
  68                         (void) putchar(' ');
  69                 }
  70                 if ((idx & 15) == 0) {
  71                         *pa = '\0';
  72                         printf("%s\n", ascii);
  73                 }
  74         }
  75 
  76         if ((idx & 15) != 0) {
  77                 *pa = '\0';
  78                 /* column align the last ascii row */
  79                 while ((idx & 15) != 0) {
  80                         if ((idx & 3) == 0)
  81                                 (void) putchar(' ');
  82                         printf("   ");
  83                         idx++;
  84                 }
  85                 printf("%s\n", ascii);
  86         }
  87 }