[Mesa-dev] [PATCH 4/6] gallium/u_queue: add an option to name threads

Nicolai Hähnle nhaehnle at gmail.com
Tue Jun 21 14:55:06 UTC 2016


On 21.06.2016 16:50, Marek Olšák wrote:
> On Tue, Jun 21, 2016 at 4:40 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
>> On 21.06.2016 14:17, Marek Olšák wrote:
>>>
>>> From: Marek Olšák <marek.olsak at amd.com>
>>>
>>> for debugging
>>> ---
>>>    src/gallium/auxiliary/util/u_queue.c              | 10 ++++++++++
>>>    src/gallium/auxiliary/util/u_queue.h              |  2 ++
>>>    src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c     |  2 +-
>>>    src/gallium/winsys/radeon/drm/radeon_drm_winsys.c |  2 +-
>>>    4 files changed, 14 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/gallium/auxiliary/util/u_queue.c
>>> b/src/gallium/auxiliary/util/u_queue.c
>>> index d14d850..a0b0317 100644
>>> --- a/src/gallium/auxiliary/util/u_queue.c
>>> +++ b/src/gallium/auxiliary/util/u_queue.c
>>> @@ -26,6 +26,7 @@
>>>
>>>    #include "u_queue.h"
>>>    #include "u_memory.h"
>>> +#include "u_string.h"
>>>    #include "os/os_time.h"
>>>
>>>    static void
>>> @@ -61,6 +62,13 @@ static PIPE_THREAD_ROUTINE(util_queue_thread_func,
>>> input)
>>>
>>>       FREE(input);
>>>
>>> +   if (queue->name) {
>>> +      char name[16] = {0};
>>> +      util_snprintf(name, sizeof(name) - 1, "%s:%i",
>>> +                    queue->name, thread_index);
>>
>>
>> It should be safe to just say util_snprintf(name, sizeof(name), ...) without
>> initializing name.
>
> It's not. snprintf doesn't write '\0' if the output string length is >= size.

Not sure if there was ever some variant that didn't, but both the 
manpage and a quick test agree that it does.

Nicolai

>
> Marek
>


More information about the mesa-dev mailing list