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


 699                             snum == in_snum) {
 700                                 continue;
 701                         } else {
 702                                 char *str = dm_get_name(slices[i], errp);
 703                                 if (*errp != 0) {
 704                                         nvlist_free(other_attrs);
 705                                         ret = -1;
 706                                         goto out;
 707                                 }
 708                                 *overlaps_with = strdup(str);
 709                                 dm_free_name(str);
 710                                 nvlist_free(other_attrs);
 711                                 ret = 1;
 712                                 goto out;
 713                         }
 714                 }
 715                 nvlist_free(other_attrs);
 716         }
 717 
 718 out:
 719         if (media_attrs)
 720                 nvlist_free(media_attrs);
 721         if (slice_attrs)
 722                 nvlist_free(slice_attrs);
 723 
 724         if (slices)
 725                 dm_free_descriptors(slices);
 726         if (media)
 727                 dm_free_descriptors(media);
 728         if (slice)
 729                 dm_free_descriptor(slice);
 730 
 731         return (ret);
 732 }
 733 
 734 /*
 735  * Get the full list of swap entries.  Returns -1 on error, or >= 0 to
 736  * indicate the number of entries in the list.  Callers are responsible
 737  * for calling dm_free_swapentries() to deallocate memory.  If this
 738  * returns 0, the swaptbl_t still needs to be freed.
 739  */
 740 int
 741 dm_get_swapentries(swaptbl_t **stp, int *errp)


1040                                 if (strcmp(by, DM_USE_SPARE_ZPOOL) != 0) {
1041                                         if (build_usage_string(dname, by,
1042                                             data, msg, &found, errp) != 0) {
1043                                                 if (*errp)
1044                                                         goto out;
1045                                         }
1046                                 }
1047                                 break;
1048 
1049                         default:
1050                                 /*
1051                                  * nothing found in use for this client
1052                                  * of libdiskmgt. Default is 'not in use'.
1053                                  */
1054                                 break;
1055                 }
1056         }
1057 out:
1058         if (dname != NULL)
1059                 free(dname);
1060         if (dev_stats != NULL)
1061                 nvlist_free(dev_stats);
1062 
1063         return (found);
1064 }
1065 
1066 void
1067 dm_get_usage_string(char *what, char *how, char **usage_string)
1068 {
1069 
1070 
1071         if (usage_string == NULL || what == NULL) {
1072                 return;
1073         }
1074         *usage_string = NULL;
1075 
1076         if (strcmp(what, DM_USE_MOUNT) == 0) {
1077                 if (strcmp(how, "swap") == 0) {
1078                         *usage_string = dgettext(TEXT_DOMAIN,
1079                             "%s is currently used by swap. Please see swap(1M)."
1080                             "\n");




 699                             snum == in_snum) {
 700                                 continue;
 701                         } else {
 702                                 char *str = dm_get_name(slices[i], errp);
 703                                 if (*errp != 0) {
 704                                         nvlist_free(other_attrs);
 705                                         ret = -1;
 706                                         goto out;
 707                                 }
 708                                 *overlaps_with = strdup(str);
 709                                 dm_free_name(str);
 710                                 nvlist_free(other_attrs);
 711                                 ret = 1;
 712                                 goto out;
 713                         }
 714                 }
 715                 nvlist_free(other_attrs);
 716         }
 717 
 718 out:

 719         nvlist_free(media_attrs);

 720         nvlist_free(slice_attrs);
 721 
 722         if (slices)
 723                 dm_free_descriptors(slices);
 724         if (media)
 725                 dm_free_descriptors(media);
 726         if (slice)
 727                 dm_free_descriptor(slice);
 728 
 729         return (ret);
 730 }
 731 
 732 /*
 733  * Get the full list of swap entries.  Returns -1 on error, or >= 0 to
 734  * indicate the number of entries in the list.  Callers are responsible
 735  * for calling dm_free_swapentries() to deallocate memory.  If this
 736  * returns 0, the swaptbl_t still needs to be freed.
 737  */
 738 int
 739 dm_get_swapentries(swaptbl_t **stp, int *errp)


1038                                 if (strcmp(by, DM_USE_SPARE_ZPOOL) != 0) {
1039                                         if (build_usage_string(dname, by,
1040                                             data, msg, &found, errp) != 0) {
1041                                                 if (*errp)
1042                                                         goto out;
1043                                         }
1044                                 }
1045                                 break;
1046 
1047                         default:
1048                                 /*
1049                                  * nothing found in use for this client
1050                                  * of libdiskmgt. Default is 'not in use'.
1051                                  */
1052                                 break;
1053                 }
1054         }
1055 out:
1056         if (dname != NULL)
1057                 free(dname);

1058         nvlist_free(dev_stats);
1059 
1060         return (found);
1061 }
1062 
1063 void
1064 dm_get_usage_string(char *what, char *how, char **usage_string)
1065 {
1066 
1067 
1068         if (usage_string == NULL || what == NULL) {
1069                 return;
1070         }
1071         *usage_string = NULL;
1072 
1073         if (strcmp(what, DM_USE_MOUNT) == 0) {
1074                 if (strcmp(how, "swap") == 0) {
1075                         *usage_string = dgettext(TEXT_DOMAIN,
1076                             "%s is currently used by swap. Please see swap(1M)."
1077                             "\n");