build: stop calling unreachable() without arguments

The unreachable(str) macro defined in src/util/macros.h is defined to
accept a literal string as an argument.

However the way it checks that the argument is a string literal, by
prepending an empty string where the argument is used, i.e.:

  #define unreachabel(str) assert(!"" str)

still allows users to call the macro with no arguments.

This is confusing, so pass an empty string to all invocations of
unreachable() for consistency.

This is done with the following command:

  git grep -l '[^_]unreachable();' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable();/\1unreachable("");/g' -i "$file";
  done

This should not change the behaviour of the callers of unreachable() in
a meaningful way, but there will be some cosmetic consequence.

The changed invocations will now print:

  Assertion `!"" ""' failed.

instead of

  Assertion `!""' failed.

But this is also what happens for the invocations that do pass an
argument, for instance `unreachable("Invalid type")` currently prints:

  Assertion `!"" "Invalid type"' failed.

So all invocations now also have the same output style.

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
This commit is contained in:
Antonio Ospite
2025-07-29 13:55:45 +02:00
committed by Marge Bot
parent 128aa6bcae
commit b4c7d3a08e
22 changed files with 75 additions and 75 deletions
+2 -2
View File
@@ -430,7 +430,7 @@ vk_image_view_type_to_sampler_dim(VkImageViewType view_type)
return GLSL_SAMPLER_DIM_3D;
default:
unreachable();
unreachable("");
}
}
@@ -450,7 +450,7 @@ vk_image_view_type_is_array(VkImageViewType view_type)
return false;
default:
unreachable();
unreachable("");
}
}