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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c
          +++ new/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  /* enable debug output and some debug asserts */
  30   28  #undef  _IPQOS_CONF_DEBUG
  31   29  
  32   30  #include <stdlib.h>
  33   31  #include <unistd.h>
  34   32  #include <libintl.h>
  35   33  #include <signal.h>
  36   34  #include <strings.h>
  37   35  #include <sys/nvpair.h>
  38   36  #include <stdio.h>
↓ open down ↓ 576 lines elided ↑ open up ↑
 615  613                              gettext("Failed to create class %s in action "
 616  614                              "%s: %s.\n"), class_name, action_name,
 617  615                              strerror(errno));
 618  616                  }
 619  617  
 620  618                  goto fail;
 621  619          }
 622  620  
 623  621          return (IPQOS_CONF_SUCCESS);
 624  622  fail:
 625      -        if (nvl != NULL)
 626      -                nvlist_free(nvl);
      623 +        nvlist_free(nvl);
 627  624          return (IPQOS_CONF_ERR);
 628  625  }
 629  626  
 630  627  
 631  628  /*
 632  629   * modify the class in the kernel action action_name called class_name with
 633  630   * stats set according to stats_enable and the first action set to
 634  631   * first_action.
 635  632   * RETURNS: IPQOS_CONF_ERR on error, else IPQOS_CONF_SUCCES.
 636  633   */
↓ open down ↓ 67 lines elided ↑ open up ↑
 704  701  
 705  702                  ipqos_msg(MT_ERROR,
 706  703                      gettext("Modifying class %s in action %s failed: %s.\n"),
 707  704                      class_name, action_name, strerror(errno));
 708  705  
 709  706                  goto fail;
 710  707          }
 711  708  
 712  709          return (IPQOS_CONF_SUCCESS);
 713  710  fail:
 714      -        if (nvl != NULL)
 715      -                nvlist_free(nvl);
      711 +        nvlist_free(nvl);
 716  712          return (IPQOS_CONF_ERR);
 717  713  }
 718  714  
 719  715  /*
 720  716   * removes the class class_name from the kernel action action_name. The
 721  717   * flags argument can currently be set to IPP_ACTION_DESTROY which will
 722  718   * result in the action this class references being destroyed.
 723  719   * RETURNS: IPQOS_CONF_ERR on error, else IPQOS_CONF_SUCCES.
 724  720   */
 725  721  static int
↓ open down ↓ 43 lines elided ↑ open up ↑
 769  765  
 770  766                  ipqos_msg(MT_ERROR,
 771  767                      gettext("Removing class %s in action %s failed: %s.\n"),
 772  768                      class_name, action_name, strerror(errno));
 773  769  
 774  770                  goto fail;
 775  771          }
 776  772  
 777  773          return (IPQOS_CONF_SUCCESS);
 778  774  fail:
 779      -        if (nvl != NULL)
 780      -                nvlist_free(nvl);
      775 +        nvlist_free(nvl);
 781  776          return (IPQOS_CONF_ERR);
 782  777  }
 783  778  
 784  779  /*
 785  780   * add the filter flt to the kernel action named action_name.
 786  781   * RETURNS: IPQOS_CONF_ERR on error, else IPQOS_CONF_SUCCES.
 787  782   */
 788  783  static int
 789  784  add_filter(
 790  785  char *action_name,
↓ open down ↓ 5547 lines elided ↑ open up ↑
6338 6333  /* frees up all memory occupied by a filter struct and its contents. */
6339 6334  static void
6340 6335  free_class(ipqos_conf_class_t *cls)
6341 6336  {
6342 6337  
6343 6338          if (cls == NULL)
6344 6339                  return;
6345 6340  
6346 6341          /* free its nvlist if present */
6347 6342  
6348      -        if (cls->nvlist)
6349      -                nvlist_free(cls->nvlist);
     6343 +        nvlist_free(cls->nvlist);
6350 6344  
6351 6345          /* free its action refs if present */
6352 6346  
6353 6347          if (cls->alist)
6354 6348                  free_arefs(cls->alist);
6355 6349  
6356 6350          /* finally free class itself */
6357 6351          free(cls);
6358 6352  }
6359 6353  
↓ open down ↓ 423 lines elided ↑ open up ↑
6783 6777   */
6784 6778  static void
6785 6779  free_arefs(
6786 6780  ipqos_conf_act_ref_t *arefs)
6787 6781  {
6788 6782  
6789 6783          ipqos_conf_act_ref_t *aref = arefs;
6790 6784          ipqos_conf_act_ref_t *next;
6791 6785  
6792 6786          while (aref) {
6793      -                if (aref->nvlist)
6794      -                        nvlist_free(aref->nvlist);
     6787 +                nvlist_free(aref->nvlist);
6795 6788                  next = aref->next;
6796 6789                  free(aref);
6797 6790                  aref = next;
6798 6791          }
6799 6792  }
6800 6793  
6801 6794  
6802 6795  
6803 6796  /* *************************************************************** */
6804 6797  
↓ open down ↓ 3237 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX