i965: Don't write past the end of the application supplied buffer
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 28 Feb 2015 02:43:00 +0000 (18:43 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 9 Mar 2015 21:07:14 +0000 (14:07 -0700)
commite7d94be1ec9c87063a21731a982ae4677cd43bdf
tree1e9239fb136ac308cc0b49e3b90c50436a239c73
parent78a211cee5f3f5fc101e3e68b5b1c8258837a6c3
i965: Don't write past the end of the application supplied buffer

Both the AMD and Intel APIs provide a dataSize parameter, and this
function would merrily ignore it.  Neither API specifies what to do when
the buffer isn't big enough.  I take the easy route of writing all the
complete bits of data that will fit.  With more complete specs, we could
probably do something different.

I noticed this while looking into an unused parameter warning.  The
warning was actually useful!

brw_performance_monitor.c: In function 'brw_get_perf_monitor_result':
brw_performance_monitor.c:1261:37: warning: unused parameter 'data_size' [-Wunused-parameter]
                             GLsizei data_size,
                                     ^

v2: Fix checks to include offset in the calculation.  Noticed by Jan.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
src/mesa/drivers/dri/i965/brw_performance_monitor.c