Skip to content

Commit a9747db

Browse files
committed
refactor(fdc): silenced some warnings from clang-tidy
1 parent 1080540 commit a9747db

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/fdc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ static void post_exec_format_track(void) {
556556

557557
// At the moment the track format is just a writing over all "pre-formatted"
558558
// sectors. An arbitrary format is currently not supported.
559-
for (size_t s = 0; s < format_args->sec_per_track; s++) {
560-
uint8_t *id_field = exec_buffer + (4 * s);
559+
for (size_t sec = 0; sec < format_args->sec_per_track; sec++) {
560+
uint8_t *id_field = exec_buffer + (4 * sec);
561561
uint8_t cylinder = id_field[0];
562562
uint8_t head = id_field[1];
563563
uint8_t record = id_field[2] - 1;
@@ -619,24 +619,26 @@ static void pre_exec_seek(void) {
619619
/* * * * * * * * * * * * * * * Utility routines * * * * * * * * * * * * * * */
620620

621621
static bool is_cmd_out_of_sequence(uint8_t cmd) {
622+
bool ret = true;
623+
622624
bool fdc_busy = status_register[MSR] &
623625
((FDC_ST_D3B | FDC_ST_D2B | FDC_ST_D1B | FDC_ST_D0B));
624626

625627
if (cmd == FDC_SEEK || cmd == FDC_RECALIBRATE)
626-
return false;
627-
// TODO: to be correct, I should check int, but it was already
628+
ret = false;
629+
// TODO(giuliof): to be correct, I should check int, but it was already
628630
// cleared in command read/write routine
629631
else if (cmd == FDC_SENSE_INTERRUPT) {
630632
if (fdc_busy)
631-
return false;
633+
ret = false;
632634
}
633635
//
634636
else {
635637
if (!fdc_busy)
636-
return false;
638+
ret = false;
637639
}
638640

639-
return true;
641+
return ret;
640642
}
641643

642644
static void fdc_compute_next_status(void) {

src/tests/test_fdc.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <criterion/parameterized.h>
44
#include <stdio.h>
55

6-
// TODO source path is src!
6+
// TODO(giuliof) source path is src!
77
#include "../fdc.h"
88
#include "../fdc_registers.h"
99

@@ -22,12 +22,13 @@ static int fake_write(uint8_t *buffer, uint8_t unit_number, bool phy_head,
2222
* @param expected_sr the expected value of the FDC main status register
2323
*/
2424
static void assert_fdc_sr(uint8_t expected_sr) {
25-
uint8_t sr;
26-
sr = fdc_in(FDC_ADDR_STATUS_REGISTER);
27-
// cr_log_info("%x != %x", sr, expected_sr);
28-
cr_expect_eq(sr, expected_sr);
25+
uint8_t sreg;
26+
sreg = fdc_in(FDC_ADDR_STATUS_REGISTER);
27+
// cr_log_info("%x != %x", sreg, expected_sr);
28+
cr_expect_eq(sreg, expected_sr);
2929
}
3030

31+
// NOLINTNEXTLINE
3132
static int fake_read(uint8_t *buffer, uint8_t unit_number, bool phy_head,
3233
uint8_t phy_track, bool head, uint8_t track,
3334
uint8_t sector) {
@@ -42,6 +43,7 @@ static int fake_read(uint8_t *buffer, uint8_t unit_number, bool phy_head,
4243
return 4;
4344
}
4445

46+
// NOLINTNEXTLINE
4547
static int fake_wrong_rw(uint8_t *buffer, uint8_t unit_number, bool phy_head,
4648
uint8_t phy_track, bool head, uint8_t track,
4749
uint8_t sector) {
@@ -56,6 +58,7 @@ static int fake_wrong_rw(uint8_t *buffer, uint8_t unit_number, bool phy_head,
5658
return DISK_IMAGE_ERR;
5759
}
5860

61+
// NOLINTNEXTLINE
5962
static int fake_read_check_track(uint8_t *buffer, uint8_t unit_number,
6063
bool phy_head, uint8_t phy_track, bool head,
6164
uint8_t track, uint8_t sector) {
@@ -173,11 +176,11 @@ Test(ceda_fdc, invalidSeekSequence) {
173176
cr_assert_eq(fdc_getIntStatus(), false);
174177

175178
{
176-
uint8_t sr;
177-
sr = fdc_in(FDC_ADDR_STATUS_REGISTER);
179+
uint8_t sreg;
180+
sreg = fdc_in(FDC_ADDR_STATUS_REGISTER);
178181
// Remove busy drives, not interested
179-
sr &= (uint8_t) ~(FDC_ST_D0B | FDC_ST_D1B | FDC_ST_D2B | FDC_ST_D3B);
180-
cr_expect_eq(sr, (FDC_ST_RQM | FDC_ST_DIO | FDC_ST_CB));
182+
sreg &= (uint8_t) ~(FDC_ST_D0B | FDC_ST_D1B | FDC_ST_D2B | FDC_ST_D3B);
183+
cr_expect_eq(sreg, (FDC_ST_RQM | FDC_ST_DIO | FDC_ST_CB));
181184
}
182185

183186
// FDC does not process this command and asserts invalid command

0 commit comments

Comments
 (0)