Print this page
patch cleanup
6659 nvlist_free(NULL) is a no-op


   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 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 /*
  30  * Disk & Indicator Monitor configuration file support routines
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <fcntl.h>
  36 #include <unistd.h>
  37 #include <string.h>
  38 #include <strings.h>
  39 #include <errno.h>
  40 #include <limits.h>
  41 #include <pthread.h>
  42 
  43 #include "disk_monitor.h"
  44 #include "util.h"
  45 #include "topo_gather.h"
  46 
  47 extern log_class_t g_verbose;
  48 


 358 
 359         dmp->configured_yet = B_FALSE;
 360         dmp->state_change_count = 0;
 361 
 362         dm_assert(pthread_mutex_init(&dmp->fru_mutex, NULL) == 0);
 363         dmp->frup = NULL;
 364 
 365         dmp->next = NULL;
 366         return (dmp);
 367 }
 368 
 369 void
 370 diskmon_free(diskmon_t *dmp)
 371 {
 372         diskmon_t *nextp;
 373 
 374         /* Free the whole list */
 375         while (dmp != NULL) {
 376                 nextp = dmp->next;
 377 
 378                 if (dmp->props)
 379                         nvlist_free(dmp->props);
 380                 if (dmp->location)
 381                         dstrfree(dmp->location);
 382                 if (dmp->ind_list)
 383                         ind_free(dmp->ind_list);
 384                 if (dmp->indrule_list)
 385                         indrule_free(dmp->indrule_list);
 386                 if (dmp->app_props)
 387                         nvlist_free(dmp->app_props);
 388                 if (dmp->frup)
 389                         dmfru_free(dmp->frup);
 390                 dfree(dmp, sizeof (diskmon_t));
 391 
 392                 dmp = nextp;
 393         }
 394 }
 395 
 396 static cfgdata_t *
 397 new_cfgdata(namevalpr_t *nvp, diskmon_t *dmp)
 398 {
 399         cfgdata_t *cdp = (cfgdata_t *)dzmalloc(sizeof (cfgdata_t));
 400 
 401         if (nvp != NULL)
 402                 cdp->props = namevalpr_to_nvlist(nvp);
 403         else if (nvlist_alloc(&cdp->props, NV_UNIQUE_NAME, 0) != 0) {
 404                 return (NULL);
 405         }
 406 




   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 /*
  23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 


  27 /*
  28  * Disk & Indicator Monitor configuration file support routines
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/stat.h>
  33 #include <fcntl.h>
  34 #include <unistd.h>
  35 #include <string.h>
  36 #include <strings.h>
  37 #include <errno.h>
  38 #include <limits.h>
  39 #include <pthread.h>
  40 
  41 #include "disk_monitor.h"
  42 #include "util.h"
  43 #include "topo_gather.h"
  44 
  45 extern log_class_t g_verbose;
  46 


 356 
 357         dmp->configured_yet = B_FALSE;
 358         dmp->state_change_count = 0;
 359 
 360         dm_assert(pthread_mutex_init(&dmp->fru_mutex, NULL) == 0);
 361         dmp->frup = NULL;
 362 
 363         dmp->next = NULL;
 364         return (dmp);
 365 }
 366 
 367 void
 368 diskmon_free(diskmon_t *dmp)
 369 {
 370         diskmon_t *nextp;
 371 
 372         /* Free the whole list */
 373         while (dmp != NULL) {
 374                 nextp = dmp->next;
 375 

 376                 nvlist_free(dmp->props);
 377                 if (dmp->location)
 378                         dstrfree(dmp->location);
 379                 if (dmp->ind_list)
 380                         ind_free(dmp->ind_list);
 381                 if (dmp->indrule_list)
 382                         indrule_free(dmp->indrule_list);

 383                 nvlist_free(dmp->app_props);
 384                 if (dmp->frup)
 385                         dmfru_free(dmp->frup);
 386                 dfree(dmp, sizeof (diskmon_t));
 387 
 388                 dmp = nextp;
 389         }
 390 }
 391 
 392 static cfgdata_t *
 393 new_cfgdata(namevalpr_t *nvp, diskmon_t *dmp)
 394 {
 395         cfgdata_t *cdp = (cfgdata_t *)dzmalloc(sizeof (cfgdata_t));
 396 
 397         if (nvp != NULL)
 398                 cdp->props = namevalpr_to_nvlist(nvp);
 399         else if (nvlist_alloc(&cdp->props, NV_UNIQUE_NAME, 0) != 0) {
 400                 return (NULL);
 401         }
 402