diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 4f3577e89..0dc93a8ed 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -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 : ""; } diff --git a/ivlpp/main.c b/ivlpp/main.c index f3433be08..7a8b4241d 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -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, diff --git a/main.cc b/main.cc index 1370d2cb6..ff5ee6f48 100644 --- a/main.cc +++ b/main.cc @@ -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::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::iterator flg = flags.begin() ; flg != flags.end() ; flg ++ ) { - free((char *)flg->second); + free((void *)flg->second); } flags.clear(); diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 2d6d0ed4a..acf2c215b 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -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), diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 248b3df80..cf3847614 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -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; diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index b3fc68e71..eeb8abfc1 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -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"; diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index 2bbaec015..5e12cc75d 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -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, diff --git a/vpi/lxt_write.c b/vpi/lxt_write.c index 3ed778cc5..9731363e9 100644 --- a/vpi/lxt_write.c +++ b/vpi/lxt_write.c @@ -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 */ } diff --git a/vpi/sys_display.c b/vpi/sys_display.c index bc7773033..b8b4a317b 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -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; diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index f6846e45b..a21af244f 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -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) { diff --git a/vpi/sys_priv.h b/vpi/sys_priv.h index 3a13d1851..d375a2ae9 100644 --- a/vpi/sys_priv.h +++ b/vpi/sys_priv.h @@ -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; diff --git a/vpi/sys_table.c b/vpi/sys_table.c index f7b1ad2be..637319e0f 100644 --- a/vpi/sys_table.c +++ b/vpi/sys_table.c @@ -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. */ diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 949ee3167..edcd2ee1d 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -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;