Skip to content

Commit

Permalink
6659 nvlist_free(NULL) is a no-op
Browse files Browse the repository at this point in the history
Reviewed by: Toomas Soome <[email protected]>
Reviewed by: Marcel Telka <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
  • Loading branch information
jeffpc authored and rmustacc committed Feb 27, 2016
1 parent d643a85 commit aab83bb
Show file tree
Hide file tree
Showing 113 changed files with 241 additions and 513 deletions.
3 changes: 1 addition & 2 deletions usr/src/cmd/beadm/beadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,7 @@ be_do_create(int argc, char **argv)
out:
nvlist_free(be_attrs);
out2:
if (zfs_props != NULL)
nvlist_free(zfs_props);
nvlist_free(zfs_props);

return (err);
}
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/boot/bootadm/bootadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,10 +3032,8 @@ savenew(char *root)
static void
clear_walk_args(void)
{
if (walk_arg.old_nvlp)
nvlist_free(walk_arg.old_nvlp);
if (walk_arg.new_nvlp)
nvlist_free(walk_arg.new_nvlp);
nvlist_free(walk_arg.old_nvlp);
nvlist_free(walk_arg.new_nvlp);
if (walk_arg.sparcfile)
(void) fclose(walk_arg.sparcfile);
walk_arg.old_nvlp = NULL;
Expand Down
3 changes: 1 addition & 2 deletions usr/src/cmd/cmd-inet/sbin/dhcpagent/defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ df_get_string(const char *if_name, boolean_t isv6, uint_t param)
if (statbuf.st_mtime != df_statbuf.st_mtime ||
statbuf.st_size != df_statbuf.st_size) {
df_statbuf = statbuf;
if (df_nvlist != NULL)
nvlist_free(df_nvlist);
nvlist_free(df_nvlist);
df_nvlist = df_build_cache();
}

Expand Down
3 changes: 1 addition & 2 deletions usr/src/cmd/cmd-inet/usr.lib/vrrpd/vrrpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4472,8 +4472,7 @@ vrrpd_post_event(const char *name, vrrp_state_t prev_st, vrrp_state_t st)
"sysevent posting failed: %s", vrrp_state2str(prev_st),
vrrp_state2str(st), strerror(errno));

if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
return (-1);
}

Expand Down
17 changes: 5 additions & 12 deletions usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/ipqosconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

/* enable debug output and some debug asserts */
#undef _IPQOS_CONF_DEBUG

Expand Down Expand Up @@ -622,8 +620,7 @@ char *first_action)

return (IPQOS_CONF_SUCCESS);
fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
return (IPQOS_CONF_ERR);
}

Expand Down Expand Up @@ -711,8 +708,7 @@ enum ipp_flags flags)

return (IPQOS_CONF_SUCCESS);
fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
return (IPQOS_CONF_ERR);
}

Expand Down Expand Up @@ -776,8 +772,7 @@ enum ipp_flags flags)

return (IPQOS_CONF_SUCCESS);
fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
return (IPQOS_CONF_ERR);
}

Expand Down Expand Up @@ -6345,8 +6340,7 @@ free_class(ipqos_conf_class_t *cls)

/* free its nvlist if present */

if (cls->nvlist)
nvlist_free(cls->nvlist);
nvlist_free(cls->nvlist);

/* free its action refs if present */

Expand Down Expand Up @@ -6790,8 +6784,7 @@ ipqos_conf_act_ref_t *arefs)
ipqos_conf_act_ref_t *next;

while (aref) {
if (aref->nvlist)
nvlist_free(aref->nvlist);
nvlist_free(aref->nvlist);
next = aref->next;
free(aref);
aref = next;
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/dcs/sparc/sun4u/ri_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,7 @@ cpu_cap_request(ri_hdl_t *ri_hdl, rcmd_t *rcm)
out:
s_free(syscpuids);
s_free(newcpuids);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
if (rcm_info != NULL)
rcm_free_info(rcm_info);

Expand Down Expand Up @@ -1771,8 +1770,7 @@ ri_ap_alloc(char *ap_id, ri_hdl_t *hdl)

if (nvlist_alloc(&ap->conf_props, NV_UNIQUE_NAME, 0) != 0 ||
nvlist_add_string(ap->conf_props, RI_AP_REQ_ID, ap_id) != 0) {
if (ap->conf_props != NULL)
nvlist_free(ap->conf_props);
nvlist_free(ap->conf_props);
free(ap);
return (NULL);
}
Expand Down
44 changes: 14 additions & 30 deletions usr/src/cmd/dcs/sparc/sun4u/rsrc_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

/*
* Routines for traversing and packing/unpacking the handle
* returned from ri_init.
Expand Down Expand Up @@ -82,8 +80,7 @@ ri_ap_free(ri_ap_t *ap)

assert(ap != NULL);

if (ap->conf_props != NULL)
nvlist_free(ap->conf_props);
nvlist_free(ap->conf_props);

while ((dev = ap->cpus) != NULL) {
ap->cpus = dev->next;
Expand Down Expand Up @@ -120,10 +117,8 @@ ri_client_free(ri_client_t *client)
{
assert(client != NULL);

if (client->usg_props != NULL)
nvlist_free(client->usg_props);
if (client->v_props != NULL)
nvlist_free(client->v_props);
nvlist_free(client->usg_props);
nvlist_free(client->v_props);
free(client);
}

Expand Down Expand Up @@ -196,8 +191,7 @@ ri_pack(ri_hdl_t *hdl, caddr_t *bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (RI_FAILURE);
}
Expand Down Expand Up @@ -250,8 +244,7 @@ ap_list_pack(ri_ap_t *aplist, char **bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -304,8 +297,7 @@ dev_list_pack(ri_dev_t *devlist, char **bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -359,8 +351,7 @@ client_list_pack(ri_client_t *client_list, char **bufp, size_t *sizep,

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -424,8 +415,7 @@ ap_pack(ri_ap_t *ap, char **bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -470,8 +460,7 @@ dev_pack(ri_dev_t *dev, char **bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -515,8 +504,7 @@ client_pack(ri_client_t *client, char **bufp, size_t *sizep, int encoding)

fail:
s_free(buf);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -617,8 +605,7 @@ ri_unpack(caddr_t buf, size_t size, ri_hdl_t **hdlp)

fail:
free(ri_hdl);
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);

return (-1);
}
Expand Down Expand Up @@ -671,8 +658,7 @@ ap_list_unpack(char *buf, size_t size, ri_ap_t **aps)
return (0);

fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
if (aplist != NULL) {
while ((tmp = aplist) != NULL) {
aplist = aplist->next;
Expand Down Expand Up @@ -729,8 +715,7 @@ dev_list_unpack(char *buf, size_t size, ri_dev_t **devs)
return (0);

fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
if (devlist != NULL) {
while ((tmp = devlist) != NULL) {
devlist = devlist->next;
Expand Down Expand Up @@ -789,8 +774,7 @@ client_list_unpack(char *buf, size_t size, ri_client_t **clients)
return (0);

fail:
if (nvl != NULL)
nvlist_free(nvl);
nvlist_free(nvl);
if (client_list != NULL) {
while ((tmp = client_list) != NULL) {
client_list = client_list->next;
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/devfsadm/devfsadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -8290,8 +8290,7 @@ build_event_attributes(char *class, char *subclass, char *node_path,
return (nvl);

out:
if (nvl)
nvlist_free(nvl);
nvlist_free(nvl);

if (dev_name)
free(dev_name);
Expand Down Expand Up @@ -8364,8 +8363,7 @@ process_syseventq()
free(tmp->class);
if (tmp->subclass != NULL)
free(tmp->subclass);
if (tmp->nvl != NULL)
nvlist_free(tmp->nvl);
nvlist_free(tmp->nvl);
syseventq_back = syseventq_back->next;
if (syseventq_back == NULL)
syseventq_front = NULL;
Expand Down
6 changes: 2 additions & 4 deletions usr/src/cmd/fm/fmd/common/fmd_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,7 @@ fmd_case_destroy_suspects(fmd_case_impl_t *cip)
if (cip->ci_proxy_asru)
fmd_free(cip->ci_proxy_asru, sizeof (uint8_t) *
cip->ci_nsuspects);
if (cip->ci_diag_de)
nvlist_free(cip->ci_diag_de);
nvlist_free(cip->ci_diag_de);
if (cip->ci_diag_asru)
fmd_free(cip->ci_diag_asru, sizeof (uint8_t) *
cip->ci_nsuspects);
Expand Down Expand Up @@ -2431,8 +2430,7 @@ fmd_case_set_de_fmri(fmd_case_t *cp, nvlist_t *nvl)
{
fmd_case_impl_t *cip = (fmd_case_impl_t *)cp;

if (cip->ci_diag_de)
nvlist_free(cip->ci_diag_de);
nvlist_free(cip->ci_diag_de);
cip->ci_diag_de = nvl;
}

Expand Down
5 changes: 1 addition & 4 deletions usr/src/cmd/fm/fmd/common/fmd_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#include <sys/fm/protocol.h>
#include <limits.h>

Expand Down Expand Up @@ -222,8 +220,7 @@ fmd_event_destroy(fmd_event_t *e)
break;
}

if (ep->ev_nvl != NULL)
nvlist_free(ep->ev_nvl);
nvlist_free(ep->ev_nvl);

fmd_free(ep, sizeof (fmd_event_impl_t));
}
Expand Down
15 changes: 5 additions & 10 deletions usr/src/cmd/fm/fmd/common/fmd_xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,9 @@ fmd_xprt_list_suspect_local(fmd_xprt_t *xp, nvlist_t *nvl)
if (loc)
topo_hdl_strfree(thp, loc);
}
if (fru)
nvlist_free(fru);
if (asru)
nvlist_free(asru);
if (rsrc)
nvlist_free(rsrc);
nvlist_free(fru);
nvlist_free(asru);
nvlist_free(rsrc);
fmd_fmri_topo_rele(thp);
fmd_case_insert_suspect(cp, flt_copy);
}
Expand Down Expand Up @@ -1327,8 +1324,7 @@ fmd_xprt_list_suspect(fmd_xprt_t *xp, nvlist_t *nvl)
(xip->xi_flags & FMD_XPRT_HC_PRESENT_ONLY)) {
if (nelem > 0) {
for (i = 0; i < nelem; i++)
if (asrua[i])
nvlist_free(asrua[i]);
nvlist_free(asrua[i]);
fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
fmd_free(diag_asru, sizeof (uint8_t) * nelem);
fmd_free(asrua, sizeof (nvlist_t *) * nelem);
Expand All @@ -1344,8 +1340,7 @@ fmd_xprt_list_suspect(fmd_xprt_t *xp, nvlist_t *nvl)
FMD_CASE_UNSOLVED, uuid, code)) == NULL) {
if (nelem > 0) {
for (i = 0; i < nelem; i++)
if (asrua[i])
nvlist_free(asrua[i]);
nvlist_free(asrua[i]);
fmd_free(proxy_asru, sizeof (uint8_t) * nelem);
fmd_free(diag_asru, sizeof (uint8_t) * nelem);
fmd_free(asrua, sizeof (nvlist_t *) * nelem);
Expand Down
5 changes: 1 addition & 4 deletions usr/src/cmd/fm/fminject/common/inj_defn.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

/*
* After having been declared, events, FMRIs and authorities must be defined
* (instantiated) before they can be used as the subjects of commands.
Expand Down Expand Up @@ -104,8 +102,7 @@ inj_defn_destroy(inj_defn_t *defn)
if (defn->defn_name != NULL)
inj_strfree(defn->defn_name);

if (defn->defn_nvl != NULL)
nvlist_free(defn->defn_nvl);
nvlist_free(defn->defn_nvl);

inj_defn_destroy_memlist(inj_list_next(&defn->defn_members));
}
Expand Down
3 changes: 1 addition & 2 deletions usr/src/cmd/fm/fmtopo/common/fmtopo.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ print_prop_nameval(topo_hdl_t *thp, tnode_t *node, nvlist_t *nvl)
}
uint32_def:
(void) printf(" 0x%x", val);
if (rsrc != NULL)
nvlist_free(rsrc);
nvlist_free(rsrc);
break;
}
case DATA_TYPE_INT64: {
Expand Down
Loading

0 comments on commit aab83bb

Please sign in to comment.