i965, anv: Add extra unused character in disk_cache renderer temp string
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 21 Jul 2018 06:41:23 +0000 (23:41 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Tue, 24 Jul 2018 23:17:25 +0000 (16:17 -0700)
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@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_device.c
src/mesa/drivers/dri/i965/brw_disk_cache.c

index 04fd6a829ed60081abc4bba2ccb0faad589769b2..247ba64133634f9927bdacda1874ce665bdbf9ad 100644 (file)
@@ -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);
index c478753d4ad29b0b941a4b80a782ab498171f3aa..a678c355b9db8b09ba4d740493ff0c3c4bd59d57 100644 (file)
@@ -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);