Skip to content

Commit

Permalink
Fix DoRaw error handling (#2)
Browse files Browse the repository at this point in the history
The err variable was shadowed by the short variable declaration in the switch case.
  • Loading branch information
danielrparks authored Dec 29, 2023
1 parent 07d94c8 commit aa2fe41
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/qrc2zip/qrc2zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,27 @@ func main() {
case 1:
err = q2z.DoRCC(pflag.Args()[0])
case 5:
formatVersion, err := strconv.Atoi(pflag.Args()[1])
var formatVersion int
var treeOffset, dataOffset, namesOffset int64
formatVersion, err = strconv.Atoi(pflag.Args()[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Error: parse format version %q: %v.\n", pflag.Args()[1], err)
os.Exit(2)
return
}
treeOffset, err := strconv.ParseInt(pflag.Args()[2], 10, 64)
treeOffset, err = strconv.ParseInt(pflag.Args()[2], 10, 64)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: parse tree offset %q: %v.\n", pflag.Args()[2], err)
os.Exit(2)
return
}
dataOffset, err := strconv.ParseInt(pflag.Args()[3], 10, 64)
dataOffset, err = strconv.ParseInt(pflag.Args()[3], 10, 64)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: parse data offset %q: %v.\n", pflag.Args()[3], err)
os.Exit(2)
return
}
namesOffset, err := strconv.ParseInt(pflag.Args()[4], 10, 64)
namesOffset, err = strconv.ParseInt(pflag.Args()[4], 10, 64)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: parse names offset %q: %v.\n", pflag.Args()[4], err)
os.Exit(2)
Expand Down

0 comments on commit aa2fe41

Please sign in to comment.