return idx;
}
-char *virIndexToDiskName(int idx, const char *prefix)
+char *virIndexToDiskName(unsigned int idx, const char *prefix)
{
char *name = NULL;
size_t i;
int ctr;
int offset;
- if (idx < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Disk index %d is negative"), idx);
- return NULL;
- }
-
for (i = 0, ctr = idx; ctr >= 0; ++i, ctr = ctr / 26 - 1) { }
offset = strlen(prefix);
int virDiskNameParse(const char *name, int *disk, int *partition);
int virDiskNameToIndex(const char* str);
-char *virIndexToDiskName(int idx, const char *prefix);
+char *virIndexToDiskName(unsigned int idx, const char *prefix);
/* No-op workarounds for functionality missing in mingw. */
#ifndef WITH_GETUID
(*def)->dst =
virIndexToDiskName
(controllerOrBus * 15 + (unit < 7 ? unit : unit - 1), "sd");
-
- if ((*def)->dst == NULL)
- goto cleanup;
} else if (busType == VIR_DOMAIN_DISK_BUS_SATA) {
if (controllerOrBus < 0 || controllerOrBus > 3) {
virReportError(VIR_ERR_INTERNAL_ERROR,
prefix = g_strdup_printf("sata%d:%d", controllerOrBus, unit);
(*def)->dst = virIndexToDiskName(controllerOrBus * 30 + unit, "sd");
-
- if ((*def)->dst == NULL)
- goto cleanup;
} else if (busType == VIR_DOMAIN_DISK_BUS_IDE) {
if (controllerOrBus < 0 || controllerOrBus > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR,
prefix = g_strdup_printf("ide%d:%d", controllerOrBus, unit);
(*def)->dst = virIndexToDiskName(controllerOrBus * 2 + unit, "hd");
-
- if ((*def)->dst == NULL)
- goto cleanup;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported bus type '%s' for device type '%s'"),
prefix = g_strdup_printf("floppy%d", unit);
(*def)->dst = virIndexToDiskName(unit, "fd");
-
- if ((*def)->dst == NULL)
- goto cleanup;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported bus type '%s' for device type '%s'"),