Add error messages when controlled_exit is called:

No exit without message.
This commit is contained in:
Holger Vogt 2022-11-16 11:37:35 +01:00
parent 75c2a3c621
commit 59413a7f71
7 changed files with 23 additions and 7 deletions

View File

@ -44,6 +44,7 @@ canonical_name(const char *name, DSTRINGPTR dbuf_p,
f_ok &= ds_cat_mem(dbuf_p, sz_branch,
sizeof sz_branch / sizeof *sz_branch - 1) == DS_E_OK;
if (!f_ok) {
fprintf(stderr, "Error: DS could not convert %s\n", name);
controlled_exit(-1);
}
return ds_get_buf(dbuf_p);
@ -56,6 +57,7 @@ canonical_name(const char *name, DSTRINGPTR dbuf_p,
f_ok &= ds_cat_str(dbuf_p, name) == DS_E_OK;
f_ok &= ds_cat_char(dbuf_p, ')') == DS_E_OK;
if (!f_ok) {
fprintf(stderr, "Error: DS could not convert %s\n", name);
controlled_exit(-1);
}
return ds_get_buf(dbuf_p);
@ -68,6 +70,7 @@ canonical_name(const char *name, DSTRINGPTR dbuf_p,
* changing the original, but in the current use cases that is
* not an issue. */
if (ds_cat_str(dbuf_p, name) != DS_E_OK) {
fprintf(stderr, "Error: DS could not convert %s\n", name);
controlled_exit(-1);
}
return ds_get_buf(dbuf_p);

View File

@ -1273,6 +1273,7 @@ struct inp_read_t inp_read( FILE *fp, int call_depth, const char *dir_name,
strcat(buffer, "\n");
}
else { /* No good way to report this so just die */
fprintf(stderr, "Error: IPC status not o.k.\n");
controlled_exit(EXIT_FAILURE);
}
}
@ -1758,7 +1759,7 @@ static char *inp_pathresolve(const char *name)
name[2] == DIR_TERM_LINUX) {
DS_CREATE(ds, 100);
if (ds_cat_str(&ds, name) != 0) {
fprintf(stderr, "Unable to copy string while resolving path");
fprintf(stderr, "Error: Unable to copy string while resolving path");
controlled_exit(EXIT_FAILURE);
}
char *const buf = ds_get_buf(&ds);
@ -1821,7 +1822,7 @@ static char *inp_pathresolve(const char *name)
if (rc_ds != 0) { /* unable to build string */
(void) fprintf(cp_err,
"Unable to build path name in inp_pathresolve");
"Error: Unable to build path name in inp_pathresolve");
controlled_exit(EXIT_FAILURE);
}
@ -1873,7 +1874,7 @@ static char *inp_pathresolve_at(const char *name, const char *dir)
DS_CREATE(ds, 100);
if (ds_cat_printf(&ds, ".%c%s", DIR_TERM, name) != 0) {
(void) fprintf(cp_err,
"Unable to build \".\" path name in inp_pathresolve_at");
"Error: Unable to build \".\" path name in inp_pathresolve_at");
controlled_exit(EXIT_FAILURE);
}
char * const r = inp_pathresolve(ds_get_buf(&ds));
@ -1901,7 +1902,7 @@ static char *inp_pathresolve_at(const char *name, const char *dir)
rc_ds |= ds_cat_str(&ds, name); /* append the file name */
if (rc_ds != 0) {
(void) fprintf(cp_err, "Unable to build \"dir\" path name "
(void) fprintf(cp_err, "Error: Unable to build \"dir\" path name "
"in inp_pathresolve_at");
controlled_exit(EXIT_FAILURE);
}
@ -3051,7 +3052,7 @@ static void inp_change_quotes(char *s)
static void add_name(struct names *p, char *name)
{
if (p->num_names >= N_SUBCKT_W_PARAMS) {
fprintf(stderr, "ERROR, N_SUBCKT_W_PARMS overflow\n");
fprintf(stderr, "ERROR: N_SUBCKT_W_PARMS overflow, more than %d subcircuits\n", N_SUBCKT_W_PARAMS);
controlled_exit(EXIT_FAILURE);
}
@ -3748,7 +3749,7 @@ static void free_function(struct function *fcn)
static void new_function_parameter(struct function *fcn, char *parameter)
{
if (fcn->num_parameters >= N_PARAMS) {
fprintf(stderr, "ERROR, N_PARAMS overflow\n");
fprintf(stderr, "ERROR, N_PARAMS overflow, more than %d parameters\n", N_PARAMS);
controlled_exit(EXIT_FAILURE);
}
@ -4926,6 +4927,7 @@ static struct card *inp_reorder_params_subckt(
}
/* the terminating `.ends' deck wasn't found */
fprintf(stderr, "Error: Missing .ends statement\n");
controlled_exit(EXIT_FAILURE);
}
@ -10091,7 +10093,7 @@ struct nscope *inp_add_levels(struct card *deck)
}
else if (ciprefix(".ends", curr_line)) {
if (lvl == root) {
fprintf(stderr, ".subckt/.ends not balanced\n");
fprintf(stderr, "Error: .subckt/.ends not balanced\n");
controlled_exit(1);
}
card->level = lvl;

View File

@ -74,6 +74,7 @@ void
sadd(DSTRINGPTR dstr_p, const char *t)
{
if (ds_cat_str(dstr_p, t) != DS_E_OK) {
fprintf(stderr, "Error: DS could not add string %s\n", t);
controlled_exit(-1);
}
}
@ -86,6 +87,7 @@ void
cadd(DSTRINGPTR dstr_p, char c)
{
if (ds_cat_char(dstr_p, c) != DS_E_OK) {
fprintf(stderr, "Error: DS could not add character %c\n", c);
controlled_exit(-1);
}
}
@ -100,6 +102,7 @@ scopyd(DSTRINGPTR dst, const DSTRINGPTR src) /* returns success flag */
{
ds_clear(dst);
if (ds_cat_ds(dst, src) != DS_E_OK) {
fprintf(stderr, "Error: DS could not copy string\n");
controlled_exit(-1);
}
}
@ -114,6 +117,7 @@ scopys(DSTRINGPTR s, const char *t) /* returns success flag */
{
ds_clear(s);
if (ds_cat_str(s, t) != DS_E_OK) {
fprintf(stderr, "Error: DS could not copy string %s\n", t);
controlled_exit(-1);
}
}
@ -129,6 +133,7 @@ pscopy(DSTRINGPTR dstr_p, const char *t, const char *stop)
ds_clear(dstr_p);
if (ds_cat_mem(dstr_p, t, (size_t) (stop - t)) != DS_E_OK) {
fprintf(stderr, "Error: DS could not copy partially string %s\n", t);
controlled_exit(-1);
}

View File

@ -336,6 +336,7 @@ dicostack_pop(dico_t *dico)
ds_clear(&param_name);
if (ds_cat_printf(&param_name, "%s.%s",
inst_name, entry->symbol) != DS_E_OK) {
fprintf(stderr, "Error: DS could not add string %s\n", inst_name);
controlled_exit(-1);
}
nupa_add_inst_param(ds_get_buf(&param_name), entry->vl);

View File

@ -69,6 +69,7 @@ static void vec_rebuild_lookup_table(struct plot *pl)
for (d = pl->pl_dvecs; d; d = d->v_next) {
ds_clear(&dbuf);
if (ds_cat_str_case(&dbuf, d->v_name, ds_case_lower) != DS_E_OK) {
fprintf(stderr, "Error: DS could not add string %s\n", d->v_name);
controlled_exit(-1);
}
char * const lower_name = ds_get_buf(&dbuf);
@ -181,6 +182,7 @@ static struct dvec *findvec(char *word, struct plot *pl)
DS_CREATE(dbuf, 200); /* make dynamic buffer */
if (ds_cat_str_case(&dbuf, word, ds_case_lower) != DS_E_OK) {
fprintf(stderr, "Error: DS could not add string %s\n", word);
controlled_exit(-1);
}
char * const lower_name = ds_get_buf(&dbuf);
@ -197,6 +199,7 @@ static struct dvec *findvec(char *word, struct plot *pl)
ds_case_lower) == DS_E_OK;
f_ok &= ds_cat_char(&dbuf, ')') == DS_E_OK;
if (!f_ok) {
fprintf(stderr, "Error: DS could not add string V() around %s\n", word);
controlled_exit(-1);
}
char * const node_name = ds_get_buf(&dbuf);

View File

@ -110,6 +110,7 @@ char *tvprintf(const char *fmt, va_list args)
* memory was exhausted) with the old behavior */
if (nchars < 0) {
fprintf(stderr, "Error: tvprintf failed\n");
controlled_exit(-1);
}

View File

@ -296,6 +296,7 @@ copy_tx(TXLine *new, TXLine *old)
new->ifImg = old->ifImg;
if (new->vi_tail != old->vi_tail) {
/* someting wrong */
fprintf(stderr, "Error during evaluating TXL line\n");
controlled_exit(0);
}