[Bf-blender-cvs] [3a88f151c49] master: Cleanup: Proper printing of a string

Sergey Sharybin noreply at git.blender.org
Wed Apr 13 11:56:57 CEST 2022


Commit: 3a88f151c49f820ebb1589377958b397b1d9b96c
Author: Sergey Sharybin
Date:   Wed Apr 13 11:55:37 2022 +0200
Branches: master
https://developer.blender.org/rB3a88f151c49f820ebb1589377958b397b1d9b96c

Cleanup: Proper printing of a string

Print it as a "%s" so that possible percentage symbols in the
error message does not cause issues.

Use proper assert (assert(true) is a no-op).

Also use `empty()` instead of `length()`.

Reviewed with Clement in real life.

===================================================================

M	source/blender/gpu/intern/gpu_shader.cc

===================================================================

diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 227525bd5d3..76b3402435a 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -283,10 +283,10 @@ GPUShader *GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
 
   GPU_debug_group_begin(GPU_DEBUG_SHADER_COMPILATION_GROUP);
 
-  std::string error = info.check_error();
-  if (error.length()) {
-    printf(error.c_str());
-    BLI_assert(true);
+  const std::string error = info.check_error();
+  if (!error.empty()) {
+    printf("%s\n", error.c_str());
+    BLI_assert(false);
   }
 
   Shader *shader = GPUBackend::get()->shader_alloc(info.name_.c_str());



More information about the Bf-blender-cvs mailing list