Down payment on const-correctness

Clears out the unambiguous and easy-to-fix const faults,
so we can focus better on the fundamental ones.
This commit is contained in:
Larry Doolittle 2010-09-27 11:03:43 -07:00 committed by Stephen Williams
parent 72f1e5a692
commit 6388430661
13 changed files with 31 additions and 29 deletions

View File

@ -44,7 +44,7 @@ static void macro_start_args();
static void macro_add_to_arg();
static void macro_finish_arg();
static void do_expand(int use_args);
static char* macro_name();
static const char* macro_name();
static void include_filename();
static void do_include();
@ -1201,7 +1201,7 @@ static int macro_needs_args(const char*text)
}
}
static char* macro_name()
static const char* macro_name()
{
return cur_macro ? cur_macro->name : "";
}

View File

@ -126,12 +126,13 @@ static int flist_read_flags(const char*path)
if (strcmp(cp,"D") == 0) {
char*val = strchr(arg, '=');
if (val)
const char *valo = "1";
if (val) {
*val++ = 0;
else
val = "1";
valo = val;
}
define_macro(arg, val, 0, 0);
define_macro(arg, valo, 0, 0);
} else if (strcmp(cp,"I") == 0) {
include_dir = realloc(include_dir,

10
main.cc
View File

@ -543,7 +543,7 @@ static void read_iconfig_file(const char*ipath)
}
if (strcmp(buf, "basedir") == 0) {
free((char *)basedir);
free((void *)basedir);
basedir = strdup(cp);
} else if (strcmp(buf, "debug") == 0) {
@ -620,7 +620,7 @@ static void read_iconfig_file(const char*ipath)
flags["VPI_MODULE_LIST"] = vpi_module_list;
} else if (strcmp(buf, "out") == 0) {
free((char *)flags["-o"]);
free((void *)flags["-o"]);
flags["-o"] = strdup(cp);
} else if (strcmp(buf, "sys_func") == 0) {
@ -732,17 +732,17 @@ static void EOC_cleanup(void)
for (list<const char*>::iterator suf = library_suff.begin() ;
suf != library_suff.end() ; suf ++ ) {
free((char *)*suf);
free((void *)*suf);
}
library_suff.clear();
free((char *) basedir);
free((void *) basedir);
free(ivlpp_string);
free(depfile_name);
for (map<string, const char*>::iterator flg = flags.begin() ;
flg != flags.end() ; flg ++ ) {
free((char *)flg->second);
free((void *)flg->second);
}
flags.clear();

View File

@ -1533,7 +1533,7 @@ static void show_logic(ivl_net_logic_t net)
static int show_scope(ivl_scope_t net, void*x)
{
unsigned idx;
char *is_auto;
const char *is_auto;
fprintf(out, "scope: %s (%u parameters, %u signals, %u logic)",
ivl_scope_name(net), ivl_scope_params(net),

View File

@ -219,7 +219,7 @@ static void eval_logic_into_integer(ivl_expr_t expr, unsigned ix)
unsigned word = 0;
if (ivl_signal_dimensions(sig) > 0) {
ivl_expr_t ixe;
char*type = ivl_expr_signed(expr) ? "/s" : "";
const char*type = ivl_expr_signed(expr) ? "/s" : "";
/* Detect the special case that this is a
variable array. In this case, the ix/getv
@ -246,7 +246,7 @@ static void eval_logic_into_integer(ivl_expr_t expr, unsigned ix)
break;
}
}
char*type = ivl_signal_signed(sig) ? "/s" : "";
const char*type = ivl_signal_signed(sig) ? "/s" : "";
fprintf(vvp_out, " %%ix/getv%s %u, v%p_%u;\n", type, ix,
sig, word);
break;

View File

@ -459,7 +459,7 @@ static int draw_unary_real(ivl_expr_t expr)
if (ivl_expr_opcode(expr) == 'r') { /* Cast an integer value to a real. */
struct vector_info res;
char *suffix = "";
const char *suffix = "";
assert(ivl_expr_value(sube) != IVL_VT_REAL);
res = draw_eval_expr(sube, 1);
if (ivl_expr_signed(sube)) suffix = "/s";

View File

@ -772,7 +772,7 @@ static int show_stmt_assign_nb(ivl_statement_t net)
if (cnt) {
int count_index = allocate_word();
char*type = ivl_expr_signed(cnt) ? "/s" : "";
const char*type = ivl_expr_signed(cnt) ? "/s" : "";
draw_eval_expr_into_integer(cnt, count_index);
fprintf(vvp_out, " %%evctl%s %s, %d;\n", type, name,
count_index);
@ -1683,7 +1683,7 @@ static int show_stmt_repeat(ivl_statement_t net, ivl_scope_t sscope)
unsigned lab_top = local_count++, lab_out = local_count++;
ivl_expr_t expr = ivl_stmt_cond_expr(net);
struct vector_info cnt = draw_eval_expr(expr, 0);
char *sign = ivl_expr_signed(expr) ? "s" : "u";
const char *sign = ivl_expr_signed(expr) ? "s" : "u";
/* Test that 0 < expr */
fprintf(vvp_out, "T_%u.%u %%cmp/%s 0, %u, %u;\n", thread_count,

View File

@ -996,8 +996,8 @@ if(rgh) lt_recurse_dictionary_free(lt, rgh);
static int lt_dictval_compare(const void *v1, const void *v2)
{
dslxt_Tree *s1 = *(dslxt_Tree **)v1;
dslxt_Tree *s2 = *(dslxt_Tree **)v2;
const dslxt_Tree *s1 = *(const dslxt_Tree * const *)v1;
const dslxt_Tree *s2 = *(const dslxt_Tree * const *)v2;
if(s1->val > s2->val) return(1); else return(-1); /* they're *never* equal */
}

View File

@ -878,6 +878,7 @@ static unsigned int get_numeric(char **rtn, struct strobe_cb_info *info,
static char *get_display(unsigned int *rtnsz, struct strobe_cb_info *info)
{
char *result, *fmt, *rtn, *func_name;
const char *cresult;
s_vpi_value value;
unsigned int idx, size, width;
char buf[256];
@ -998,10 +999,10 @@ static char *get_display(unsigned int *rtnsz, struct strobe_cb_info *info)
vpi_printf("WARNING: %s:%d: unknown argument type (%s) given to %s!\n",
info->filename, info->lineno, vpi_get_str(vpiType, item),
info->name);
result = "<?>";
width = strlen(result);
cresult = "<?>";
width = strlen(cresult);
rtn = realloc(rtn, (size+width)*sizeof(char));
memcpy(rtn+size-1, result, width);
memcpy(rtn+size-1, cresult, width);
break;
}
size += width;
@ -1755,9 +1756,9 @@ static PLI_INT32 sys_timeformat_calltf(PLI_BYTE8*xx)
return 0;
}
static char *pts_convert(int value)
static const char *pts_convert(int value)
{
char *string;
const char *string;
switch (value) {
case 0: string = "1s"; break;
case -1: string = "100ms"; break;

View File

@ -102,7 +102,7 @@ char *get_filename(vpiHandle callh, char *name, vpiHandle file)
}
void check_for_extra_args(vpiHandle argv, vpiHandle callh, char *name,
char *arg_str, unsigned opt)
const char *arg_str, unsigned opt)
{
/* Check that there are no extra arguments. */
if (vpi_scan(argv) != 0) {

View File

@ -38,8 +38,8 @@ extern PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec);
extern char *as_escaped(char *arg);
extern char *get_filename(vpiHandle callh, char *name, vpiHandle file);
extern void check_for_extra_args(vpiHandle argv, vpiHandle callh,
char *name, char *arg_str, unsigned opt);
extern void check_for_extra_args(vpiHandle argv, vpiHandle callh, char *name,
const char *arg_str, unsigned opt);
struct timeformat_info_s {
int units;

View File

@ -59,7 +59,7 @@ static void sys_lxt_or_vcd_register()
int idx;
struct t_vpi_vlog_info vlog_info;
char*dumper;
const char*dumper;
/* Get the dumper of choice from the IVERILOG_DUMPER
environment variable. */

View File

@ -708,7 +708,7 @@ static int draw_scope(vpiHandle item, vpiHandle callh)
{
int depth;
const char *name;
char *type;
const char *type;
vpiHandle scope = vpi_handle(vpiScope, item);
if (!scope) return 0;