Skip to content

Commit

Permalink
SCP: Avoid potential compiler warnings
Browse files Browse the repository at this point in the history
Essentially all are non-functional problems but silencing them is a good idea
  • Loading branch information
markpizz committed Oct 9, 2020
1 parent 85858b1 commit 3160616
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
27 changes: 18 additions & 9 deletions scp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2689,15 +2689,15 @@ for (i = 1; i < argc; i++) { /* loop thru args */
if (get_switches (argv[i], &sw, NULL) == SW_ERROR) {
fprintf (stderr, "Invalid switch %s\n", argv[i]);
free (targv);
return 0;
return EXIT_FAILURE;
}
sim_switches = sim_switches | sw;
}
else {
if ((strlen (argv[i]) + strlen (cbuf) + 3) >= sizeof(cbuf)) {
fprintf (stderr, "Argument string too long\n");
free (targv);
return 0;
return EXIT_FAILURE;
}
if (*cbuf) /* concat args */
strlcat (cbuf, " ", sizeof (cbuf));
Expand Down Expand Up @@ -2741,6 +2741,7 @@ if (sim_timer_init ()) {
fprintf (stderr, "Fatal timer initialization error\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
sim_register_internal_device (&sim_scp_dev);
Expand All @@ -2754,12 +2755,14 @@ if ((stat = sim_ttinit ()) != SCPE_OK) {
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
if ((sim_eval = (t_value *) calloc (sim_emax, sizeof (t_value))) == NULL) {
fprintf (stderr, "Unable to allocate examine buffer\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
};
if (sim_dflt_dev == NULL) /* if no default */
Expand All @@ -2769,6 +2772,7 @@ if ((stat = reset_all_p (0)) != SCPE_OK) {
sim_failed_reset_dptr->name, sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
if (register_check) {
Expand All @@ -2779,17 +2783,21 @@ if (register_check) {
sim_printf ("Simulator device register sanity check error\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
sim_printf ("*** Good Registers in %s simulator.\n", sim_name);
if (argc < 2) /* No remaining command arguments? */
if (argc < 2) { /* No remaining command arguments? */
free (targv);
return EXIT_SUCCESS; /* then we're done */
}
}
if ((stat = sim_brk_init ()) != SCPE_OK) {
fprintf (stderr, "Fatal breakpoint table initialization error\n%s\n",
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
}
/* always check for register definition problems */
Expand Down Expand Up @@ -2867,7 +2875,7 @@ return sim_exit_status;
t_stat process_stdin_commands (t_stat stat, char *argv[], t_bool do_called)
{
char cbuf[4*CBUFSIZE], gbuf[CBUFSIZE];
CONST char *cptr;
CONST char *cptr = NULL;
t_stat stat_nomessage;
CTAB *cmdp = NULL;

Expand Down Expand Up @@ -4639,12 +4647,12 @@ t_stat assert_cmd (int32 flag, CONST char *cptr)
char gbuf[CBUFSIZE], gbuf2[CBUFSIZE];
CONST char *tptr, *gptr;
REG *rptr;
uint32 idx;
uint32 idx = 0;
t_stat r;
t_bool Not = FALSE;
t_bool Exist = FALSE;
t_bool result;
t_addr addr;
t_addr addr = 0;
t_stat reason;

cptr = (CONST char *)get_sim_opt (CMD_OPT_SW|CMD_OPT_DFT, (CONST char *)cptr, &r);
Expand Down Expand Up @@ -4771,7 +4779,8 @@ else {
return SCPE_ARG;
gptr = tptr; /* update */
}
else idx = 0; /* not array */
else
idx = 0; /* not array */
if (idx >= rptr->depth) /* validate subscript */
return SCPE_SUB;
}
Expand Down Expand Up @@ -10797,7 +10806,7 @@ SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
{
int32 c, logop, cmpop;
t_value *logval, *cmpval;
t_stat reason;
t_stat reason = SCPE_OK;
CONST char *ocptr = cptr;
const char *sptr;
char gbuf[CBUFSIZE];
Expand Down Expand Up @@ -12656,7 +12665,7 @@ return SCPE_OK;
t_stat sim_exp_check (EXPECT *exp, uint8 data)
{
int32 i;
EXPTAB *ep;
EXPTAB *ep = NULL;
int regex_checks = 0;
char *tstr = NULL;

Expand Down
4 changes: 2 additions & 2 deletions scp.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ void sim_debug_unit (uint32 dbits, UNIT* uptr, const char *fmt, ...) GCC_FMT_ATT
#else
void _sim_debug_unit (uint32 dbits, UNIT *uptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4);
void _sim_debug_device (uint32 dbits, DEVICE* dptr, const char* fmt, ...) GCC_FMT_ATTR(3, 4);
#define sim_debug(dbits, dptr, ...) do { if (sim_deb && dptr && ((dptr)->dctrl & (dbits))) _sim_debug_device (dbits, dptr, __VA_ARGS__);} while (0)
#define sim_debug_unit(dbits, uptr, ...) do { if (sim_deb && uptr && (((uptr)->dctrl | (uptr)->dptr->dctrl) & (dbits))) _sim_debug_unit (dbits, uptr, __VA_ARGS__);} while (0)
#define sim_debug(dbits, dptr, ...) do { if ((sim_deb != NULL) && ((dptr) != NULL) && ((dptr)->dctrl & (dbits))) _sim_debug_device (dbits, dptr, __VA_ARGS__);} while (0)
#define sim_debug_unit(dbits, uptr, ...) do { if ((sim_deb != NULL) && ((uptr) != NULL) && (((uptr)->dctrl | (uptr)->dptr->dctrl) & (dbits))) _sim_debug_unit (dbits, uptr, __VA_ARGS__);} while (0)
#endif
void sim_flush_buffered_files (void);

Expand Down
4 changes: 2 additions & 2 deletions sim_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,7 @@ else
return sim_messagef (SCPE_INVREM, "Can't enable Remote Console Master mode with Remote Console disabled\n");

if (sim_rem_master_mode) {
t_stat stat_nomessage;
t_stat stat_nomessage = 0;

sim_messagef (SCPE_OK, "Command input starting on Master Remote Console Session\n");
stat = sim_run_boot_prep (0);
Expand Down Expand Up @@ -2291,7 +2291,7 @@ t_stat sim_set_debon (int32 flag, CONST char *cptr)
char gbuf[CBUFSIZE];
t_stat r;
time_t now;
size_t buffer_size;
size_t buffer_size = 0;

if ((cptr == NULL) || (*cptr == 0)) /* need arg */
return SCPE_2FARG;
Expand Down
4 changes: 3 additions & 1 deletion sim_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,6 @@ return SCPE_IOERR;

static t_stat rstsLoadAndScanSATT(rstsContext *context, uint16 uaa, uint16 uar, t_offset *result)
{
t_offset blocks = 0;
uint8 bitmap[8192];
int i, j;
RSTS_ACNT acnt;
Expand Down Expand Up @@ -2080,6 +2079,7 @@ switch (DK_GET_FMT (uptr)) { /* case on format */

/* Construct a pseudo simh disk footer*/
memcpy (f->Signature, "simh", 4);
f->DriveType[sizeof (f->DriveType) - 1] = '\0'; /* Force NUL termination */
strncpy ((char *)f->DriveType, sim_vhd_disk_get_dtype (uptr->fileref, &f->SectorSize, &f->TransferElementSize, (char *)f->CreatingSimulator, &creation_time), sizeof (f->DriveType) - 1);
f->SectorSize = NtoHl (f->SectorSize);
f->TransferElementSize = NtoHl (f->TransferElementSize);
Expand Down Expand Up @@ -2146,6 +2146,7 @@ f = (struct simh_disk_footer *)calloc (1, sizeof (*f));
f->AccessFormat = DK_GET_FMT (uptr);
total_sectors = (((t_offset)uptr->capac) * ctx->capac_factor * ((dptr->flags & DEV_SECTORS) ? 512 : 1)) / ctx->sector_size;
memcpy (f->Signature, "simh", 4);
f->CreatingSimulator[sizeof (f->CreatingSimulator) - 1] = '\0'; /* Force NUL termination */
strncpy ((char *)f->CreatingSimulator, sim_name, sizeof (f->CreatingSimulator) - 1);
strncpy ((char *)f->DriveType, dtype, sizeof (f->DriveType) - 1);
f->SectorSize = NtoHl (ctx->sector_size);
Expand Down Expand Up @@ -4736,6 +4737,7 @@ memset (hVHD->Footer.DriveType, '\0', sizeof hVHD->Footer.DriveType);
memcpy (hVHD->Footer.DriveType, dtype, ((1+strlen (dtype)) < sizeof (hVHD->Footer.DriveType)) ? (1+strlen (dtype)) : sizeof (hVHD->Footer.DriveType));
hVHD->Footer.DriveSectorSize = NtoHl (SectorSize);
hVHD->Footer.DriveTransferElementSize = NtoHl (xfer_element_size);
hVHD->Footer.CreatingSimulator[sizeof (hVHD->Footer.CreatingSimulator) - 1] = '\0'; /* Force NUL termination */
strncpy ((char *)hVHD->Footer.CreatingSimulator, sim_name, sizeof (hVHD->Footer.CreatingSimulator) - 1);
hVHD->Footer.Checksum = 0;
hVHD->Footer.Checksum = NtoHl (CalculateVhdFooterChecksum (&hVHD->Footer, sizeof(hVHD->Footer)));
Expand Down
3 changes: 1 addition & 2 deletions sim_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ static void *
_eth_writer(void *arg)
{
ETH_DEV* volatile dev = (ETH_DEV*)arg;
ETH_WRITE_REQUEST *request;
ETH_WRITE_REQUEST *request = NULL;

/* Boost Priority for this I/O thread vs the CPU instruction execution
thread which in general won't be readily yielding the processor when
Expand Down Expand Up @@ -4272,7 +4272,6 @@ ETH_MAC filter_address[3] = {
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
};
int addr_count;
ETH_MAC physical_addr = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
ETH_MAC host_nic_phy_hw_addr = {0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
ETH_MAC *host_phy_addr_list[2] = {&host_nic_phy_hw_addr, NULL};
int host_phy_addr_listindex;
Expand Down
4 changes: 1 addition & 3 deletions sim_fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,7 @@ if (dir) {
#endif
t_offset FileSize;
char *FileName;
const char *MatchName = 1 + strrchr (cptr, '/');
char *p_name;
struct tm *local;
char *p_name;
#if defined (HAVE_GLOB)
size_t i;
#endif
Expand Down

0 comments on commit 3160616

Please sign in to comment.