]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/riscv: clean up error checking for encoding
authorJoel Sing <joel@sing.id.au>
Sun, 27 Aug 2023 14:13:34 +0000 (00:13 +1000)
committerJoel Sing <joel@sing.id.au>
Fri, 8 Sep 2023 04:21:30 +0000 (04:21 +0000)
Replace a "fixme" with a more appropriate error. Also invert the condition
so that the error returns early, which is more Go idiomatic.

Change-Id: I03006572c4010fb47037bed3ee1fd7f92bfc20d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/523457
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: M Zhuo <mzh@golangcn.org>
src/cmd/internal/obj/riscv/obj.go

index f60abe4197aca18fecc0b263ca1fb12b663b10af..7b5621f65082cd6954857884bedac41f5b7bedd6 100644 (file)
@@ -1722,10 +1722,10 @@ func (ins *instruction) encode() (uint32, error) {
        if err != nil {
                return 0, err
        }
-       if enc.length > 0 {
-               return enc.encode(ins), nil
+       if enc.length <= 0 {
+               return 0, fmt.Errorf("%v: encoding called for a pseudo instruction", ins.as)
        }
-       return 0, fmt.Errorf("fixme")
+       return enc.encode(ins), nil
 }
 
 func (ins *instruction) length() int {