From aa2fe41e9e6ce60f98b8eb7e137abc754cb65431 Mon Sep 17 00:00:00 2001 From: Daniel Parks <42898924+danielrparks@users.noreply.github.com> Date: Fri, 29 Dec 2023 01:50:06 -0600 Subject: [PATCH] Fix DoRaw error handling (#2) The err variable was shadowed by the short variable declaration in the switch case. --- cmd/qrc2zip/qrc2zip.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/qrc2zip/qrc2zip.go b/cmd/qrc2zip/qrc2zip.go index 16055c4..435ca7a 100644 --- a/cmd/qrc2zip/qrc2zip.go +++ b/cmd/qrc2zip/qrc2zip.go @@ -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)