Print this page
patch tsoome-feedback


1019                 nvlist_free(pa[i]);
1020         topo_mod_free(mod, pa, npairs * sizeof (nvlist_t *));
1021         topo_mod_strfree(mod, serial);
1022         topo_mod_strfree(mod, part);
1023         topo_mod_strfree(mod, rev);
1024         nvlist_free(auth);
1025 
1026         if (make_facility(mod, str, &fac) == -1)
1027                 goto hcfmbail;
1028 
1029         if (fac != NULL) {
1030                 if (nvlist_add_nvlist(nf, FM_FMRI_FACILITY, fac) != 0)
1031                         goto hcfmbail;
1032         }
1033 
1034         *out = nf;
1035 
1036         return (0);
1037 
1038 hcfmbail:
1039         if (nf != NULL)
1040                 nvlist_free(nf);
1041         for (i = 0; i < npairs; i++)
1042                 nvlist_free(pa[i]);
1043         topo_mod_free(mod, pa, npairs * sizeof (nvlist_t *));
1044 
1045         topo_mod_strfree(mod, serial);
1046         topo_mod_strfree(mod, part);
1047         topo_mod_strfree(mod, rev);
1048         nvlist_free(auth);
1049         nvlist_free(nf);
1050         return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM));
1051 }
1052 
1053 static nvlist_t *
1054 hc_list_create(topo_mod_t *mod, const char *name, char *inst)
1055 {
1056         int err;
1057         nvlist_t *hc;
1058 
1059         if (topo_mod_nvalloc(mod, &hc, NV_UNIQUE_NAME) != 0)


1160                 if (topo_mod_nvdup(mod, phcl[i], &hcl[i]) != 0)
1161                         return (hc_create_seterror(mod,
1162                             hcl, pelems, fmri, EMOD_FMRI_NVL));
1163 
1164         (void) snprintf(str, sizeof (str), "%d", inst);
1165         if ((hcl[i] = hc_list_create(mod, name, str)) == NULL)
1166                 return (hc_create_seterror(mod,
1167                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1168 
1169         if ((fmri = hc_base_fmri_create(mod, auth, part, rev, serial)) == NULL)
1170                 return (hc_create_seterror(mod,
1171                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1172 
1173         if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, hcl, pelems + 1)
1174             != 0)
1175                 return (hc_create_seterror(mod,
1176                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1177 
1178         if (hcl != NULL) {
1179                 for (i = 0; i < pelems + 1; ++i) {
1180                         if (hcl[i] != NULL)
1181                                 nvlist_free(hcl[i]);
1182                 }
1183                 topo_mod_free(mod, hcl, sizeof (nvlist_t *) * (pelems + 1));
1184         }
1185 
1186         return (fmri);
1187 }
1188 
1189 /*ARGSUSED*/
1190 static int
1191 hc_fmri_create_meth(topo_mod_t *mod, tnode_t *node, topo_version_t version,
1192     nvlist_t *in, nvlist_t **out)
1193 {
1194         int ret;
1195         nvlist_t *args, *pfmri = NULL;
1196         nvlist_t *auth;
1197         uint32_t inst;
1198         char *name, *serial, *rev, *part;
1199 
1200         if (version > TOPO_METH_FMRI_VERSION)




1019                 nvlist_free(pa[i]);
1020         topo_mod_free(mod, pa, npairs * sizeof (nvlist_t *));
1021         topo_mod_strfree(mod, serial);
1022         topo_mod_strfree(mod, part);
1023         topo_mod_strfree(mod, rev);
1024         nvlist_free(auth);
1025 
1026         if (make_facility(mod, str, &fac) == -1)
1027                 goto hcfmbail;
1028 
1029         if (fac != NULL) {
1030                 if (nvlist_add_nvlist(nf, FM_FMRI_FACILITY, fac) != 0)
1031                         goto hcfmbail;
1032         }
1033 
1034         *out = nf;
1035 
1036         return (0);
1037 
1038 hcfmbail:

1039         nvlist_free(nf);
1040         for (i = 0; i < npairs; i++)
1041                 nvlist_free(pa[i]);
1042         topo_mod_free(mod, pa, npairs * sizeof (nvlist_t *));
1043 
1044         topo_mod_strfree(mod, serial);
1045         topo_mod_strfree(mod, part);
1046         topo_mod_strfree(mod, rev);
1047         nvlist_free(auth);
1048         nvlist_free(nf);
1049         return (topo_mod_seterrno(mod, EMOD_FMRI_MALFORM));
1050 }
1051 
1052 static nvlist_t *
1053 hc_list_create(topo_mod_t *mod, const char *name, char *inst)
1054 {
1055         int err;
1056         nvlist_t *hc;
1057 
1058         if (topo_mod_nvalloc(mod, &hc, NV_UNIQUE_NAME) != 0)


1159                 if (topo_mod_nvdup(mod, phcl[i], &hcl[i]) != 0)
1160                         return (hc_create_seterror(mod,
1161                             hcl, pelems, fmri, EMOD_FMRI_NVL));
1162 
1163         (void) snprintf(str, sizeof (str), "%d", inst);
1164         if ((hcl[i] = hc_list_create(mod, name, str)) == NULL)
1165                 return (hc_create_seterror(mod,
1166                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1167 
1168         if ((fmri = hc_base_fmri_create(mod, auth, part, rev, serial)) == NULL)
1169                 return (hc_create_seterror(mod,
1170                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1171 
1172         if (nvlist_add_nvlist_array(fmri, FM_FMRI_HC_LIST, hcl, pelems + 1)
1173             != 0)
1174                 return (hc_create_seterror(mod,
1175                     hcl, pelems, fmri, EMOD_FMRI_NVL));
1176 
1177         if (hcl != NULL) {
1178                 for (i = 0; i < pelems + 1; ++i) {

1179                         nvlist_free(hcl[i]);
1180                 }
1181                 topo_mod_free(mod, hcl, sizeof (nvlist_t *) * (pelems + 1));
1182         }
1183 
1184         return (fmri);
1185 }
1186 
1187 /*ARGSUSED*/
1188 static int
1189 hc_fmri_create_meth(topo_mod_t *mod, tnode_t *node, topo_version_t version,
1190     nvlist_t *in, nvlist_t **out)
1191 {
1192         int ret;
1193         nvlist_t *args, *pfmri = NULL;
1194         nvlist_t *auth;
1195         uint32_t inst;
1196         char *name, *serial, *rev, *part;
1197 
1198         if (version > TOPO_METH_FMRI_VERSION)