diff --git a/src/frontend/dotcards.c b/src/frontend/dotcards.c index de7a7ee3c..15d1af3ac 100644 --- a/src/frontend/dotcards.c +++ b/src/frontend/dotcards.c @@ -633,7 +633,9 @@ gettoks(char *s) /* Transfer i(xx) to xxx#branch only when i is the first character of the token or preceeded by a space. */ - if ((*(l - 1) == 'i' || *(l - 1) == 'I') && (l - 1 == t) || ((l > t + 1) && isspace(*(l-2)))) { + if ((*(l - 1) == 'i' || + ((*(l - 1) == 'I') && (l - 1 == t))) || + ((l > t + 1) && isspace(*(l-2)))) { char buf[513]; sprintf(buf, "%s#branch", l + 1); wl->wl_word = copy(buf); diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 64acd47b3..8929897d9 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -606,18 +606,19 @@ static char *cat2strings(char *s1, char *s2, bool spa) else if (s1 == NULL || *s1 == '\0') { return copy(s2); } - size_t lges = strlen(s1) + strlen(s2) + 2; - char *nextstr; - char *strsum = TMALLOC(char, lges); + size_t l1 = strlen(s1); + size_t l2 = strlen(s2); + char *strsum = TMALLOC(char, l1 + l2 + 2); if (spa) { - nextstr = memccpy(strsum, s1, '\0', lges); - *(nextstr - 1) = ' '; - nextstr = memccpy(nextstr, s2, '\0', lges); + memcpy(strsum, s1, l1); + memcpy(strsum + l1 + 1, s2, l2); + strsum[l1] = ' '; + strsum[l1 + l2 + 1] = '\0'; } else { - nextstr = (char*)memccpy(strsum, s1, '\0', lges) - 1; - nextstr = (char*)memccpy(nextstr, s2, '\0', lges) - 1; - *nextstr = '\0'; + memcpy(strsum, s1, l1); + memcpy(strsum + l1, s2, l2); + strsum[l1 + l2] = '\0'; } return strsum; } diff --git a/src/frontend/udevices.c b/src/frontend/udevices.c index 14c9b0571..cadcd095e 100644 --- a/src/frontend/udevices.c +++ b/src/frontend/udevices.c @@ -262,6 +262,8 @@ static void clear_name_list(NAME_ENTRY nelist, char *msg) #ifdef TRACE printf("%s\n", msg); print_name_list(nelist); +#else + (void)msg; #endif for (x = nelist; x; x = next) { next = x->next; @@ -1505,7 +1507,7 @@ static struct instance_hdr *create_instance_header(char *line) return hdr; } -char *new_inverter(char *iname, char *node, Xlatorp xlp) +static char *new_inverter(char *iname, char *node, Xlatorp xlp) { /* Return the name of the output of the new inverter */ /* tfree the returned string after it has been used by the caller */ @@ -2469,7 +2471,7 @@ static void estimate_typ(struct timing_data *tdp) if (strlen(tmpmin) > 0 && strlen(tmpmax) > 0) { valmin = strtof(tmpmin, &units1); valmax = strtof(tmpmax, &units2); - average = (valmin + valmax) / (float)2.0; + average = (float)((valmin + valmax) / 2.0); tdp->ave = tprintf("%.2f%s", average, units2); if (!eq(units1, units2)) { printf("WARNING units do not match\n"); diff --git a/src/main.c b/src/main.c index fb019df77..7923c6201 100644 --- a/src/main.c +++ b/src/main.c @@ -810,7 +810,7 @@ int main(int argc, char **argv) bool qflag = FALSE; /* flag for command completion */ FILE * volatile circuit_file; - bool oflag = FALSE; + bool volatile oflag = FALSE; bool srflag = FALSE; #ifdef TRACE diff --git a/src/spicelib/parser/ptfuncs.c b/src/spicelib/parser/ptfuncs.c index a4ed04a3c..e0211e74c 100644 --- a/src/spicelib/parser/ptfuncs.c +++ b/src/spicelib/parser/ptfuncs.c @@ -4,7 +4,7 @@ Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group **********/ /* - * All the functions used in the parse tree. These functions return HUGE + * All the functions used in the B-source parse tree. These functions return HUGE * if their argument is out of range. */ diff --git a/src/xspice/cm/cm.c b/src/xspice/cm/cm.c index 0b9626bd6..61ba08819 100644 --- a/src/xspice/cm/cm.c +++ b/src/xspice/cm/cm.c @@ -430,10 +430,12 @@ int cm_analog_set_temp_bkpt( } /* If too close to a permanent breakpoint or the current time, discard it */ - if( (fabs(time - ckt->CKTbreaks[0]) < ckt->CKTminBreak) || - (fabs(time - ckt->CKTbreaks[1]) < ckt->CKTminBreak) || - (fabs(time - ckt->CKTtime) < ckt->CKTminBreak) ) + if ((ckt->CKTbreaks && + (fabs(time - ckt->CKTbreaks[0]) < ckt->CKTminBreak || + fabs(time - ckt->CKTbreaks[1]) < ckt->CKTminBreak)) || + fabs(time - ckt->CKTtime) < ckt->CKTminBreak) { return(MIF_OK); + } /* If < current dynamic breakpoint, make it the current breakpoint */ if( time < g_mif_info.breakpoint.current) diff --git a/src/xspice/cmpp/file_buffer.c b/src/xspice/cmpp/file_buffer.c index 27a9d10ff..0c2a084f1 100644 --- a/src/xspice/cmpp/file_buffer.c +++ b/src/xspice/cmpp/file_buffer.c @@ -482,7 +482,7 @@ static size_t fb_make_space_at_end(FILEBUF *p_fb) /* Shift data in use to the front of the buffer if not already */ if (p_dst != p_src) { /* object is not at start of buffer */ - const size_t n = p_fb->p_data_end - p_src; + const size_t n = (size_t)(p_fb->p_data_end - p_src); if (n > 0) { /* Will be 0 if skipping whitespace and comments */ (void) memmove(p_dst, p_src, n); } @@ -528,7 +528,7 @@ static size_t fb_make_space_at_end(FILEBUF *p_fb) } } - return p_fb->p_buf_end - p_fb->p_data_end; + return (size_t)(p_fb->p_buf_end - p_fb->p_data_end); } /* end of function fb_make_space_at_end */ @@ -689,7 +689,7 @@ static int fb_return_string(FILEBUF *p_fb, { const char *p_data_start = p_fbobj->str_value.sz = p_fb->p_obj_start; - p_fbobj->str_value.n_char = p_fb->p_obj_end - p_data_start; + p_fbobj->str_value.n_char = (size_t)(p_fb->p_obj_end - p_data_start); *p_type_found = BUF_TYPE_STRING; return 0; } /* end of function fb_return_string */ diff --git a/src/xspice/cmpp/pp_lst.c b/src/xspice/cmpp/pp_lst.c index 31946a825..1edaaf226 100644 --- a/src/xspice/cmpp/pp_lst.c +++ b/src/xspice/cmpp/pp_lst.c @@ -471,12 +471,12 @@ EXITPOINT: /* If error, free model info */ if (xrc != 0) { - free_model_info(n_model_info, p_model_info); + free_model_info((int)n_model_info, p_model_info); n_model_info = 0; p_model_info = (Model_Info_t *) NULL; } - *p_num_model_info = n_model_info; + *p_num_model_info = (int)n_model_info; *pp_model_info = p_model_info; return xrc; @@ -648,12 +648,12 @@ EXITPOINT: /* If error, free node info */ if (xrc != 0) { - free_node_info(n_node_info, p_node_info); + free_node_info((int)n_node_info, p_node_info); n_node_info = 0; p_node_info = (Node_Info_t *) NULL; } - *p_num_node_info = n_node_info; + *p_num_node_info = (int)n_node_info; *pp_node_info = p_node_info; return xrc; @@ -945,8 +945,8 @@ static int check_uniqueness( } /* Sizes of models and nodes */ - const unsigned int n_model = (unsigned int) numSPICEmodels + num_models; - const unsigned int n_node = (unsigned int) numUDNidentifiers + num_nodes; + const unsigned int n_model = (unsigned int)(numSPICEmodels + num_models); + const unsigned int n_node = (unsigned int)(numUDNidentifiers + num_nodes); const unsigned int n_ks = n_model > n_node ? n_model : n_node; /* Allocate structure to compare */ @@ -994,8 +994,8 @@ static int check_uniqueness( } /* Test for duplicates */ - f_have_duplicate |= test_for_duplicates(num_models, p_ks, - &report_error_function_name); + f_have_duplicate |= test_for_duplicates((unsigned int)num_models, + p_ks, &report_error_function_name); } } @@ -1588,14 +1588,14 @@ static int read_udn_type_name( c = fgetc(fp); if(c == '"') { found = true; - if (i >= sizeof name) { + if (i >= (int)sizeof name) { print_error("name too long"); exit(1); } name[i] = '\0'; } else if(c != EOF) { - if (i > sizeof name) { + if (i > (int)sizeof name) { print_error("name too long"); exit(1); } diff --git a/src/xspice/cmpp/writ_ifs.c b/src/xspice/cmpp/writ_ifs.c index e452e3f62..941abf4ef 100644 --- a/src/xspice/cmpp/writ_ifs.c +++ b/src/xspice/cmpp/writ_ifs.c @@ -1220,7 +1220,7 @@ static char *value_to_str(Data_Type_t type, Value_t value) str_len = (int) strlen(value.svalue); if ((str_len + BASE_STR_LEN) > max_len) { int n_byte_alloc = max_len + str_len + 1; - void * const p = realloc(str, n_byte_alloc); + void * const p = realloc(str, (size_t)n_byte_alloc); if (p == NULL) { (void) fprintf(stderr, "Unable to resize string buffer to size %d.\n",