From: Christof Hanke Date: Tue, 5 Oct 2010 15:01:41 +0000 (+0200) Subject: volserver: Do not return ENOMEM on AIX from XVolListPartitions X-Git-Tag: upstream/1.8.0_pre1^2~4700 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=21e1bb9bb46b0e8e2523c3310ea8e602d2b07091;p=packages%2Fo%2Fopenafs.git 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 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index 94f458683..f609e1aec 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -1884,12 +1884,17 @@ XVolListPartitions(struct rx_call *acid, struct partEntries *pEntries) if (dp) partList.partId[j++] = i; } - pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int)); - if (!pEntries->partEntries_val) - return ENOMEM; - memcpy((char *)pEntries->partEntries_val, (char *)&partList, - j * sizeof(int)); - pEntries->partEntries_len = j; + if (j > 0) { + pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int)); + if (!pEntries->partEntries_val) + return ENOMEM; + memcpy((char *)pEntries->partEntries_val, (char *)&partList, + j * sizeof(int)); + pEntries->partEntries_len = j; + } else { + pEntries->partEntries_val = NULL; + pEntries->partEntries_len = 0; + } return 0; }