Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed more linter warnings #157

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions consolein/consolein_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package consolein

import (
"testing"
)
import "testing"

func TestReadline(t *testing.T) {

Expand Down
2 changes: 1 addition & 1 deletion consolein/select_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// SELECT to read from STDIN.
func canSelect() bool {

fds := &unix.FdSet{}
fds := new(unix.FdSet)
fds.Set(int(os.Stdin.Fd()))

// See if input is pending, for a while.
Expand Down
6 changes: 3 additions & 3 deletions consoleout/consoleout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestOutput(t *testing.T) {
}

// ensure we redirect the output
tmp := &bytes.Buffer{}
tmp := new(bytes.Buffer)

d.driver.SetWriter(tmp)

Expand Down Expand Up @@ -106,7 +106,7 @@ func TestNull(t *testing.T) {
}

// ensure we redirect the output
tmp := &bytes.Buffer{}
tmp := new(bytes.Buffer)

null.driver.SetWriter(tmp)

Expand Down Expand Up @@ -134,7 +134,7 @@ func TestLogger(t *testing.T) {
}

// ensure we redirect the output
tmp := &bytes.Buffer{}
tmp := new(bytes.Buffer)

drv.driver.SetWriter(tmp)

Expand Down
32 changes: 16 additions & 16 deletions cpm/cpm_bdos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestDriveGetSet(t *testing.T) {
}

// Set a drive to a bogus value
c.CPU.States.AF.Hi = 0xff
c.CPU.States.AF.Hi = 0xFF
err = BdosSysCallDriveSet(c)
if err != nil {
t.Fatalf("failed to call CP/M")
Expand Down Expand Up @@ -428,7 +428,7 @@ func TestUserNumber(t *testing.T) {
}

// now get properly
c.CPU.States.DE.Lo = 0xff
c.CPU.States.DE.Lo = 0xFF
err = BdosSysCallUserNumber(c)
if err != nil {
t.Fatalf("failed to call CPM")
Expand Down Expand Up @@ -475,8 +475,8 @@ func TestDriveReset(t *testing.T) {

// Now reset again and we should see 0xFF to trigger
// the submit.com behaviour
if getState() != 0xff {
t.Fatalf("getState != 0xff")
if getState() != 0xFF {
t.Fatalf("getState != 0xFF")
}
}

Expand Down Expand Up @@ -565,7 +565,7 @@ func TestIOByte(t *testing.T) {
}

// set it
c.CPU.States.DE.Lo = 0xfe
c.CPU.States.DE.Lo = 0xFE
err = BdosSysCallSetIOByte(c)
if err != nil {
t.Fatalf("error in CPM call")
Expand All @@ -577,7 +577,7 @@ func TestIOByte(t *testing.T) {
t.Fatalf("error in CPM call")
}

if c.CPU.States.AF.Hi != 0xfe {
if c.CPU.States.AF.Hi != 0xFE {
t.Fatalf("unexpected updated IO byte")
}
}
Expand All @@ -597,7 +597,7 @@ func TestBDOSCoverage(t *testing.T) {
for _, handler := range c.BDOSSyscalls {

if handler.Fake {
err := handler.Handler(c)
err = handler.Handler(c)
if err != nil {
t.Fatalf("error calling %s\n", handler.Desc)
}
Expand Down Expand Up @@ -663,7 +663,7 @@ func TestMakeFile(t *testing.T) {
c.SetDrives(false)

fileExists := func(path string) bool {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
if _, err2 := os.Stat(path); errors.Is(err2, os.ErrNotExist) {
return false
}
return true
Expand Down Expand Up @@ -703,7 +703,7 @@ func TestMakeFile(t *testing.T) {

// Why not also try to close a file that is
// not open?
c.CPU.States.DE.SetU16(0xcdcd)
c.CPU.States.DE.SetU16(0xCDCD)
err = BdosSysCallFileClose(c)
if err != nil {
t.Fatalf("failed to close file which wasn't open")
Expand All @@ -716,7 +716,7 @@ func TestMakeFile(t *testing.T) {
if err != nil {
t.Fatalf("error calling CP/M")
}
if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("expected error with empty file")
}

Expand Down Expand Up @@ -745,7 +745,7 @@ func TestDelete(t *testing.T) {
}

fileExists := func(path string) bool {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
if _, err2 := os.Stat(path); errors.Is(err2, os.ErrNotExist) {
return false
}
return true
Expand Down Expand Up @@ -795,7 +795,7 @@ func TestRename(t *testing.T) {
}

fileExists := func(path string) bool {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
if _, err2 := os.Stat(path); errors.Is(err2, os.ErrNotExist) {
return false
}
return true
Expand Down Expand Up @@ -843,7 +843,7 @@ func TestRename(t *testing.T) {
if err != nil {
t.Fatalf("error calling CP/M")
}
if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("renaming to an impossible name succeeded")
}

Expand All @@ -863,7 +863,7 @@ func TestWriteFile(t *testing.T) {
c.SetDrives(false)

fileExists := func(path string) bool {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
if _, err2 := os.Stat(path); errors.Is(err2, os.ErrNotExist) {
return false
}
return true
Expand Down Expand Up @@ -965,7 +965,7 @@ func TestWriteFile(t *testing.T) {
if err != nil {
t.Fatalf("error calling cp/m")
}
if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("expected A-reg to hold an error")
}
}
Expand Down Expand Up @@ -994,7 +994,7 @@ func TestReadFile(t *testing.T) {
if err != nil {
t.Fatalf("error calling cp/m")
}
if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("expected A-reg to hold an error")
}

Expand Down
24 changes: 12 additions & 12 deletions cpm/cpm_bios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestStatus(t *testing.T) {
t.Fatalf("failed to call CPM")
}

if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("printer status was wrong")
}

Expand All @@ -46,7 +46,7 @@ func TestStatus(t *testing.T) {
t.Fatalf("failed to call CPM")
}

if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("screen status was wrong")
}

Expand All @@ -55,7 +55,7 @@ func TestStatus(t *testing.T) {
t.Fatalf("failed to call CPM")
}

if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("aux input status was wrong")
}

Expand All @@ -64,7 +64,7 @@ func TestStatus(t *testing.T) {
t.Fatalf("failed to call CPM")
}

if c.CPU.States.AF.Hi != 0xff {
if c.CPU.States.AF.Hi != 0xFF {
t.Fatalf("aux output status was wrong")
}

Expand Down Expand Up @@ -157,17 +157,17 @@ func TestCustom(t *testing.T) {

// set to "null"
c.CPU.States.HL.SetU16(0x0002)
c.CPU.States.DE.SetU16(0xfe00)
c.Memory.SetRange(0xfe00, []byte{'n', 'u', 'l', 'l', ' '}...)
c.CPU.States.DE.SetU16(0xFE00)
c.Memory.SetRange(0xFE00, []byte{'n', 'u', 'l', 'l', ' '}...)
err = BiosSysCallReserved1(c)
if err != nil {
t.Fatalf("error calling reserved function")
}

// set to "steve" - this will fail
c.CPU.States.HL.SetU16(0x0002)
c.CPU.States.DE.SetU16(0xfe00)
c.Memory.SetRange(0xfe00, []byte{'s', 't', 'e', 'v', 'e', ' '}...)
c.CPU.States.DE.SetU16(0xFE00)
c.Memory.SetRange(0xFE00, []byte{'s', 't', 'e', 'v', 'e', ' '}...)
err = BiosSysCallReserved1(c)
if err != nil {
t.Fatalf("error calling reserved function")
Expand Down Expand Up @@ -200,17 +200,17 @@ func TestCustom(t *testing.T) {

// set to "ccpz"
c.CPU.States.HL.SetU16(0x0003)
c.CPU.States.DE.SetU16(0xfe00)
c.Memory.SetRange(0xfe00, []byte{'c', 'c', 'p', 'z', ' '}...)
c.CPU.States.DE.SetU16(0xFE00)
c.Memory.SetRange(0xFE00, []byte{'c', 'c', 'p', 'z', ' '}...)
err = BiosSysCallReserved1(c)
if err != nil {
t.Fatalf("error calling reserved function")
}

// set to "steve" - this will fail
c.CPU.States.HL.SetU16(0x0003)
c.CPU.States.DE.SetU16(0xfe00)
c.Memory.SetRange(0xfe00, []byte{'s', 't', 'e', 'v', 'e', ' '}...)
c.CPU.States.DE.SetU16(0xFE00)
c.Memory.SetRange(0xFE00, []byte{'s', 't', 'e', 'v', 'e', ' '}...)
err = BiosSysCallReserved1(c)
if err != nil {
t.Fatalf("error calling reserved function")
Expand Down
13 changes: 6 additions & 7 deletions cpm/cpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func TestSimple(t *testing.T) {
}

// Write a string of three bytes to the console - again discarded
obj.CPU.States.DE.SetU16(0xfe00)
obj.Memory.Set(0xfe00, 's')
obj.Memory.Set(0xfe01, 'k')
obj.Memory.Set(0xfe02, 'x')
obj.Memory.Set(0xfe03, '$')
obj.CPU.States.DE.SetU16(0xFE00)
obj.Memory.Set(0xFE00, 's')
obj.Memory.Set(0xFE01, 'k')
obj.Memory.Set(0xFE02, 'x')
obj.Memory.Set(0xFE03, '$')
err = BdosSysCallWriteString(obj)
if err != nil {
t.Fatalf("failed to call CPM")
Expand Down Expand Up @@ -282,7 +282,7 @@ func TestCPMCoverage(t *testing.T) {
}

// Invalid
obj.Out(0xFF, 0xff)
obj.Out(0xFF, 0xFF)
if obj.biosErr != ErrUnimplemented {
t.Fatalf("expected unimplemented, got %s", obj.biosErr)
}
Expand Down Expand Up @@ -337,7 +337,6 @@ func TestAutoExec(t *testing.T) {
obj.StuffText("nothing\n")
obj.RunAutoExec()

out = ""
out, err = obj.input.ReadLine(200)
if err != nil {
t.Fatalf("failed to call ReadLine")
Expand Down
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,9 @@ func main() {
slog.SetDefault(log)

// Create a new emulator.
obj, err := cpm.New(
cpm.WithPrinterPath(*prnPath),
obj, err := cpm.New(cpm.WithPrinterPath(*prnPath),
cpm.WithConsoleDriver(*console),
cpm.WithCCP(*ccp),
)
cpm.WithCCP(*ccp))
if err != nil {
fmt.Printf("error creating CPM object: %s\n", err)
return
Expand Down
4 changes: 1 addition & 3 deletions memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// within which the emulator executes its programs.
package memory

import (
"os"
)
import "os"

// Memory is our structure for representing the 64k of RAM
// that we run our programs within.
Expand Down
Loading