Compiler suggested cleanups - mostly const fixups

This commit is contained in:
Mark Pizzolato 2014-10-26 17:06:24 -07:00
parent 5c45aec68f
commit 2e1167d4a0
12 changed files with 63 additions and 53 deletions

View file

@ -7168,7 +7168,7 @@ static t_stat sim_load_m68k(FILE *fileref, char *cptr, char *fnam, int flag) {
int32 i;
t_addr j, lo, hi;
uint32 addr, org, cnt = 0;
char* result;
const char* result;
if (flag ) {
result = get_range(NULL, cptr, &lo, &hi, 16, M68K_MAX_RAM, 0);
if (result == NULL)
@ -7202,7 +7202,7 @@ t_stat sim_load(FILE *fileref, char *cptr, char *fnam, int flag) {
int32 i;
uint32 addr, cnt = 0, org, pagesModified = 0, makeROM = FALSE;
t_addr j, lo, hi;
char *result;
const char *result;
MDEV m;
char gbuf[CBUFSIZE];
if (chiptype == CHIP_TYPE_M68K)

View file

@ -345,7 +345,7 @@ static uint8 load_rom[] = {
t_stat pt_dump (FILE *of, char *cptr, char *fnam)
{
uint32 i, lo, hi, cs;
char *tptr;
const char *tptr;
extern DEVICE cpu_dev;
if ((cptr == NULL) || (*cptr == 0))

View file

@ -239,14 +239,14 @@ t_addr ad, ea;
if ((dptr == sim_devices[0]) &&
((sim_switches & SWMASK ('T')) ||
((cpu_unit.flags & UNIT_TTSS_D) && !(sim_switches & SWMASK ('N'))))) {
ad = (t_addr) strtotv (cptr, tptr, 10);
ad = (t_addr) strtotv (cptr, (const char **)tptr, 10);
if (((ad / 100) >= NTK_30) || ((ad % 100) >= NSC_30)) {
*tptr = cptr;
return 0;
}
ea = ((ad / 100) * NSC_30) | (ad % 100);
}
else ea = (t_addr) strtotv (cptr, tptr, dptr->aradix);
else ea = (t_addr) strtotv (cptr, (const char **)tptr, dptr->aradix);
return ea;
}

View file

@ -781,7 +781,7 @@ t_value get_opnd (char *cptr, t_stat *status)
{
int32 sign = 0;
t_value val, xr = 0, ind = 0;
char *tptr;
const char *tptr;
*status = SCPE_ARG; /* assume fail */
if (*cptr == '@') {
@ -799,14 +799,14 @@ if (val > 0777777)
return 0;
if (sign)
val = (~val + 1) & 0777777;
cptr = tptr;
cptr = (char *)tptr;
if (*cptr == '(') {
cptr++;
xr = strtotv (cptr, &tptr, 8);
if ((cptr == tptr) || (*tptr != ')') ||
(xr > AC_NUM) || (xr == 0))
return 0;
cptr = ++tptr;
cptr = (char *)++tptr;
}
if (*cptr == 0)
*status = SCPE_OK;

View file

@ -1211,7 +1211,7 @@ cpu_get_switches(void)
t_stat sim_load(FILE *fileref, char *cptr, char *fnam, int flag) {
uint32 word;
t_addr j, lo, hi, sz, sz_words;
char *result;
const char *result;
if (flag) { /* Dump to file. */
result = get_range(NULL, cptr, &lo, &hi, 8, 0xFFFF, 0);

View file

@ -1434,7 +1434,7 @@ for (i = 15; i >= 0; i--) { /* chk named reg */
}
if (*cptr++ != 'R') /* look for R */
return NULL;
regnum = strtotv (cptr, &tptr, 10); /* look for reg # */
regnum = strtotv (cptr, (const char **)&tptr, 10); /* look for reg # */
if ((cptr == tptr) || (regnum > 15))
return NULL;
*rn = (int32) regnum;

51
scp.c
View file

@ -406,14 +406,13 @@ char *get_sim_sw (char *cptr);
t_stat get_aval (t_addr addr, DEVICE *dptr, UNIT *uptr);
t_value get_rval (REG *rptr, uint32 idx);
void put_rval (REG *rptr, uint32 idx, t_value val);
t_value strtotv (const char *inptr, char **endptr, uint32 radix);
void fprint_help (FILE *st);
void fprint_stopped (FILE *st, t_stat r);
void fprint_capac (FILE *st, DEVICE *dptr, UNIT *uptr);
void fprint_sep (FILE *st, int32 *tokens);
char *read_line (char *ptr, int32 size, FILE *stream);
char *read_line_p (char *prompt, char *ptr, int32 size, FILE *stream);
REG *find_reg_glob (char *ptr, char **optr, DEVICE **gdptr);
char *read_line_p (const char *prompt, char *ptr, int32 size, FILE *stream);
REG *find_reg_glob (const char *ptr, const char **optr, DEVICE **gdptr);
char *sim_trim_endspc (char *cptr);
/* Forward references */
@ -2088,7 +2087,7 @@ t_bool found = FALSE;
t_bool all_unique = TRUE;
size_t max_namelen = 0;
DEVICE *tdptr;
char *tptr;
const char *tptr;
char *namebuf;
char rangebuf[32];
@ -3095,7 +3094,8 @@ return 1;
*/
t_stat assert_cmd (int32 flag, char *cptr)
{
char gbuf[CBUFSIZE], *gptr, *tptr, gbuf2[CBUFSIZE];
char gbuf[CBUFSIZE], gbuf2[CBUFSIZE];
const char *tptr, *gptr;
REG *rptr;
uint32 idx;
t_value val;
@ -3110,7 +3110,7 @@ if (*cptr == 0) /* must be more */
tptr = get_glyph (cptr, gbuf, 0); /* get token */
if (!strcmp (gbuf, "NOT")) { /* Conditional Inversion? */
not = TRUE; /* remember that, and */
cptr = tptr;
cptr = (char *)tptr;
}
if (*cptr == '"') { /* quoted string comparison? */
char op[CBUFSIZE];
@ -4771,7 +4771,8 @@ return ssh_break (NULL, cptr, flg); /* call common code */
t_stat ssh_break (FILE *st, char *cptr, int32 flg)
{
char gbuf[CBUFSIZE], *tptr, *t1ptr, *aptr;
char gbuf[CBUFSIZE], *aptr;
const char *tptr, *t1ptr;
DEVICE *dptr = sim_dflt_dev;
UNIT *uptr = dptr->units;
t_stat r;
@ -5709,7 +5710,8 @@ return r;
t_stat run_cmd (int32 flag, char *cptr)
{
char *tptr, gbuf[CBUFSIZE];
char gbuf[CBUFSIZE];
const char *tptr;
uint32 i, j;
int32 sim_next;
int32 unitno;
@ -5726,7 +5728,7 @@ if ((flag == RU_RUN) || (flag == RU_GO)) { /* run or go */
if (*cptr != 0) /* should be end */
return SCPE_2MARG;
if (sim_vm_parse_addr) /* address parser? */
pcv = sim_vm_parse_addr (sim_dflt_dev, gbuf, &tptr);
pcv = sim_vm_parse_addr (sim_dflt_dev, gbuf, (char **)&tptr);
else pcv = strtotv (gbuf, &tptr, sim_PC->radix);/* parse PC */
if ((tptr == gbuf) || (*tptr != 0) || /* error? */
(pcv > width_mask[sim_PC->width]))
@ -6057,7 +6059,9 @@ return;
t_stat exdep_cmd (int32 flag, char *cptr)
{
char gbuf[CBUFSIZE], *gptr, *tptr = NULL;
char gbuf[CBUFSIZE];
const char *gptr;
const char *tptr = NULL;
int32 opt;
t_addr low, high;
t_stat reason;
@ -6693,7 +6697,7 @@ return read_line_p (NULL, cptr, size, stream);
NULL if EOF
*/
char *read_line_p (char *prompt, char *cptr, int32 size, FILE *stream)
char *read_line_p (const char *prompt, char *cptr, int32 size, FILE *stream)
{
char *tptr;
#if defined(HAVE_DLOPEN)
@ -6896,7 +6900,7 @@ return FALSE;
t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status)
{
t_value val;
char *tptr;
const char *tptr;
*status = SCPE_OK;
val = strtotv (cptr, &tptr, radix);
@ -6925,10 +6929,10 @@ return val;
NULL if error
*/
char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi,
const char *get_range (DEVICE *dptr, const char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term)
{
char *tptr;
const char *tptr;
if (max && strncmp (cptr, "ALL", strlen ("ALL")) == 0) { /* ALL? */
tptr = cptr + strlen ("ALL");
@ -6937,14 +6941,14 @@ if (max && strncmp (cptr, "ALL", strlen ("ALL")) == 0) { /* ALL? */
}
else {
if (dptr && sim_vm_parse_addr) /* get low */
*lo = sim_vm_parse_addr (dptr, cptr, &tptr);
*lo = sim_vm_parse_addr (dptr, (char *)cptr, (char **)&tptr);
else *lo = (t_addr) strtotv (cptr, &tptr, rdx);
if (cptr == tptr) /* error? */
return NULL;
if ((*tptr == '-') || (*tptr == ':')) { /* range? */
cptr = tptr + 1;
if (dptr && sim_vm_parse_addr) /* get high */
*hi = sim_vm_parse_addr (dptr, cptr, &tptr);
*hi = sim_vm_parse_addr (dptr, (char *)cptr, (char **)&tptr);
else *hi = (t_addr) strtotv (cptr, &tptr, rdx);
if (cptr == tptr)
return NULL;
@ -7346,7 +7350,7 @@ return (dptr->flags & DEV_DIS? TRUE: FALSE);
*gdptr = pointer to device where found
*/
REG *find_reg_glob (char *cptr, char **optr, DEVICE **gdptr)
REG *find_reg_glob (const char *cptr, const char **optr, DEVICE **gdptr)
{
int32 i;
DEVICE *dptr;
@ -7569,7 +7573,7 @@ SCHTAB *get_search (char *cptr, int32 radix, SCHTAB *schptr)
int32 c, logop, cmpop;
t_value logval, cmpval;
const char *sptr;
char *tptr;
const char *tptr;
const char logstr[] = "|&^", cmpstr[] = "=!><";
logval = cmpval = 0;
@ -7581,7 +7585,7 @@ for (logop = cmpop = -1; (c = *cptr++); ) { /* loop thru clauses */
logval = strtotv (cptr, &tptr, radix);
if (cptr == tptr)
return NULL;
cptr = tptr;
cptr = (char *)tptr;
}
else if ((sptr = strchr (cmpstr, c))) { /* check for boolop */
cmpop = (int32)(sptr - cmpstr);
@ -7592,7 +7596,7 @@ for (logop = cmpop = -1; (c = *cptr++); ) { /* loop thru clauses */
cmpval = strtotv (cptr, &tptr, radix);
if (cptr == tptr)
return NULL;
cptr = tptr;
cptr = (char *)tptr;
}
else return NULL;
} /* end for */
@ -7673,7 +7677,7 @@ return 0;
On an error, the endptr will equal the inptr.
*/
t_value strtotv (const char *inptr, char **endptr, uint32 radix)
t_value strtotv (const char *inptr, const char **endptr, uint32 radix)
{
int32 nodigit;
t_value val;
@ -8533,7 +8537,8 @@ return SCPE_OK;
t_stat sim_set_expect (EXPECT *exp, char *cptr)
{
char gbuf[CBUFSIZE], *gptr = gbuf, *tptr, *c1ptr;
char gbuf[CBUFSIZE], *gptr = gbuf, *tptr;
const char *c1ptr;
uint32 after = exp->after;
int32 cnt = 0;
t_stat r;
@ -8546,7 +8551,7 @@ if (*cptr == '[') {
sim_printf ("Invalid Repeat count specification\n");
return SCPE_ARG|SCPE_NOMESSAGE;
}
cptr = c1ptr + 1;
cptr = (char *)(c1ptr + 1);
while (isspace(*cptr))
++cptr;
}

4
scp.h
View file

@ -130,12 +130,12 @@ char *get_glyph (const char *iptr, char *optr, char mchar);
char *get_glyph_nc (const char *iptr, char *optr, char mchar);
char *get_glyph_quoted (const char *iptr, char *optr, char mchar);
t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status);
char *get_range (DEVICE *dptr, char *cptr, t_addr *lo, t_addr *hi,
const char *get_range (DEVICE *dptr, const char *cptr, t_addr *lo, t_addr *hi,
uint32 rdx, t_addr max, char term);
t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
char *sim_encode_quoted_string (const uint8 *iptr, uint32 size);
void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size);
t_value strtotv (const char *cptr, char **endptr, uint32 radix);
t_value strtotv (const char *cptr, const char **endptr, uint32 radix);
t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format);
char *read_line (char *cptr, int32 size, FILE *stream);

View file

@ -431,11 +431,12 @@ TMLN *lp;
if (*cptr != 0)
return SCPE_NOPARAM;
if (sim_rem_active_number >= 0)
if (sim_rem_active_number >= 0) {
if (sim_rem_master_mode && (sim_rem_active_number == 0))
fprintf (st, "Running from Master Mode Remote Console Connection\n");
else
fprintf (st, "Running from Remote Console Connection %d\n", sim_rem_active_number);
}
if (sim_rem_con_tmxr.lines > 1)
fprintf (st, "Remote Console Input Connections from %d sources are supported concurrently\n", sim_rem_con_tmxr.lines);
if (sim_rem_read_timeout)
@ -452,11 +453,12 @@ for (i=connections=0; i<sim_rem_con_tmxr.lines; i++) {
if (connections == 1)
fprintf (st, "Remote Console Connections:\n");
tmxr_fconns (st, lp, i);
if (sim_rem_read_timeouts[i] != sim_rem_read_timeout)
if (sim_rem_read_timeouts[i] != sim_rem_read_timeout) {
if (sim_rem_read_timeouts[i])
fprintf (st, "Remote Console Input on connection %d automatically continues after %d seconds\n", i, sim_rem_read_timeouts[i]);
else
fprintf (st, "Remote Console Input on connection %d does not continue automatically\n", i);
}
}
return SCPE_OK;
}
@ -1041,7 +1043,7 @@ sim_rem_buf_ptr = (int32 *)realloc (sim_rem_buf_ptr, sizeof(*sim_rem_buf_ptr)*li
memset (sim_rem_buf_ptr, 0, sizeof(*sim_rem_buf_ptr)*lines);
sim_rem_single_mode = (t_bool *)realloc (sim_rem_single_mode, sizeof(*sim_rem_single_mode)*lines);
memset (sim_rem_single_mode, 0, sizeof(*sim_rem_single_mode)*lines);
sim_rem_read_timeouts = (t_bool *)realloc (sim_rem_read_timeouts, sizeof(*sim_rem_read_timeouts)*lines);
sim_rem_read_timeouts = (uint32 *)realloc (sim_rem_read_timeouts, sizeof(*sim_rem_read_timeouts)*lines);
memset (sim_rem_read_timeouts, 0, sizeof(*sim_rem_read_timeouts)*lines);
return SCPE_OK;
}
@ -2921,17 +2923,19 @@ static void decode (char *decoded, const char *encoded)
{
char c;
while (c = *decoded++ = *encoded++) /* copy the character */
if (c == ESC_CHAR) /* does it start an escape? */
if (isalpha (*encoded) || /* is next character "A-Z" or "a-z"? */
*encoded == '@' || /* or "@"? */
*encoded >= '[' && *encoded <= '_') /* or "[\]^_"? */
while ((c = *decoded++ = *encoded++)) /* copy the character */
if (c == ESC_CHAR) { /* does it start an escape? */
if ((isalpha (*encoded)) || /* is next character "A-Z" or "a-z"? */
(*encoded == '@') || /* or "@"? */
((*encoded >= '[') && (*encoded <= '_'))) /* or "[\]^_"? */
*(decoded - 1) = *encoded++ & 037; /* convert back to control character */
else if (*encoded == '\0' || /* single escape character at EOL? */
*encoded++ != ESC_CHAR) /* or not followed by another escape? */
decoded--; /* drop the encoding */
else {
if ((*encoded == '\0') || /* single escape character at EOL? */
(*encoded++ != ESC_CHAR)) /* or not followed by another escape? */
decoded--; /* drop the encoding */
}
}
return;
}
@ -2958,7 +2962,7 @@ else {
mbuf,
(sim_switches & SWMASK ('I')) ? "" : "\n");
free (mbuf);
mbuf = sim_encode_quoted_string (mbuf2, strlen (mbuf2));
mbuf = sim_encode_quoted_string ((uint8 *)mbuf2, strlen (mbuf2));
sim_exp_set (&sim_con_expect, mbuf, 0, sim_con_expect.after, 0, NULL);
free (mbuf);
free (mbuf2);
@ -2983,7 +2987,7 @@ else {
rbuf = (uint8 *)malloc (1 + strlen(cptr));
decode ((char *)rbuf, cptr); /* decod string */
sim_send_input (&sim_con_send, rbuf, strlen(rbuf), 0, 0); /* queue it for output */
sim_send_input (&sim_con_send, rbuf, strlen((char *)rbuf), 0, 0); /* queue it for output */
free (rbuf);
}

View file

@ -471,7 +471,7 @@ _serial_remove_from_open_list (port);
t_stat sim_config_serial (SERHANDLE port, const char *sconfig)
{
const char *pptr;
char *sptr, *tptr;
const char *sptr, *tptr;
SERCONFIG config = { 0 };
t_bool arg_error = FALSE;
t_stat r;

View file

@ -955,7 +955,8 @@ return SCPE_OK;
t_stat sim_set_throt (int32 arg, char *cptr)
{
char *tptr, c;
const char *tptr;
char c;
t_value val, val2 = 0;
if (arg == 0) {

View file

@ -4087,8 +4087,8 @@ tptr = cptr + strlen (cptr); /* append a semicolon */
*tptr++ = ';'; /* to the command string */
*tptr = '\0'; /* to make parsing easier for get_range */
while (*cptr) { /* parse command string */
cptr = get_range (NULL, cptr, &low, &high, 10, max, ';'); /* get a line range */
while (*cptr) { /* parse command string */
cptr = (char *)get_range (NULL, cptr, &low, &high, 10, max, ';');/* get a line range */
if (cptr == NULL) { /* parsing error? */
result = SCPE_ARG; /* "Invalid argument" error */