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

Huang, Haitao haitao.huang at intel.com
Wed Aug 1 11:16:47 PDT 2012


On Tue, Jul 31, 2012 at 11:47 PM, Gwenole Beauchesne <gb.devel at gmail.com> wrote:
> 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).
>
I'll vote for no dynamic allocation. It's not big deal to me to
truncate if log message is too long.

> Thanks,
> Gwenole.
> _______________________________________________
> Libva mailing list
> Libva at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libva


More information about the Libva mailing list