Print this page
10100 Illumos is confused about calloc() arguments

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/checknr/checknr.c
          +++ new/usr/src/cmd/checknr/checknr.c
↓ open down ↓ 5 lines elided ↑ open up ↑
   6    6   * Copyright (c) 1980 Regents of the University of California.
   7    7   * All rights reserved. The Berkeley software License Agreement
   8    8   * specifies the terms and conditions for redistribution.
   9    9   */
  10   10  
  11   11  /*
  12   12   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  13   13   * Use is subject to license terms.
  14   14   */
  15   15  
  16      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       16 +/*
       17 + * Copyright (c) 2018, Joyent, Inc.
       18 + */
  17   19  
  18   20  /*
  19   21   * checknr: check an nroff/troff input file for matching macro calls.
  20   22   * we also attempt to match size and font changes, but only the embedded
  21   23   * kind.  These must end in \s0 and \fP resp.  Maybe more sophistication
  22   24   * later but for now think of these restrictions as contributions to
  23   25   * structured typesetting.
  24   26   */
  25   27  #include <stdio.h>
  26   28  #include <stdlib.h>
↓ open down ↓ 156 lines elided ↑ open up ↑
 183  185          FILE *f;
 184  186          int i;
 185  187          char *cp;
 186  188          char b1[4];
 187  189  
 188  190          (void) setlocale(LC_ALL, "");
 189  191  #if !defined(TEXT_DOMAIN)
 190  192  #define TEXT_DOMAIN     "SYS_TEST"
 191  193  #endif
 192  194          (void) textdomain(TEXT_DOMAIN);
 193      -        stk = (struct stkstr *)calloc(sizeof (struct stkstr), 100);
      195 +        stk = (struct stkstr *)calloc(100, sizeof (struct stkstr));
 194  196          maxstk = 100;
 195  197          /* Figure out how many known commands there are */
 196  198          while (knowncmds[ncmds])
 197  199                  ncmds++;
 198  200          while (argc > 1 && argv[1][0] == '-') {
 199  201                  switch (argv[1][1]) {
 200  202  
 201  203                  /* -a: add pairs of macros */
 202  204                  case 'a':
 203  205                          i = strlen(argv[1]) - 2;
↓ open down ↓ 411 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX