From 9e0846e8a4beebff36c72f03479a7db775b5144e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 7 May 2018 17:59:06 +0200 Subject: all: get rid of underscores in identifiers Underscores are against Go coding style. Update #538 --- vm/adb/adb.go | 12 ++++++------ vm/gce/gce.go | 30 +++++++++++++++--------------- vm/isolated/isolated.go | 18 +++++++++--------- vm/qemu/qemu.go | 30 +++++++++++++++--------------- vm/vmimpl/console.go | 6 +++--- vm/vmimpl/console_darwin.go | 8 ++++---- vm/vmimpl/console_freebsd.go | 8 ++++---- vm/vmimpl/console_linux_386.go | 8 ++++---- vm/vmimpl/console_linux_amd64.go | 8 ++++---- vm/vmimpl/console_linux_arm.go | 8 ++++---- vm/vmimpl/console_linux_arm64.go | 8 ++++---- vm/vmimpl/console_linux_ppc64le.go | 8 ++++---- vm/vmimpl/console_netbsd.go | 8 ++++---- 13 files changed, 80 insertions(+), 80 deletions(-) (limited to 'vm') diff --git a/vm/adb/adb.go b/vm/adb/adb.go index e6908a9aa..1c1271b34 100644 --- a/vm/adb/adb.go +++ b/vm/adb/adb.go @@ -28,15 +28,15 @@ func init() { } type Config struct { - Adb string // adb binary name ("adb" by default) - Devices []string // list of adb device IDs to use + Adb string `json:"adb"` // adb binary name ("adb" by default) + Devices []string `json:"devices"` // list of adb device IDs to use // Ensure that a device battery level is at 20+% before fuzzing. // Sometimes we observe that a device can't charge during heavy fuzzing // and eventually powers down (which then requires manual intervention). // This option is enabled by default. Turn it off if your devices // don't have battery service, or it causes problems otherwise. - Battery_Check bool + BatteryCheck bool `json:"battery_check"` } type Pool struct { @@ -54,8 +54,8 @@ type instance struct { func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { cfg := &Config{ - Adb: "adb", - Battery_Check: true, + Adb: "adb", + BatteryCheck: true, } if err := config.LoadData(env.Config, cfg); err != nil { return nil, fmt.Errorf("failed to parse adb vm config: %v", err) @@ -103,7 +103,7 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) { return nil, err } inst.console = findConsole(inst.adbBin, inst.device) - if pool.cfg.Battery_Check { + if pool.cfg.BatteryCheck { if err := inst.checkBatteryLevel(); err != nil { return nil, err } diff --git a/vm/gce/gce.go b/vm/gce/gce.go index 036ffeb8b..dbd1001fd 100644 --- a/vm/gce/gce.go +++ b/vm/gce/gce.go @@ -36,10 +36,10 @@ func init() { } type Config struct { - Count int // number of VMs to use - Machine_Type string // GCE machine type (e.g. "n1-highcpu-2") - GCS_Path string // GCS path to upload image - GCE_Image string // Pre-created GCE image to use + Count int `json:"count"` // number of VMs to use + MachineType string `json:"machine_type"` // GCE machine type (e.g. "n1-highcpu-2") + GCSPath string `json:"gcs_path"` // GCS path to upload image + GCEImage string `json:"gce_image"` // Pre-created GCE image to use } type Pool struct { @@ -77,16 +77,16 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { if env.Debug { cfg.Count = 1 } - if cfg.Machine_Type == "" { + if cfg.MachineType == "" { return nil, fmt.Errorf("machine_type parameter is empty") } - if cfg.GCE_Image == "" && cfg.GCS_Path == "" { + if cfg.GCEImage == "" && cfg.GCSPath == "" { return nil, fmt.Errorf("gcs_path parameter is empty") } - if cfg.GCE_Image == "" && env.Image == "" { + if cfg.GCEImage == "" && env.Image == "" { return nil, fmt.Errorf("config param image is empty (required for GCE)") } - if cfg.GCE_Image != "" && env.Image != "" { + if cfg.GCEImage != "" && env.Image != "" { return nil, fmt.Errorf("both image and gce_image are specified") } @@ -97,18 +97,18 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { log.Logf(0, "GCE initialized: running on %v, internal IP %v, project %v, zone %v, net %v/%v", GCE.Instance, GCE.InternalIP, GCE.ProjectID, GCE.ZoneID, GCE.Network, GCE.Subnetwork) - if cfg.GCE_Image == "" { - cfg.GCE_Image = env.Name - gcsImage := filepath.Join(cfg.GCS_Path, env.Name+"-image.tar.gz") + if cfg.GCEImage == "" { + cfg.GCEImage = env.Name + gcsImage := filepath.Join(cfg.GCSPath, env.Name+"-image.tar.gz") log.Logf(0, "uploading image to %v...", gcsImage) if err := uploadImageToGCS(env.Image, gcsImage); err != nil { return nil, err } - log.Logf(0, "creating GCE image %v...", cfg.GCE_Image) - if err := GCE.DeleteImage(cfg.GCE_Image); err != nil { + log.Logf(0, "creating GCE image %v...", cfg.GCEImage) + if err := GCE.DeleteImage(cfg.GCEImage); err != nil { return nil, fmt.Errorf("failed to delete GCE image: %v", err) } - if err := GCE.CreateImage(cfg.GCE_Image, gcsImage); err != nil { + if err := GCE.CreateImage(cfg.GCEImage, gcsImage); err != nil { return nil, fmt.Errorf("failed to create GCE image: %v", err) } } @@ -142,7 +142,7 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) { return nil, err } log.Logf(0, "creating instance: %v", name) - ip, err := pool.GCE.CreateInstance(name, pool.cfg.Machine_Type, pool.cfg.GCE_Image, string(gceKeyPub)) + ip, err := pool.GCE.CreateInstance(name, pool.cfg.MachineType, pool.cfg.GCEImage, string(gceKeyPub)) if err != nil { return nil, err } diff --git a/vm/isolated/isolated.go b/vm/isolated/isolated.go index 86adb80dc..f86ec96fd 100644 --- a/vm/isolated/isolated.go +++ b/vm/isolated/isolated.go @@ -24,9 +24,9 @@ func init() { } type Config struct { - Targets []string // target machines: (hostname|ip)(:port)? - Target_Dir string // directory to copy/run on target - Target_Reboot bool // reboot target on repair + Targets []string `json:"targets"` // target machines: (hostname|ip)(:port)? + TargetDir string `json:"target_dir"` // directory to copy/run on target + TargetReboot bool `json:"target_reboot"` // reboot target on repair } type Pool struct { @@ -52,7 +52,7 @@ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { if len(cfg.Targets) == 0 { return nil, fmt.Errorf("config param targets is empty") } - if cfg.Target_Dir == "" { + if cfg.TargetDir == "" { return nil, fmt.Errorf("config param target_dir is empty") } for _, target := range cfg.Targets { @@ -95,10 +95,10 @@ func (pool *Pool) Create(workdir string, index int) (vmimpl.Instance, error) { } // Create working dir if doesn't exist. - inst.ssh("mkdir -p '" + inst.cfg.Target_Dir + "'") + inst.ssh("mkdir -p '" + inst.cfg.TargetDir + "'") // Remove temp files from previous runs. - inst.ssh("rm -rf '" + filepath.Join(inst.cfg.Target_Dir, "*") + "'") + inst.ssh("rm -rf '" + filepath.Join(inst.cfg.TargetDir, "*") + "'") closeInst = nil return inst, nil @@ -168,7 +168,7 @@ func (inst *instance) ssh(command string) error { func (inst *instance) repair() error { log.Logf(2, "isolated: trying to ssh") if err := inst.waitForSSH(30 * 60); err == nil { - if inst.cfg.Target_Reboot { + if inst.cfg.TargetReboot { log.Logf(2, "isolated: trying to reboot") inst.ssh("reboot") // reboot will return an error, ignore it if err := inst.waitForReboot(5 * 60); err != nil { @@ -233,7 +233,7 @@ func (inst *instance) Close() { func (inst *instance) Copy(hostSrc string) (string, error) { baseName := filepath.Base(hostSrc) - vmDst := filepath.Join(inst.cfg.Target_Dir, baseName) + vmDst := filepath.Join(inst.cfg.TargetDir, baseName) inst.ssh("pkill -9 '" + baseName + "'; rm -f '" + vmDst + "'") args := append(inst.sshArgs("-P"), hostSrc, inst.target+":"+vmDst) cmd := osutil.Command("scp", args...) @@ -281,7 +281,7 @@ func (inst *instance) Run(timeout time.Duration, stop <-chan bool, command strin proxy := fmt.Sprintf("%v:127.0.0.1:%v", inst.port, inst.port) args = append(args, "-R", proxy) } - args = append(args, inst.target, "cd "+inst.cfg.Target_Dir+" && exec "+command) + args = append(args, inst.target, "cd "+inst.cfg.TargetDir+" && exec "+command) log.Logf(0, "running command: ssh %#v", args) if inst.debug { log.Logf(0, "running command: ssh %#v", args) diff --git a/vm/qemu/qemu.go b/vm/qemu/qemu.go index 07066a237..a745402f1 100644 --- a/vm/qemu/qemu.go +++ b/vm/qemu/qemu.go @@ -30,15 +30,15 @@ func init() { } type Config struct { - Count int // number of VMs to use - Qemu string // qemu binary name (qemu-system-arch by default) - Qemu_Args string // additional command line arguments for qemu binary - Kernel string // kernel for injected boot (e.g. arch/x86/boot/bzImage) - Cmdline string // kernel command line (can only be specified with kernel) - Initrd string // linux initial ramdisk. (optional) - Image_Device string // qemu image device (hda by default) - CPU int // number of VM CPUs - Mem int // amount of VM memory in MBs + Count int `json:"count"` // number of VMs to use + Qemu string `json:"qemu"` // qemu binary name (qemu-system-arch by default) + QemuArgs string `json:"qemu_args"` // additional command line arguments for qemu binary + Kernel string `json:"kernel"` // kernel for injected boot (e.g. arch/x86/boot/bzImage) + Cmdline string `json:"cmdline"` // kernel command line (can only be specified with kernel) + Initrd string `json:"initrd"` // linux initial ramdisk. (optional) + ImageDevice string `json:"image_device"` // qemu image device (hda by default) + CPU int `json:"cpu"` // number of VM CPUs + Mem int `json:"mem"` // amount of VM memory in MBs } type Pool struct { @@ -101,10 +101,10 @@ var archConfigs = map[string]archConfig{ func ctor(env *vmimpl.Env) (vmimpl.Pool, error) { archConfig := archConfigs[env.OS+"/"+env.Arch] cfg := &Config{ - Count: 1, - Image_Device: "hda", - Qemu: archConfig.Qemu, - Qemu_Args: archConfig.QemuArgs, + Count: 1, + ImageDevice: "hda", + Qemu: archConfig.Qemu, + QemuArgs: archConfig.QemuArgs, } if err := config.LoadData(env.Config, cfg); err != nil { return nil, fmt.Errorf("failed to parse qemu vm config: %v", err) @@ -244,7 +244,7 @@ func (inst *instance) Boot() error { "-serial", "stdio", "-no-reboot", } - args = append(args, strings.Split(inst.cfg.Qemu_Args, " ")...) + args = append(args, strings.Split(inst.cfg.QemuArgs, " ")...) if inst.image == "9p" { args = append(args, "-fsdev", "local,id=fsdev0,path=/,security_model=none,readonly", @@ -252,7 +252,7 @@ func (inst *instance) Boot() error { ) } else { args = append(args, - "-"+inst.cfg.Image_Device, inst.image, + "-"+inst.cfg.ImageDevice, inst.image, "-snapshot", ) } diff --git a/vm/vmimpl/console.go b/vm/vmimpl/console.go index 07c9b9d27..cd47a43bc 100644 --- a/vm/vmimpl/console.go +++ b/vm/vmimpl/console.go @@ -27,12 +27,12 @@ func OpenConsole(con string) (rc io.ReadCloser, err error) { } }() var term unix.Termios - _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscall_TCGETS, uintptr(unsafe.Pointer(&term))) + _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscallTCGETS, uintptr(unsafe.Pointer(&term))) if errno != 0 { return nil, fmt.Errorf("failed to get console termios: %v", errno) } // no parity bit, only need 1 stop bit, no hardware flowcontrol - term.Cflag &^= unix_CBAUD | unix.CSIZE | unix.PARENB | unix.CSTOPB | unix_CRTSCTS + term.Cflag &^= unixCBAUD | unix.CSIZE | unix.PARENB | unix.CSTOPB | unixCRTSCTS // ignore modem controls term.Cflag |= unix.B115200 | unix.CS8 | unix.CLOCAL | unix.CREAD // setup for non-canonical mode @@ -42,7 +42,7 @@ func OpenConsole(con string) (rc io.ReadCloser, err error) { term.Oflag &^= unix.OPOST term.Cc[unix.VMIN] = 0 term.Cc[unix.VTIME] = 10 // 1 second timeout - _, _, errno = syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscall_TCSETS, uintptr(unsafe.Pointer(&term))) + _, _, errno = syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscallTCSETS, uintptr(unsafe.Pointer(&term))) if errno != 0 { return nil, fmt.Errorf("failed to get console termios: %v", errno) } diff --git a/vm/vmimpl/console_darwin.go b/vm/vmimpl/console_darwin.go index 15909ae57..1de3380c0 100644 --- a/vm/vmimpl/console_darwin.go +++ b/vm/vmimpl/console_darwin.go @@ -6,8 +6,8 @@ package vmimpl import "syscall" const ( - unix_CBAUD = 0 - unix_CRTSCTS = 0 - syscall_TCGETS = syscall.TIOCGETA - syscall_TCSETS = syscall.TIOCSETA + unixCBAUD = 0 + unixCRTSCTS = 0 + syscallTCGETS = syscall.TIOCGETA + syscallTCSETS = syscall.TIOCSETA ) diff --git a/vm/vmimpl/console_freebsd.go b/vm/vmimpl/console_freebsd.go index 1bc79c439..9f4455ed5 100644 --- a/vm/vmimpl/console_freebsd.go +++ b/vm/vmimpl/console_freebsd.go @@ -5,8 +5,8 @@ package vmimpl // Merely to fix build. const ( - unix_CBAUD = 0 - unix_CRTSCTS = 0 - syscall_TCGETS = 0 - syscall_TCSETS = 0 + unixCBAUD = 0 + unixCRTSCTS = 0 + syscallTCGETS = 0 + syscallTCSETS = 0 ) diff --git a/vm/vmimpl/console_linux_386.go b/vm/vmimpl/console_linux_386.go index 2f7cad8e6..c2743088b 100644 --- a/vm/vmimpl/console_linux_386.go +++ b/vm/vmimpl/console_linux_386.go @@ -9,8 +9,8 @@ import ( // Builds but is not tested. const ( - unix_CBAUD = unix.CBAUD - unix_CRTSCTS = unix.CRTSCTS - syscall_TCGETS = unix.TCGETS2 - syscall_TCSETS = unix.TCSETS2 + unixCBAUD = unix.CBAUD + unixCRTSCTS = unix.CRTSCTS + syscallTCGETS = unix.TCGETS2 + syscallTCSETS = unix.TCSETS2 ) diff --git a/vm/vmimpl/console_linux_amd64.go b/vm/vmimpl/console_linux_amd64.go index 6eeb2b258..4b6c11703 100644 --- a/vm/vmimpl/console_linux_amd64.go +++ b/vm/vmimpl/console_linux_amd64.go @@ -8,8 +8,8 @@ import ( ) const ( - unix_CBAUD = unix.CBAUD - unix_CRTSCTS = unix.CRTSCTS - syscall_TCGETS = unix.TCGETS2 - syscall_TCSETS = unix.TCSETS2 + unixCBAUD = unix.CBAUD + unixCRTSCTS = unix.CRTSCTS + syscallTCGETS = unix.TCGETS2 + syscallTCSETS = unix.TCSETS2 ) diff --git a/vm/vmimpl/console_linux_arm.go b/vm/vmimpl/console_linux_arm.go index f10edf002..35944a761 100644 --- a/vm/vmimpl/console_linux_arm.go +++ b/vm/vmimpl/console_linux_arm.go @@ -9,8 +9,8 @@ import ( // This compiles, but wan't tested. const ( - unix_CBAUD = unix.CBAUD - unix_CRTSCTS = unix.CRTSCTS - syscall_TCGETS = unix.TCGETS2 - syscall_TCSETS = unix.TCSETS2 + unixCBAUD = unix.CBAUD + unixCRTSCTS = unix.CRTSCTS + syscallTCGETS = unix.TCGETS2 + syscallTCSETS = unix.TCSETS2 ) diff --git a/vm/vmimpl/console_linux_arm64.go b/vm/vmimpl/console_linux_arm64.go index f10edf002..35944a761 100644 --- a/vm/vmimpl/console_linux_arm64.go +++ b/vm/vmimpl/console_linux_arm64.go @@ -9,8 +9,8 @@ import ( // This compiles, but wan't tested. const ( - unix_CBAUD = unix.CBAUD - unix_CRTSCTS = unix.CRTSCTS - syscall_TCGETS = unix.TCGETS2 - syscall_TCSETS = unix.TCSETS2 + unixCBAUD = unix.CBAUD + unixCRTSCTS = unix.CRTSCTS + syscallTCGETS = unix.TCGETS2 + syscallTCSETS = unix.TCSETS2 ) diff --git a/vm/vmimpl/console_linux_ppc64le.go b/vm/vmimpl/console_linux_ppc64le.go index a7374c0e5..62e2c7709 100644 --- a/vm/vmimpl/console_linux_ppc64le.go +++ b/vm/vmimpl/console_linux_ppc64le.go @@ -6,8 +6,8 @@ package vmimpl // Just to make the code compile. // linux_ppc64le as host with adb VMs is not tested. const ( - unix_CBAUD = 0 - unix_CRTSCTS = 0 - syscall_TCGETS = 0 - syscall_TCSETS = 0 + unixCBAUD = 0 + unixCRTSCTS = 0 + syscallTCGETS = 0 + syscallTCSETS = 0 ) diff --git a/vm/vmimpl/console_netbsd.go b/vm/vmimpl/console_netbsd.go index dc332833d..d7e3487c4 100644 --- a/vm/vmimpl/console_netbsd.go +++ b/vm/vmimpl/console_netbsd.go @@ -5,8 +5,8 @@ package vmimpl // Merely to fix build. const ( - unix_CBAUD = 0 - unix_CRTSCTS = 0 - syscall_TCGETS = 0 - syscall_TCSETS = 0 + unixCBAUD = 0 + unixCRTSCTS = 0 + syscallTCGETS = 0 + syscallTCSETS = 0 ) -- cgit mrf-deployment