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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libilb/common/ilb_comm.c
          +++ new/usr/src/lib/libilb/common/ilb_comm.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + *
       26 + * Copyright (c) 2018, Joyent, Inc.
  25   27   */
  26   28  
  27   29  #include <stdlib.h>
  28   30  #include <strings.h>
  29   31  #include <unistd.h>
  30   32  #include <stddef.h>
  31   33  #include <assert.h>
  32   34  #include <sys/types.h>
  33   35  #include <sys/socket.h>
  34   36  #include <thread.h>
↓ open down ↓ 18 lines elided ↑ open up ↑
  53   55  {
  54   56          ilb_handle_impl_t       *hi = NULL;
  55   57          int                     s = -1;
  56   58          struct sockaddr_un sa = {AF_UNIX, SOCKET_PATH};
  57   59          ilb_status_t            rc = ILB_STATUS_OK;
  58   60          int                     sobufsz;
  59   61  
  60   62          if (hp == NULL)
  61   63                  return (ILB_STATUS_EINVAL);
  62   64  
  63      -        hi = calloc(sizeof (*hi), 1);
       65 +        hi = calloc(1, sizeof (*hi));
  64   66          if (hi == NULL)
  65   67                  return (ILB_STATUS_ENOMEM);
  66   68  
  67   69          if (cond_init(&hi->h_cv, USYNC_THREAD, NULL) != 0) {
  68   70                  rc = ILB_STATUS_INTERNAL;
  69   71                  goto out;
  70   72          }
  71   73  
  72   74          if (mutex_init(&hi->h_lock, USYNC_THREAD | LOCK_ERRORCHECK, NULL)
  73   75              != 0) {
↓ open down ↓ 162 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX