enum tgt_type type)
{
int ret, obdcount, maxidx, obd_valid = 0, obdnum;
- long i;
- struct obd_uuid *uuids = NULL;
int *indices = NULL;
- char buf[16];
+ struct obd_uuid *uuids = NULL;
int *indexes;
+ char buf[16];
+ long i;
if (type == LOV_TYPE)
ret = get_param_lov(path, "numobd", buf, sizeof(buf));
return -ENOMEM;
indices = malloc(obdcount * sizeof(int));
if (indices == NULL) {
- free(uuids);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out_uuids;
}
maxidx = obdcount;
if (ret) {
if (ret == -EOVERFLOW) {
struct obd_uuid *uuids_temp;
- int *indices_temp;
+ int *indices_temp = NULL;
uuids_temp = realloc(uuids, obdcount *
sizeof(struct obd_uuid));
- indices_temp = realloc(indices, obdcount * sizeof(int));
- if (uuids_temp != NULL && indices_temp != NULL) {
+ if (uuids_temp)
uuids = uuids_temp;
+ indices_temp = realloc(indices, obdcount * sizeof(int));
+ if (indices_temp)
indices = indices_temp;
+ if (uuids_temp && indices_temp)
goto retry_get_uuids;
- }
ret = -ENOMEM;
}
- llapi_error(LLAPI_MSG_ERROR, ret, "cannot get ost uuid");
+ llapi_error(LLAPI_MSG_ERROR, ret, "cannot fetch %u OST UUIDs",
+ obdcount);
goto out_free;
}
*obdindexes = indexes;
out_free:
- if (uuids)
- free(uuids);
if (indices)
free(indices);
+out_uuids:
+ if (uuids)
+ free(uuids);
return ret;
}