[Mesa-dev] [PATCH v2 1/2] i965, anv: Add extra unused character in disk_cache renderer temp string
Jason Ekstrand
jason at jlekstrand.net
Mon Jul 23 06:17:46 UTC 2018
Acked-by: Jason Ekstrand <jason at jlekstrand.net>
On Sun, Jul 22, 2018 at 9:28 PM Jordan Justen <jordan.l.justen at intel.com>
wrote:
> This extra character should not be used by snprintf, but we make it
> available to verify that we printed the exact number we wanted, and
> didn't overflow.
>
> v2:
> * Also update Anvil
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com> (v1)
> ---
> src/intel/vulkan/anv_device.c | 4 ++--
> src/mesa/drivers/dri/i965/brw_disk_cache.c | 5 +++--
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 04fd6a829ed..247ba641336 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -278,10 +278,10 @@ static void
> anv_physical_device_init_disk_cache(struct anv_physical_device *device)
> {
> #ifdef ENABLE_SHADER_CACHE
> - char renderer[9];
> + char renderer[10];
> MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "anv_%04x",
> device->chipset_id);
> - assert(len == sizeof(renderer) - 1);
> + assert(len == sizeof(renderer) - 2);
>
> char timestamp[41];
> _mesa_sha1_format(timestamp, device->driver_build_sha1);
> diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c
> b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> index c478753d4ad..a678c355b9d 100644
> --- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
> +++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
> @@ -377,10 +377,11 @@ void
> brw_disk_cache_init(struct intel_screen *screen)
> {
> #ifdef ENABLE_SHADER_CACHE
> - char renderer[10];
> + /* array length: print length + null char + 1 extra to verify it is
> unused */
> + char renderer[11];
> MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer),
> "i965_%04x",
> screen->deviceID);
> - assert(len == sizeof(renderer) - 1);
> + assert(len == sizeof(renderer) - 2);
>
> const struct build_id_note *note =
> build_id_find_nhdr_for_addr(brw_disk_cache_init);
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180722/0ce2a336/attachment.html>
More information about the mesa-dev
mailing list