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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libipmi/common/libipmi.c
          +++ new/usr/src/lib/libipmi/common/libipmi.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  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   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright (c) 2018, Joyent, Inc.
  24   26   */
  25   27  
  26   28  #include <libipmi.h>
  27   29  #include <string.h>
  28   30  
  29   31  #include "ipmi_impl.h"
  30   32  
  31   33  ipmi_handle_t *
  32   34  ipmi_open(int *errp, char **msg, uint_t xport_type, nvlist_t *params)
  33   35  {
  34   36          ipmi_handle_t *ihp;
  35   37          static char errmsg[48];
  36   38  
  37   39          if (msg)
  38   40                  *msg = NULL;
  39   41  
  40      -        if ((ihp = calloc(sizeof (ipmi_handle_t), 1)) == NULL) {
       42 +        if ((ihp = calloc(1, sizeof (ipmi_handle_t))) == NULL) {
  41   43                  *errp = EIPMI_NOMEM;
  42   44                  if (msg)
  43   45                          *msg = "memory allocation failure";
  44   46                  return (NULL);
  45   47          }
  46   48  
  47   49          switch (xport_type) {
  48   50          case IPMI_TRANSPORT_BMC:
  49   51                  ihp->ih_transport = &ipmi_transport_bmc;
  50   52                  break;
↓ open down ↓ 101 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX