Skip to content

Commit ab225dc

Browse files
committed
Small cosmetic changes
- perform arg checks early - removed unneeded err variable in function scope
1 parent fbfa695 commit ab225dc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cli/firmware/flash.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ func runFlash(cmd *cobra.Command, args []string) {
6969
// at the end cleanup the fwuploader temp dir
7070
defer globals.FwUploaderPath.RemoveAll()
7171

72-
packageIndex, firmwareIndex := common.InitIndexes()
7372
common.CheckFlags(commonFlags.Fqbn, commonFlags.Address)
73+
packageIndex, firmwareIndex := common.InitIndexes()
7474
board := common.GetBoard(firmwareIndex, commonFlags.Fqbn)
7575
uploadToolDir := common.DownloadRequiredToolsForBoard(packageIndex, board)
7676

@@ -92,7 +92,6 @@ func runFlash(cmd *cobra.Command, args []string) {
9292
moduleName = strings.ToUpper(moduleName)
9393

9494
var firmwareFilePath *paths.Path
95-
var err error
9695
// If a local firmware file has been specified
9796
if fwFile != "" {
9897
firmwareFilePath = paths.New(fwFile)
@@ -111,9 +110,10 @@ func runFlash(cmd *cobra.Command, args []string) {
111110
feedback.Fatal(fmt.Sprintf("Error getting firmware for board: %s", commonFlags.Fqbn), feedback.ErrGeneric)
112111
}
113112
logrus.Debugf("module name: %s, firmware version: %s", firmware.Module, firmware.Version.String())
114-
firmwareFilePath, err = download.DownloadFirmware(firmware)
115-
if err != nil {
113+
if fwPath, err := download.DownloadFirmware(firmware); err != nil {
116114
feedback.Fatal(fmt.Sprintf("Error downloading firmware from %s: %s", firmware.URL, err), feedback.ErrGeneric)
115+
} else {
116+
firmwareFilePath = fwPath
117117
}
118118
logrus.Debugf("firmware file downloaded in %s", firmwareFilePath.String())
119119
}

0 commit comments

Comments
 (0)