Fixed usage of string literals with non-const char pointers. trunk
authorRyan C. Gordon <icculus@icculus.org>
Thu, 03 Apr 2008 06:40:22 -0400
branchtrunk
changeset 65 aa0b9bb40df7
parent 64 4f4bd3c7eef6
child 66 64c37d56e19f
Fixed usage of string literals with non-const char pointers. Apparently gcc 4.2 starts to warn about that.
mojoshader.c
--- a/mojoshader.c	Thu Apr 03 06:06:02 2008 -0400
+++ b/mojoshader.c	Thu Apr 03 06:40:22 2008 -0400
@@ -672,10 +672,13 @@
 
 static char *make_D3D_destarg_string(Context *ctx, const int idx)
 {
+    char *retval = get_scratch_buffer(ctx);
+    *retval = '\0';  // truncate string to start.
+
     if (idx >= STATICARRAYLEN(ctx->dest_args))
     {
         fail(ctx, "Too many destination args");
-        return "";
+        return retval;
     } // if
 
     const DestArgInfo *arg = &ctx->dest_args[idx];
@@ -702,7 +705,7 @@
     if (regtype_str == NULL)
     {
         fail(ctx, "Unknown destination register type.");
-        return "";
+        return retval;
     } // if
 
     char writemask_str[6];
@@ -719,7 +722,6 @@
     assert(i < sizeof (writemask_str));
 
     // may turn out something like "_x2_sat_pp_centroid r0.xyzw" ...
-    char *retval = get_scratch_buffer(ctx);
     snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s%s%s %s%s%s",
              result_shift_str, sat_str, pp_str, cent_str,
              regtype_str, regnum_str, writemask_str);