Series looks good.  Thanks for doing this.

Reviewed-by: Brian Paul <bri...@vmware.com>


On 08/01/2018 12:53 PM, Andres Gomez wrote:
Instead of plain snprintf(). To fix the MSVC 2013 build.

Fixes: 6ff0c6f4ebc ("gallium: move ddebug, noop, rbug, trace to auxiliary to improve 
build times")
Cc: Marek Olšák <marek.ol...@amd.com>
Cc: Brian Paul <bri...@vmware.com>
Cc: Roland Scheidegger <srol...@vmware.com>
Signed-off-by: Andres Gomez <ago...@igalia.com>
---
  .../glsl/ir_builder_print_visitor.cpp         |  7 ++++---
  src/compiler/glsl/ir_print_visitor.cpp        | 20 ++++++++++---------
  src/compiler/glsl/link_interface_blocks.cpp   |  5 +++--
  src/compiler/glsl/linker.cpp                  |  5 +++--
  .../glsl/opt_dead_builtin_varyings.cpp        | 11 +++++-----
  src/compiler/glsl_types.cpp                   | 13 ++++++------
  6 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/src/compiler/glsl/ir_builder_print_visitor.cpp 
b/src/compiler/glsl/ir_builder_print_visitor.cpp
index dfe4bb27ac9..da04868652a 100644
--- a/src/compiler/glsl/ir_builder_print_visitor.cpp
+++ b/src/compiler/glsl/ir_builder_print_visitor.cpp
@@ -29,6 +29,7 @@
  #include "glsl_parser_extras.h"
  #include "main/macros.h"
  #include "util/hash_table.h"
+#include "util/u_string.h"
class ir_builder_print_visitor : public ir_hierarchical_visitor {
  public:
@@ -705,9 +706,9 @@ ir_builder_print_visitor::visit_leave(ir_call *ir)
        const struct hash_entry *const he =
           _mesa_hash_table_search(index_map, ir->return_deref);
- snprintf(return_deref_string, sizeof(return_deref_string),
-               "operand(r%04X).val",
-               (unsigned)(uintptr_t) he->data);
+      util_snprintf(return_deref_string, sizeof(return_deref_string),
+                    "operand(r%04X).val",
+                    (unsigned)(uintptr_t) he->data);
     } else {
        strcpy(return_deref_string, "NULL");
     }
diff --git a/src/compiler/glsl/ir_print_visitor.cpp 
b/src/compiler/glsl/ir_print_visitor.cpp
index ea14cdeb6c7..1626657081e 100644
--- a/src/compiler/glsl/ir_print_visitor.cpp
+++ b/src/compiler/glsl/ir_print_visitor.cpp
@@ -27,6 +27,7 @@
  #include "glsl_parser_extras.h"
  #include "main/macros.h"
  #include "util/hash_table.h"
+#include "util/u_string.h"
static void print_type(FILE *f, const glsl_type *t); @@ -167,31 +168,32 @@ void ir_print_visitor::visit(ir_variable *ir) char binding[32] = {0};
     if (ir->data.binding)
-      snprintf(binding, sizeof(binding), "binding=%i ", ir->data.binding);
+      util_snprintf(binding, sizeof(binding), "binding=%i ", ir->data.binding);
char loc[32] = {0};
     if (ir->data.location != -1)
-      snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
+      util_snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
char component[32] = {0};
     if (ir->data.explicit_component || ir->data.location_frac != 0)
-      snprintf(component, sizeof(component), "component=%i ", 
ir->data.location_frac);
+      util_snprintf(component, sizeof(component), "component=%i ",
+                    ir->data.location_frac);
char stream[32] = {0};
     if (ir->data.stream & (1u << 31)) {
        if (ir->data.stream & ~(1u << 31)) {
-         snprintf(stream, sizeof(stream), "stream(%u,%u,%u,%u) ",
-                  ir->data.stream & 3, (ir->data.stream >> 2) & 3,
-                  (ir->data.stream >> 4) & 3, (ir->data.stream >> 6) & 3);
+         util_snprintf(stream, sizeof(stream), "stream(%u,%u,%u,%u) ",
+                       ir->data.stream & 3, (ir->data.stream >> 2) & 3,
+                       (ir->data.stream >> 4) & 3, (ir->data.stream >> 6) & 3);
        }
     } else if (ir->data.stream) {
-      snprintf(stream, sizeof(stream), "stream%u ", ir->data.stream);
+      util_snprintf(stream, sizeof(stream), "stream%u ", ir->data.stream);
     }
char image_format[32] = {0};
     if (ir->data.image_format) {
-      snprintf(image_format, sizeof(image_format), "format=%x ",
-               ir->data.image_format);
+      util_snprintf(image_format, sizeof(image_format), "format=%x ",
+                    ir->data.image_format);
     }
const char *const cent = (ir->data.centroid) ? "centroid " : "";
diff --git a/src/compiler/glsl/link_interface_blocks.cpp 
b/src/compiler/glsl/link_interface_blocks.cpp
index 7c3037e8975..e5eca9460e3 100644
--- a/src/compiler/glsl/link_interface_blocks.cpp
+++ b/src/compiler/glsl/link_interface_blocks.cpp
@@ -32,6 +32,7 @@
  #include "main/macros.h"
  #include "main/mtypes.h"
  #include "util/hash_table.h"
+#include "util/u_string.h"
namespace {
@@ -233,7 +234,7 @@ public:
        if (var->data.explicit_location &&
            var->data.location >= VARYING_SLOT_VAR0) {
           char location_str[11];
-         snprintf(location_str, 11, "%d", var->data.location);
+         util_snprintf(location_str, 11, "%d", var->data.location);
const struct hash_entry *entry =
              _mesa_hash_table_search(ht, location_str);
@@ -259,7 +260,7 @@ public:
            * unsigned location value which is overkill but future proof.
            */
           char location_str[11];
-         snprintf(location_str, 11, "%d", var->data.location);
+         util_snprintf(location_str, 11, "%d", var->data.location);
           _mesa_hash_table_insert(ht, ralloc_strdup(mem_ctx, location_str), 
var);
        } else {
           _mesa_hash_table_insert(ht,
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 6a9d19e8695..3ce78fe6428 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -83,6 +83,7 @@
  #include "ir_uniform.h"
  #include "builtin_functions.h"
  #include "shader_cache.h"
+#include "util/u_string.h"
#include "main/imports.h"
  #include "main/shaderobj.h"
@@ -4119,8 +4120,8 @@ is_top_level_shader_storage_block_member(const char* name,
        return false;
     }
- snprintf(full_instanced_name, name_length, "%s.%s",
-            interface_name, field_name);
+   util_snprintf(full_instanced_name, name_length, "%s.%s",
+                 interface_name, field_name);
/* Check if its top-level shader storage block member of an
      * instanced interface block, or of a unnamed interface block.
diff --git a/src/compiler/glsl/opt_dead_builtin_varyings.cpp 
b/src/compiler/glsl/opt_dead_builtin_varyings.cpp
index 0ce19218606..0cb04b34589 100644
--- a/src/compiler/glsl/opt_dead_builtin_varyings.cpp
+++ b/src/compiler/glsl/opt_dead_builtin_varyings.cpp
@@ -53,6 +53,7 @@
  #include "compiler/glsl_types.h"
  #include "link_varyings.h"
  #include "main/mtypes.h"
+#include "util/u_string.h"
namespace { @@ -322,14 +323,14 @@ public: if (!(external_color_usage & (1 << i))) {
              if (info->color[i]) {
-               snprintf(name, 32, "gl_%s_FrontColor%i_dummy", mode_str, i);
+               util_snprintf(name, 32, "gl_%s_FrontColor%i_dummy", mode_str, 
i);
                 this->new_color[i] =
                    new (ctx) ir_variable(glsl_type::vec4_type, name,
                                          ir_var_temporary);
              }
if (info->backcolor[i]) {
-               snprintf(name, 32, "gl_%s_BackColor%i_dummy", mode_str, i);
+               util_snprintf(name, 32, "gl_%s_BackColor%i_dummy", mode_str, i);
                 this->new_backcolor[i] =
                    new (ctx) ir_variable(glsl_type::vec4_type, name,
                                          ir_var_temporary);
@@ -341,7 +342,7 @@ public:
            info->fog) {
           char name[32];
- snprintf(name, 32, "gl_%s_FogFragCoord_dummy", mode_str);
+         util_snprintf(name, 32, "gl_%s_FogFragCoord_dummy", mode_str);
           this->new_fog = new (ctx) ir_variable(glsl_type::float_type, name,
                                                 ir_var_temporary);
        }
@@ -365,13 +366,13 @@ public:
              if (!(external_usage & (1 << i))) {
                 /* This varying is unused in the next stage. Declare
                  * a temporary instead of an output. */
-               snprintf(name, 32, "gl_%s_%s%i_dummy", mode_str, var_name, i);
+               util_snprintf(name, 32, "gl_%s_%s%i_dummy", mode_str, var_name, 
i);
                 new_var[i] =
                    new (ctx) ir_variable(glsl_type::vec4_type, name,
                                          ir_var_temporary);
              }
              else {
-               snprintf(name, 32, "gl_%s_%s%i", mode_str, var_name, i);
+               util_snprintf(name, 32, "gl_%s_%s%i", mode_str, var_name, i);
                 new_var[i] =
                    new(ctx) ir_variable(glsl_type::vec4_type, name,
                                         this->info->mode);
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index d11c365e191..ca5368aa53f 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -26,6 +26,7 @@
  #include "compiler/glsl/glsl_parser_extras.h"
  #include "glsl_types.h"
  #include "util/hash_table.h"
+#include "util/u_string.h"
mtx_t glsl_type::hash_mutex = _MTX_INITIALIZER_NP;
@@ -459,7 +460,7 @@ glsl_type::glsl_type(const glsl_type *array, unsigned 
length) :
     char *const n = (char *) ralloc_size(this->mem_ctx, name_length);
if (length == 0)
-      snprintf(n, name_length, "%s[]", array->name);
+      util_snprintf(n, name_length, "%s[]", array->name);
     else {
        /* insert outermost dimensions in the correct spot
         * otherwise the dimension order will be backwards
@@ -467,11 +468,11 @@ glsl_type::glsl_type(const glsl_type *array, unsigned 
length) :
        const char *pos = strchr(array->name, '[');
        if (pos) {
           int idx = pos - array->name;
-         snprintf(n, idx+1, "%s", array->name);
-         snprintf(n + idx, name_length - idx, "[%u]%s",
-                  length, array->name + idx);
+         util_snprintf(n, idx+1, "%s", array->name);
+         util_snprintf(n + idx, name_length - idx, "[%u]%s",
+                       length, array->name + idx);
        } else {
-         snprintf(n, name_length, "%s[%u]", array->name, length);
+         util_snprintf(n, name_length, "%s[%u]", array->name, length);
        }
     }
@@ -853,7 +854,7 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
      * named 'foo'.
      */
     char key[128];
-   snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
+   util_snprintf(key, sizeof(key), "%p[%u]", (void *) base, array_size);
mtx_lock(&glsl_type::hash_mutex);

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to