[Libva] [PATCH] android-log: enable logs according to Android version

Gwenole Beauchesne gb.devel at gmail.com
Tue Jul 31 21:47:03 PDT 2012


Hi,

2012/8/1 Charles, Daniel <daniel.charles at intel.com>:

>> No need to change anything in this hunk.
>
> ok, I guess you want to keep indentation here.

Hmmm, yes, but also because it's not related to what this patch was about. :)

>>> diff --git a/va/va.c b/va/va.c
>>> index 1bbe047..6adf821 100644
>>> --- a/va/va.c
>>> +++ b/va/va.c
>>> @@ -105,21 +105,24 @@ int vaDisplayIsValid(VADisplay dpy)
>>>
>>>  void va_errorMessage(const char *msg, ...)
>>>  {
>>> +    char buffer[1024];
>>>      va_list args;
>>>
>>> -    fprintf(stderr, "libva error: ");
>>>      va_start(args, msg);
>>> -    vfprintf(stderr, msg, args);
>>> +    vsnprintf(buffer, 1024, msg, args);
>>
>> Several errors: use sizeof, and check return value. If undersized,
>> allocate a new buffer.
>> Same for va_infoMessage().
>
> Someone recommended offline to use vasnprintf, it will avoid check
> plus re-allocate, the chances to re-size are really high here.

vasnprintf() is still a GNU libc extension IIRC. Please stick to
vsnprintf() with local buffer (up to 512 or 1024 bytes) + dynamic
buffer if needed. The former will cover most cases so that you avoid
memory allocation (and deallocation).

Thanks,
Gwenole.


More information about the Libva mailing list