BESM6: Fixed memory access issues (COVERITY).

This commit is contained in:
Leo Broukhis 2017-03-09 21:32:23 -08:00
parent 828fe4c901
commit 9e318d16a2
3 changed files with 10 additions and 8 deletions

View file

@ -2,7 +2,7 @@
* besm6_mmu.c: BESM-6 fast write cache and TLB registers * besm6_mmu.c: BESM-6 fast write cache and TLB registers
*стойка БРУС) *стойка БРУС)
* *
* Copyright (c) 2009, Leonid Broukhis * Copyright (c) 2009-2017, Leonid Broukhis
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -623,7 +623,7 @@ t_value mmu_prefetch (int addr, int actual)
return 0; return 0;
} else { } else {
/* Чтобы лампочки мигали */ /* Чтобы лампочки мигали */
i = addr & 3; i = addr;
} }
if (addr < 0100000) { if (addr < 0100000) {
@ -645,7 +645,7 @@ t_value mmu_prefetch (int addr, int actual)
} }
} else } else
val = memory[addr]; val = memory[addr];
BRS[i] = val; BRS[i & 3] = val;
return val; return val;
} }

View file

@ -173,7 +173,7 @@ static void pi_to_bytes(int unit, int card, unsigned char buf[120]) {
static void pi_punch_binary(int unit, int card) { static void pi_punch_binary(int unit, int card) {
UNIT *u = &pi_unit[unit]; UNIT *u = &pi_unit[unit];
FILE * f = u->fileref; FILE * f = u->fileref;
unsigned char buf[120]; static unsigned char buf[120];
pi_to_bytes(unit, card, buf); pi_to_bytes(unit, card, buf);
fwrite(buf, 120, 1, f); fwrite(buf, 120, 1, f);
} }
@ -226,7 +226,7 @@ static void pi_punch_visual(int unit, int card) {
static void pi_punch_gost(int unit, int card) { static void pi_punch_gost(int unit, int card) {
UNIT *u = &pi_unit[unit]; UNIT *u = &pi_unit[unit];
FILE * f = u->fileref; FILE * f = u->fileref;
unsigned char buf[120]; static unsigned char buf[120];
int len; int len;
int cur; int cur;
int zero_expected = 0; int zero_expected = 0;

View file

@ -1,7 +1,7 @@
/* /*
* besm6_tty.c: BESM-6 teletype device * besm6_tty.c: BESM-6 teletype device
* *
* Copyright (c) 2009, Leo Broukhis * Copyright (c) 2009-2017, Leo Broukhis
* Copyright (c) 2009, Serge Vakulenko * Copyright (c) 2009, Serge Vakulenko
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -72,8 +72,10 @@ char * process (int sym)
/* For serial lines */ /* For serial lines */
int tty_active [TTY_MAX+1], tty_sym [TTY_MAX+1]; int tty_active [TTY_MAX+1], tty_sym [TTY_MAX+1];
int tty_typed [TTY_MAX+1], tty_instate [TTY_MAX+1]; int tty_typed [TTY_MAX+1], tty_instate [TTY_MAX+1];
time_t tty_last_time [TTY_MAX+1];
int tty_idle_count [TTY_MAX+1]; /* For all lines */
time_t tty_last_time [LINES_MAX+1];
int tty_idle_count [LINES_MAX+1];
/* The serial interrupt generator frequency, common for all VT lines */ /* The serial interrupt generator frequency, common for all VT lines */
int tty_rate = 300; int tty_rate = 300;