From: Joel Sing Date: Sun, 27 Aug 2023 14:13:34 +0000 (+1000) Subject: cmd/internal/obj/riscv: clean up error checking for encoding X-Git-Tag: go1.22rc1~947 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7f574998534548220ae31597a5a942db2ed548c6;p=gostls13.git cmd/internal/obj/riscv: clean up error checking for encoding 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 Reviewed-by: Cherry Mui Reviewed-by: Dmitri Shuralyov Run-TryBot: Joel Sing Reviewed-by: M Zhuo --- diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go index f60abe4197..7b5621f650 100644 --- a/src/cmd/internal/obj/riscv/obj.go +++ b/src/cmd/internal/obj/riscv/obj.go @@ -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 {