Print this page
patch tsoome-feedback

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/topo/libtopo/common/topo_prop.c
          +++ new/usr/src/lib/fm/topo/libtopo/common/topo_prop.c
↓ open down ↓ 101 lines elided ↑ open up ↑
 102  102                  if (strcmp(pvl->tp_pval->tp_name, pname) == 0)
 103  103                          return (pvl->tp_pval);
 104  104          }
 105  105  
 106  106          return (NULL);
 107  107  }
 108  108  
 109  109  static int
 110  110  method_geterror(nvlist_t *nvl, int err, int *errp)
 111  111  {
 112      -        if (nvl != NULL)
 113      -                nvlist_free(nvl);
      112 +        nvlist_free(nvl);
 114  113  
 115  114          *errp = err;
 116  115  
 117  116          return (-1);
 118  117  }
 119  118  
 120  119  static int
 121  120  prop_method_get(tnode_t *node, topo_propval_t *pv, topo_propmethod_t *pm,
 122  121      nvlist_t *pargs, int *err)
 123  122  {
↓ open down ↓ 34 lines elided ↑ open up ↑
 158  157          /* Verify the property contents */
 159  158          ret = nvlist_lookup_string(nvl, TOPO_PROP_VAL_NAME, &name);
 160  159          if (ret != 0 || strcmp(name, pv->tp_name) != 0)
 161  160                  return (method_geterror(nvl, ETOPO_PROP_NAME, err));
 162  161  
 163  162          ret = nvlist_lookup_uint32(nvl, TOPO_PROP_VAL_TYPE, (uint32_t *)&type);
 164  163          if (ret != 0 || type != pv->tp_type)
 165  164                  return (method_geterror(nvl, ETOPO_PROP_TYPE, err));
 166  165  
 167  166          /* Release the last value and re-assign to the new value */
 168      -        if (pv->tp_val != NULL)
 169      -                nvlist_free(pv->tp_val);
      167 +        nvlist_free(pv->tp_val);
 170  168          pv->tp_val = nvl;
 171  169  
 172  170          return (0);
 173  171  }
 174  172  
 175  173  static topo_propval_t *
 176  174  prop_get(tnode_t *node, const char *pgname, const char *pname, nvlist_t *pargs,
 177  175      int *err)
 178  176  {
 179  177          topo_propval_t *pv = NULL;
↓ open down ↓ 668 lines elided ↑ open up ↑
 848  846  
 849  847  static int
 850  848  register_methoderror(tnode_t *node, topo_propmethod_t *pm, int *errp, int l,
 851  849      int err)
 852  850  {
 853  851          topo_hdl_t *thp = node->tn_hdl;
 854  852  
 855  853          if (pm != NULL) {
 856  854                  if (pm->tpm_name != NULL)
 857  855                          topo_hdl_strfree(thp, pm->tpm_name);
 858      -                if (pm->tpm_args != NULL)
 859      -                        nvlist_free(pm->tpm_args);
      856 +                nvlist_free(pm->tpm_args);
 860  857                  topo_hdl_free(thp, pm, sizeof (topo_propmethod_t));
 861  858          }
 862  859  
 863  860          *errp = err;
 864  861  
 865  862          if (l != 0)
 866  863                  topo_node_unlock(node);
 867  864  
 868  865          return (-1);
 869  866  }
↓ open down ↓ 430 lines elided ↑ open up ↑
1300 1297  
1301 1298  static void
1302 1299  propmethod_destroy(topo_hdl_t *thp, topo_propval_t *pv)
1303 1300  {
1304 1301          topo_propmethod_t *pm;
1305 1302  
1306 1303          pm = pv->tp_method;
1307 1304          if (pm != NULL) {
1308 1305                  if (pm->tpm_name != NULL)
1309 1306                          topo_hdl_strfree(thp, pm->tpm_name);
1310      -                if (pm->tpm_args != NULL)
1311      -                        nvlist_free(pm->tpm_args);
     1307 +                nvlist_free(pm->tpm_args);
1312 1308                  topo_hdl_free(thp, pm, sizeof (topo_propmethod_t));
1313 1309                  pv->tp_method = NULL;
1314 1310          }
1315 1311  }
1316 1312  
1317 1313  static void
1318 1314  topo_propval_destroy(topo_propval_t *pv)
1319 1315  {
1320 1316          topo_hdl_t *thp;
1321 1317  
1322 1318          if (pv == NULL)
1323 1319                  return;
1324 1320  
1325 1321          thp = pv->tp_hdl;
1326 1322  
1327 1323          if (pv->tp_name != NULL)
1328 1324                  topo_hdl_strfree(thp, pv->tp_name);
1329 1325  
1330      -        if (pv->tp_val != NULL)
1331      -                nvlist_free(pv->tp_val);
     1326 +        nvlist_free(pv->tp_val);
1332 1327  
1333 1328          propmethod_destroy(thp, pv);
1334 1329  
1335 1330          topo_hdl_free(thp, pv, sizeof (topo_propval_t));
1336 1331  }
1337 1332  
1338 1333  void
1339 1334  topo_prop_hold(topo_propval_t *pv)
1340 1335  {
1341 1336          pv->tp_refs++;
↓ open down ↓ 54 lines elided ↑ open up ↑
1396 1391          }
1397 1392  
1398 1393          return (0);
1399 1394  }
1400 1395  
1401 1396  static int
1402 1397  get_pgrp_seterror(tnode_t *node, nvlist_t *nvl, int *errp, int err)
1403 1398  {
1404 1399          topo_node_unlock(node);
1405 1400  
1406      -        if (nvl != NULL)
1407      -                nvlist_free(nvl);
     1401 +        nvlist_free(nvl);
1408 1402  
1409 1403          *errp = err;
1410 1404  
1411 1405          return (-1);
1412 1406  }
1413 1407  
1414 1408  int
1415 1409  topo_prop_getpgrp(tnode_t *node, const char *pgname, nvlist_t **pgrp,
1416 1410      int *err)
1417 1411  {
↓ open down ↓ 51 lines elided ↑ open up ↑
1469 1463          topo_node_unlock(node);
1470 1464          *err = ETOPO_PROP_NOENT;
1471 1465          return (-1);
1472 1466  }
1473 1467  
1474 1468  static nvlist_t *
1475 1469  get_all_seterror(tnode_t *node, nvlist_t *nvl, int *errp, int err)
1476 1470  {
1477 1471          topo_node_unlock(node);
1478 1472  
1479      -        if (nvl != NULL)
1480      -                nvlist_free(nvl);
     1473 +        nvlist_free(nvl);
1481 1474  
1482 1475          *errp = err;
1483 1476  
1484 1477          return (NULL);
1485 1478  }
1486 1479  
1487 1480  nvlist_t *
1488 1481  topo_prop_getprops(tnode_t *node, int *err)
1489 1482  {
1490 1483          int ret;
↓ open down ↓ 57 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX