Fix loader manifest version checks
authorCharles Giessen <charles@lunarg.com>
Tue, 25 Jan 2022 02:34:50 +0000 (19:34 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 25 Jan 2022 19:32:56 +0000 (12:32 -0700)
Several version checks were underspecified and either caused false positives
or didn't catch version violations.
For example, a manifest version 1.2.0 is valid but would emit warnings implying
the version is less than 1.1.

loader/loader.c

index 3d671daa0a71523687a40409c3964bb787a94c50..9c0aa134e708f0c059f7b2a0b29191eaa7bf8388 100644 (file)
@@ -2001,7 +2001,7 @@ static VkResult loader_read_layer_json(const struct loader_instance *inst, struc
     if (!strcmp(name, VK_OVERRIDE_LAYER_NAME)) {
         cJSON *expiration;
 
-        if (version.major < 1 && version.minor < 1 && version.patch < 2) {
+        if (version.major == 0 || (version.minor == 1 && version.patch < 2) || version.minor == 0) {
             loader_log(
                 inst, VULKAN_LOADER_WARN_BIT, 0,
                 "Override layer expiration date not added until version 1.1.2.  Please update JSON file version appropriately.");
@@ -2109,7 +2109,7 @@ static VkResult loader_read_layer_json(const struct loader_instance *inst, struc
             }
         }
     } else if (NULL != component_layers) {
-        if (version.major == 1 && ((version.minor == 1 && version.patch < 1) || (version.minor == 0))) {
+        if (version.major == 0 || (version.minor == 1 && version.patch < 1) || (version.minor == 0)) {
             loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
                        "Indicating meta-layer-specific component_layers, but using older JSON file version.");
         }
@@ -2195,7 +2195,7 @@ static VkResult loader_read_layer_json(const struct loader_instance *inst, struc
 
     override_paths = cJSON_GetObjectItem(layer_node, "override_paths");
     if (NULL != override_paths) {
-        if (version.major == 1 && (version.minor < 1 || version.patch < 1)) {
+        if (version.major == 0 || (version.minor == 1 && version.patch) < 1 || version.minor == 0) {
             loader_log(inst, VULKAN_LOADER_WARN_BIT, 0,
                        "Indicating meta-layer-specific override paths, but using older JSON file version.");
         }