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


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #pragma ident   "%Z%%M% %I%     %E% SMI"


  27 
  28 
  29 #include        <stdlib.h>
  30 #include        <stdio.h>
  31 #include        <string.h>
  32 #include        <proc_service.h>
  33 #include        <link.h>
  34 #include        <rtld_db.h>
  35 #include        <rtld.h>
  36 #include        <_rtld_db.h>
  37 #include        <msg.h>
  38 #include        <sys/param.h>
  39 
  40 /*
  41  * Mutex to protect global data
  42  */
  43 mutex_t glob_mutex = DEFAULTMUTEX;
  44 int     rtld_db_version = RD_VERSION1;
  45 int     rtld_db_logging = 0;
  46 char    rtld_db_helper_path[MAXPATHLEN];
  47 
  48 


 145                 return (RD_DBERR);
 146         }
 147 
 148         if (rap->rd_dmodel == PR_MODEL_LP64)
 149                 err = _rd_reset64(rap);
 150         else
 151 #endif
 152                 err = _rd_reset32(rap);
 153 
 154         RDAGUNLOCK(rap);
 155         return (err);
 156 }
 157 
 158 
 159 rd_agent_t *
 160 rd_new(struct ps_prochandle *php)
 161 {
 162         rd_agent_t      *rap;
 163 
 164         LOG(ps_plog(MSG_ORIG(MSG_DB_RDNEW), php));
 165         if ((rap = (rd_agent_t *)calloc(sizeof (rd_agent_t), 1)) == NULL)
 166                 return (0);
 167 
 168         rap->rd_psp = php;
 169         (void) mutex_init(&rap->rd_mutex, USYNC_THREAD, 0);
 170         if (rd_reset(rap) != RD_OK) {
 171                 if (rap->rd_helper.rh_dlhandle != NULL) {
 172                         rap->rd_helper.rh_ops->rho_fini(rap->rd_helper.rh_data);
 173                         (void) dlclose(rap->rd_helper.rh_dlhandle);
 174                 }
 175                 free(rap);
 176                 LOG(ps_plog(MSG_ORIG(MSG_DB_RESETFAIL)));
 177                 return ((rd_agent_t *)0);
 178         }
 179 
 180         return (rap);
 181 }
 182 
 183 
 184 void
 185 rd_delete(rd_agent_t *rap)




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 

  30 #include        <stdlib.h>
  31 #include        <stdio.h>
  32 #include        <string.h>
  33 #include        <proc_service.h>
  34 #include        <link.h>
  35 #include        <rtld_db.h>
  36 #include        <rtld.h>
  37 #include        <_rtld_db.h>
  38 #include        <msg.h>
  39 #include        <sys/param.h>
  40 
  41 /*
  42  * Mutex to protect global data
  43  */
  44 mutex_t glob_mutex = DEFAULTMUTEX;
  45 int     rtld_db_version = RD_VERSION1;
  46 int     rtld_db_logging = 0;
  47 char    rtld_db_helper_path[MAXPATHLEN];
  48 
  49 


 146                 return (RD_DBERR);
 147         }
 148 
 149         if (rap->rd_dmodel == PR_MODEL_LP64)
 150                 err = _rd_reset64(rap);
 151         else
 152 #endif
 153                 err = _rd_reset32(rap);
 154 
 155         RDAGUNLOCK(rap);
 156         return (err);
 157 }
 158 
 159 
 160 rd_agent_t *
 161 rd_new(struct ps_prochandle *php)
 162 {
 163         rd_agent_t      *rap;
 164 
 165         LOG(ps_plog(MSG_ORIG(MSG_DB_RDNEW), php));
 166         if ((rap = (rd_agent_t *)calloc(1, sizeof (rd_agent_t))) == NULL)
 167                 return (0);
 168 
 169         rap->rd_psp = php;
 170         (void) mutex_init(&rap->rd_mutex, USYNC_THREAD, 0);
 171         if (rd_reset(rap) != RD_OK) {
 172                 if (rap->rd_helper.rh_dlhandle != NULL) {
 173                         rap->rd_helper.rh_ops->rho_fini(rap->rd_helper.rh_data);
 174                         (void) dlclose(rap->rd_helper.rh_dlhandle);
 175                 }
 176                 free(rap);
 177                 LOG(ps_plog(MSG_ORIG(MSG_DB_RESETFAIL)));
 178                 return ((rd_agent_t *)0);
 179         }
 180 
 181         return (rap);
 182 }
 183 
 184 
 185 void
 186 rd_delete(rd_agent_t *rap)