summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorVinson Lee <[email protected]>2010-05-01 22:01:28 -0700
committerVinson Lee <[email protected]>2010-05-01 22:01:28 -0700
commitf4874705d95adfc85be535b85c9db26f5d3746f7 (patch)
tree60b5bad92d517b27aa54c7a9deeb32f2a3f2dd60 /src/mesa/shader/slang
parent9446fd8f69564e09ffd0f28735a99c510f84bb62 (diff)
glsl: s/sprintf/_mesa_snprintf/
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c2
-rw-r--r--src/mesa/shader/slang/slang_emit.c31
-rw-r--r--src/mesa/shader/slang/slang_ir.c8
-rw-r--r--src/mesa/shader/slang/slang_label.c2
-rw-r--r--src/mesa/shader/slang/slang_link.c5
-rw-r--r--src/mesa/shader/slang/slang_print.c8
-rw-r--r--src/mesa/shader/slang/slang_utility.c2
7 files changed, 29 insertions, 29 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index fa79632c18b..27ac1da9ad8 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1560,7 +1560,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
char name[200];
prevFuncEndLabel = A->curFuncEndLabel;
- sprintf(name, "__endOfFunc_%s_", (char *) fun->header.a_name);
+ _mesa_snprintf(name, sizeof(name), "__endOfFunc_%s_", (char *) fun->header.a_name);
A->curFuncEndLabel = _slang_label_new(name);
assert(A->curFuncEndLabel);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 7c0ea0c1148..974c4a31315 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -652,30 +652,30 @@ storage_annotation(const slang_ir_node *n, const struct gl_program *prog)
if (st->Index >= 0) {
const GLfloat *val = prog->Parameters->ParameterValues[st->Index];
if (st->Swizzle == SWIZZLE_NOOP)
- sprintf(s, "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
+ _mesa_snprintf(s, sizeof(s), "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
else {
- sprintf(s, "%g", val[GET_SWZ(st->Swizzle, 0)]);
+ _mesa_snprintf(s, sizeof(s), "%g", val[GET_SWZ(st->Swizzle, 0)]);
}
}
break;
case PROGRAM_TEMPORARY:
if (n->Var)
- sprintf(s, "%s", (char *) n->Var->a_name);
+ _mesa_snprintf(s, sizeof(s), "%s", (char *) n->Var->a_name);
else
- sprintf(s, "t[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "t[%d]", st->Index);
break;
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
- sprintf(s, "%s", prog->Parameters->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Parameters->Parameters[st->Index].Name);
break;
case PROGRAM_VARYING:
- sprintf(s, "%s", prog->Varying->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Varying->Parameters[st->Index].Name);
break;
case PROGRAM_INPUT:
- sprintf(s, "input[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "input[%d]", st->Index);
break;
case PROGRAM_OUTPUT:
- sprintf(s, "output[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "output[%d]", st->Index);
break;
default:
s[0] = 0;
@@ -752,9 +752,8 @@ instruction_annotation(gl_inst_opcode opcode, char *dstAnnot,
}
s = (char *) malloc(len);
- sprintf(s, "%s = %s %s %s %s", dstAnnot,
- srcAnnot0, operator, srcAnnot1, srcAnnot2);
- assert(strlen(s) < len);
+ _mesa_snprintf(s, len, "%s = %s %s %s %s", dstAnnot,
+ srcAnnot0, operator, srcAnnot1, srcAnnot2);
free(dstAnnot);
free(srcAnnot0);
@@ -2274,11 +2273,11 @@ emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n)
if (emitInfo->EmitComments) {
/* emit NOP with comment describing the variable's storage location */
char s[1000];
- sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
- n->Store->Index,
- _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
- (n->Var ? (char *) n->Var->a_name : "anonymous"),
- n->Store->Size);
+ _mesa_snprintf(s, sizeof(s), "TEMP[%d]%s = variable %s (size %d)",
+ n->Store->Index,
+ _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
+ (n->Var ? (char *) n->Var->a_name : "anonymous"),
+ n->Store->Size);
emit_comment(emitInfo, s);
}
return NULL;
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 62603503dd9..c223004b22b 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -340,13 +340,13 @@ storage_string(const slang_ir_storage *st)
assert(Elements(files) == PROGRAM_FILE_MAX);
#if 0
if (st->Size == 1)
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, "%s[%d]", files[st->File], st->Index);
else
- sprintf(s, "%s[%d..%d]", files[st->File], st->Index,
- st->Index + st->Size - 1);
+ _mesa_snprintf(s, "%s[%d..%d]", files[st->File], st->Index,
+ st->Index + st->Size - 1);
#endif
assert(st->File < (GLint) (sizeof(files) / sizeof(files[0])));
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, sizeof(s), "%s[%d]", files[st->File], st->Index);
return s;
}
diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c
index 225612a9369..8e3a8ebc1aa 100644
--- a/src/mesa/shader/slang/slang_label.c
+++ b/src/mesa/shader/slang/slang_label.c
@@ -37,7 +37,7 @@ _slang_label_new_unique(const char *name)
free(l);
return NULL;
}
- sprintf(l->Name, "%s_%d", name, id);
+ _mesa_snprintf(l->Name, strlen(name) + 10, "%s_%d", name, id);
id++;
l->Location = -1;
}
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 47bc9339716..b16778f8ad4 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -370,8 +370,9 @@ link_uniform_vars(GLcontext *ctx,
GLuint newSampNum = *numSamplers;
if (newSampNum >= ctx->Const.MaxTextureImageUnits) {
char s[100];
- sprintf(s, "Too many texture samplers (%u, max is %u)",
- newSampNum, ctx->Const.MaxTextureImageUnits);
+ _mesa_snprintf(s, sizeof(s),
+ "Too many texture samplers (%u, max is %u)",
+ newSampNum, ctx->Const.MaxTextureImageUnits);
link_error(shProg, s);
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c
index 3c75523c42f..6b34f395fdf 100644
--- a/src/mesa/shader/slang/slang_print.c
+++ b/src/mesa/shader/slang/slang_print.c
@@ -813,7 +813,7 @@ static const char *
slang_fq_type_string(const slang_fully_specified_type *t)
{
static char str[1000];
- sprintf(str, "%s %s", slang_type_qual_string(t->qualifier),
+ _mesa_snprintf(str, sizeof(str), "%s %s", slang_type_qual_string(t->qualifier),
slang_type_string(t->specifier.type));
return str;
}
@@ -832,9 +832,9 @@ static char *
slang_var_string(const slang_variable *v)
{
static char str[1000];
- sprintf(str, "%s : %s",
- (char *) v->a_name,
- slang_fq_type_string(&v->type));
+ _mesa_snprintf(str, sizeof(str), "%s : %s",
+ (char *) v->a_name,
+ slang_fq_type_string(&v->type));
return str;
}
#endif
diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c
index e77404f6928..c1d57409a43 100644
--- a/src/mesa/shader/slang/slang_utility.c
+++ b/src/mesa/shader/slang/slang_utility.c
@@ -120,7 +120,7 @@ slang_string_pushi (slang_string *self, GLint i)
{
char buffer[12];
- sprintf (buffer, "%d", i);
+ _mesa_snprintf (buffer, sizeof(buffer), "%d", i);
slang_string_pushs (self, buffer, strlen (buffer));
}