volserver: Do not return ENOMEM on AIX from XVolListPartitions

When calling "vos partinfo" or "vos listpart" towards a server
 running AIX with no partitions attached, it would return a
ENOMEM, because unlike on linux, malloc(0) returns NULL on AIX.
Thus, just don't do any malloc, when we have no partitions anyway.

Change-Id: Id1900e2ab11850ada8b2e91667288576d408014b
Reviewed-on: http://gerrit.openafs.org/2912
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Christof Hanke 2010-10-05 17:01:41 +02:00 committed by Derrick Brashear
parent e445faa68c
commit 21e1bb9bb4

View File

@ -1884,12 +1884,17 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries)
if (dp) if (dp)
partList.partId[j++] = i; partList.partId[j++] = i;
} }
pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int)); if (j > 0) {
if (!pEntries->partEntries_val) pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int));
return ENOMEM; if (!pEntries->partEntries_val)
memcpy((char *)pEntries->partEntries_val, (char *)&partList, return ENOMEM;
j * sizeof(int)); memcpy((char *)pEntries->partEntries_val, (char *)&partList,
pEntries->partEntries_len = j; j * sizeof(int));
pEntries->partEntries_len = j;
} else {
pEntries->partEntries_val = NULL;
pEntries->partEntries_len = 0;
}
return 0; return 0;
} }