Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Better const char * correction.
--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 3, 2008
1 parent c27e2c9 commit ef5433f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions mojoshader.c
Expand Up @@ -673,15 +673,12 @@ static const char *get_D3D_register_string(Context *ctx,
#define AT_LEAST_ONE_PROFILE 1
#define PROFILE_EMITTER_D3D(op) emit_D3D_##op,

static char *make_D3D_destarg_string(Context *ctx, const int idx)
static const 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 retval;
return "";
} // if

const DestArgInfo *arg = &ctx->dest_args[idx];
Expand All @@ -708,7 +705,7 @@ static char *make_D3D_destarg_string(Context *ctx, const int idx)
if (regtype_str == NULL)
{
fail(ctx, "Unknown destination register type.");
return retval;
return "";
} // if

char writemask_str[6];
Expand All @@ -725,6 +722,7 @@ static char *make_D3D_destarg_string(Context *ctx, const int idx)
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);
Expand All @@ -733,15 +731,12 @@ static char *make_D3D_destarg_string(Context *ctx, const int idx)
} // make_D3D_destarg_string


static char *make_D3D_sourcearg_string(Context *ctx, const int idx)
static const char *make_D3D_sourcearg_string(Context *ctx, const int idx)
{
char *retval = get_scratch_buffer(ctx);
*retval = '\0'; // truncate string to start.

if (idx >= STATICARRAYLEN(ctx->source_args))
{
fail(ctx, "Too many source args");
return retval;
return "";
} // if

const SourceArgInfo *arg = &ctx->source_args[idx];
Expand Down Expand Up @@ -812,7 +807,7 @@ static char *make_D3D_sourcearg_string(Context *ctx, const int idx)
if (regtype_str == NULL)
{
fail(ctx, "Unknown source register type.");
return retval;
return "";
} // if

char swizzle_str[6];
Expand All @@ -833,6 +828,7 @@ static char *make_D3D_sourcearg_string(Context *ctx, const int idx)
swizzle_str[i] = '\0';
assert(i < sizeof (swizzle_str));

char *retval = get_scratch_buffer(ctx);
snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s%s%s%s",
premod_str, regtype_str, regnum_str, postmod_str, swizzle_str);
// !!! FIXME: make sure the scratch buffer was large enough.
Expand Down

0 comments on commit ef5433f

Please sign in to comment.