This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Description There is no need for a break statement in the case block in golang.
switch int (event ) {
case VirtioConsoleDeviceReady :
vchannel .Debug ("device-ready" )
device .sendCtrl (0 , VirtioConsolePortAdd , 1 )
break
case VirtioConsolePortAdd :
vchannel .Debug ("port-add?" )
break
case VirtioConsolePortRemove :
vchannel .Debug ("port-remove?" )
break
case VirtioConsolePortReady :
vchannel .Debug ("port-ready" )
if id == 0 && value == 1 {
// No, this is not a console.
device .sendCtrl (0 , VirtioConsolePortConsole , 0 )
device .sendCtrl (0 , VirtioConsolePortOpen , 1 )
if ! device .Opened {
device .Opened = true
device .read_lock .Unlock ()
device .write_lock .Unlock ()
}
}
break
case VirtioConsolePortConsole :
vchannel .Debug ("port-console?" )
break
case VirtioConsolePortResize :
vchannel .Debug ("port-resize" )
break
case VirtioConsolePortOpen :
vchannel .Debug ("port-open" )
break
case VirtioConsolePortName :
vchannel .Debug ("port-name" )
break
default :
vchannel .Debug ("unknown?" )
break
}
switch int (cmd_type ) {
case VirtioBlockTIn :
_ , err := buf .PRead (device .Fd , offset , 16 , buf .Length ()- 17 )
if err != nil {
device .Debug (
"read err [%x,%x] -> %s" ,
offset ,
int (offset )+ buf .Length ()- 18 ,
err .Error ())
status .Set8 (0 , VirtioBlockSIoErr )
} else {
device .Debug (
"read ok [%x,%x]" ,
offset ,
int (offset )+ buf .Length ()- 18 )
status .Set8 (0 , VirtioBlockSOk )
}
break
case VirtioBlockTOut :
_ , err := buf .PWrite (device .Fd , offset , 16 , buf .Length ()- 17 )
if err != nil {
device .Debug (
"write err [%x,%x] -> %s" ,
offset ,
int (offset )+ buf .Length ()- 18 ,
err .Error ())
status .Set8 (0 , VirtioBlockSIoErr )
} else {
device .Debug (
"write ok [%x,%x]" ,
offset ,
int (offset )+ buf .Length ()- 18 )
status .Set8 (0 , VirtioBlockSOk )
}
break
default :
device .Debug ("unknown command '%d'?" , cmd_type )
status .Set8 (0 , VirtioBlockSUnsupported )
break
}
Reactions are currently unavailable
There is no need for a break statement in the case block in golang.
novm/src/novmm/machine/virtio_console.go
Lines 95 to 143 in 278237d
novm/src/novmm/machine/virtio_block.go
Lines 74 to 115 in 278237d