On 01/11/2011 11:58 AM, Eric Blake wrote:
>>  char *
>>  openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
>>  {
>> @@ -98,7 +99,13 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, 
>> char const *file)
>>    else
>>      {
>>        size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file));
>> -      char *result = (bufsize < OPENAT_BUFFER_SIZE ? buf : xmalloc 
>> (bufsize));
>> +      char *result = buf;
>> +      if (OPENAT_BUFFER_SIZE < bufsize)
>> +        {
>> +          result = malloc (bufsize);
>> +          if (! result)
>> +            return NULL;
> 
> Either we must depend on malloc-posix, or you need to force errno=ENOMEM
> here rather than relying on malloc() to do it.

Correction - due to how openat_proc_name is used, we _don't_ need
malloc-posix, because you didn't change things to promise a sane errno.
 Since we _always_ fallback to the fchdir method if this failed without
ever inspecting errno, the caller never needs to know that we had an
intermediate ENOMEM situation, and we can get by without worrying
whether malloc set errno.

But you should still drop the xmalloc dependency from the module
description.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to