Skip to content

Commit 77503df

Browse files
committed
Code clean-up
1 parent 0146e1a commit 77503df

File tree

26 files changed

+110
-76
lines changed

26 files changed

+110
-76
lines changed

core/mathutils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ You should have received a copy of the GNU General Public License
1919
along with this program. If not, see <https://www.gnu.org/licenses/>.
2020
*/
2121

22+
#include <cstdint>
23+
2224
#ifndef MATH_UTILS_H
2325
#define MATH_UTILS_H
2426

core/timermanager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3131
#include <vector>
3232
#include <mutex>
3333

34-
#define NS_PER_SEC 1000000000
35-
#define USEC_PER_SEC 1000000
36-
#define NS_PER_USEC 1000
37-
#define NS_PER_MSEC 1000000
38-
#define ONE_BILLION_NS 1000000000
34+
constexpr auto NS_PER_SEC = 1000000000;
35+
constexpr auto USEC_PER_SEC = 1000000;
36+
constexpr auto NS_PER_USEC = 1000;
37+
constexpr auto NS_PER_MSEC = 1000000;
38+
constexpr auto ONE_BILLION_NS = 1000000000;
3939

4040
#define USECS_TO_NSECS(us) (us) * NS_PER_USEC
4141
#define MSECS_TO_NSECS(ms) (ms) * NS_PER_MSEC

debugger/debugger.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void show_help() {
112112

113113
static uint32_t disasm_68k(uint32_t count, uint32_t address) {
114114
csh cs_handle;
115-
uint8_t code[12];
115+
uint8_t code[12]{};
116116
size_t code_size;
117117
uint64_t dis_addr;
118118

@@ -160,7 +160,7 @@ static uint32_t disasm_68k(uint32_t count, uint32_t address) {
160160
}
161161

162162
/* emulator opcode table size --> 512 KB */
163-
#define EMU_68K_TABLE_SIZE 0x80000
163+
constexpr auto EMU_68K_TABLE_SIZE = 0x80000;
164164

165165
/** Execute one emulated 68k instruction. */
166166
void exec_single_68k()
@@ -476,7 +476,7 @@ void DppcDebugger::enter_debugger() {
476476
uint32_t next_addr_68k;
477477
#endif
478478
bool cmd_repeat;
479-
int repeat_count;
479+
int repeat_count = 0;
480480

481481
unique_ptr<OfConfigUtils> ofnvram = unique_ptr<OfConfigUtils>(new OfConfigUtils);
482482

devices/common/adb/adbbus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3030
#include <string>
3131
#include <vector>
3232

33-
#define ADB_MAX_DATA_SIZE 8
33+
constexpr auto ADB_MAX_DATA_SIZE = 8;
3434

3535
/** ADB status. */
3636
enum {

devices/common/ata/atabasedevice.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class AtaBaseDevice : public HWComponent, public AtaInterface
7171
}
7272

7373
protected:
74-
bool is_selected() { return ((this->r_dev_head >> 4) & 1) == this->my_dev_id; };
74+
bool is_selected() const {
75+
return ((this->r_dev_head >> 4) & 1) == this->my_dev_id;
76+
};
7577

7678
void prepare_xfer(int xfer_size, int block_size);
7779

@@ -82,7 +84,7 @@ class AtaBaseDevice : public HWComponent, public AtaInterface
8284
IdeChannel* host_obj = nullptr;
8385

8486
// IDE aka task file registers
85-
uint8_t r_error;
87+
uint8_t r_error = 0;
8688
uint8_t r_features;
8789
uint8_t r_sect_count;
8890
uint8_t r_sect_num;

devices/common/ata/atahd.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2929

3030
#include <string>
3131

32-
#define ATA_HD_SEC_SIZE 512
33-
#define SECTORS_PER_INT 16
32+
constexpr auto ATA_HD_SEC_SIZE = 512;
33+
constexpr auto SECTORS_PER_INT = 16;
3434

3535
// C:16383 x H:16 x S:63 = C:1032 x H:254 x S:63 = 8063.5078125 MiB = 8.46 GB
36-
#define ATA_BIOS_LIMIT 16514064
36+
constexpr auto ATA_BIOS_LIMIT = 16514064;
3737
// C:65535 x H:16 x S:255 = 127.498 GiB = 136.900 GB = largest identify
38-
#define REAL_CHS_LIMIT 267382800
38+
constexpr auto REAL_CHS_LIMIT = 267382800;
3939
// C:65536 x H:16 x S:255 = 127.500 GiB = 136.902 GB = largest address
40-
#define CHS_LIMIT 267386880
40+
constexpr auto CHS_LIMIT = 267386880;
4141

4242
class AtaHardDisk : public AtaBaseDevice
4343
{

devices/common/ata/cmd646.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3131

3232
#include <memory>
3333

34-
#define DEV_ID_CMD646 0x646
35-
#define MY_DEV_CLASS 0x010180 // mass storage | IDE controller | IDE master
36-
#define MY_REV_ID 7
34+
constexpr auto DEV_ID_CMD646 = 0x646;
35+
constexpr auto MY_DEV_CLASS = 0x010180; // mass storage | IDE controller | IDE master;
36+
constexpr auto MY_REV_ID = 7;
3737

3838
// Offset for converting addresses of the device control block registers
3939
// defined in the PCI IDE Controller specification, rev. 1.0 3/4/94
4040
// to the addresses used in IdeChannel
41-
#define DEV_CTRL_BLK_OFFSET 0x14
41+
constexpr auto DEV_CTRL_BLK_OFFSET = 0x14;
4242

4343
/** CMD646 control/status registers. */
4444
enum {

devices/common/clockgen/athens.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2929

3030
#include <cinttypes>
3131

32-
#define ATHENS_NUM_REGS 8
32+
constexpr auto ATHENS_NUM_REGS = 8;
3333

3434
/** Default external crystal oscillator frequency. */
3535
constexpr auto ATHENS_XTAL = 31334400.0f;

devices/common/ofnvram.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3333
class NVram;
3434

3535
/** ========== Apple Open Firmware 1.x/2.x partition definitions. ========== */
36-
#define OF_NVRAM_OFFSET 0x1800
37-
#define OF_NVRAM_SIG 0x1275
38-
#define OF_CFG_SIZE 0x800
36+
constexpr auto OF_NVRAM_OFFSET = 0x1800;
37+
constexpr auto OF_NVRAM_SIG = 0x1275;
38+
constexpr auto OF_CFG_SIZE = 0x800;
3939

4040
// OF Variable types
4141
enum {

devices/common/pci/bandit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
4646
#include <memory>
4747
#include <string>
4848

49-
#define BANDIT_DEV (11) // Bandit's own device number
50-
#define BANDIT_CAR_TYPE (1 << 0) // Bandit config address type bit
49+
constexpr auto BANDIT_DEV = (11); // Bandit's own device number;
50+
constexpr auto BANDIT_CAR_TYPE = (1 << 0); // Bandit config address type bit;
5151

5252
/* Convenient macros for parsing CONFIG_ADDR fields. */
5353
#define BUS_NUM() ((this->config_addr >> 16) & 0xFFU)

0 commit comments

Comments
 (0)