[Mesa-dev] [PATCH 5/6] mesa: Implement INTEL_performance_query.

Petri Latvala petri.latvala at intel.com
Tue Apr 22 03:31:07 PDT 2014


On 04/19/2014 12:34 AM, Ian Romanick wrote:
> On 03/17/2014 01:43 AM, Petri Latvala wrote:
> +   if (queryName) {
> +      strncpy(queryName, group_obj->Name, queryNameLength);
> +      /* No specification given about whether the string needs to be
> +       * zero-terminated.  Zero-terminate the string anyway, no way for the
> +       * application to know if the buffer was large enough.
> +       */
> Ugh... there's no way to ask the length of the longest name (like you
> can do with program uniforms)?  Bad spec, bad!
>
>

There's GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL etc. for all these 
string getters, so the comment might be a bit misleading. I'll rewrite 
it. The intention is to ensure that the written data is always 
null-terminated, even if the given buffer was too small. strncpy will 
already write the \0 at the end unless the buffer was too small. 
glGetActiveUniform() and pals return the length of the actual data 
written (not to mention explicitly specifying that the string is 
null-terminated), this API does not.



More information about the mesa-dev mailing list