From 7f574998534548220ae31597a5a942db2ed548c6 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Mon, 28 Aug 2023 00:13:34 +1000 Subject: [PATCH] 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 --- src/cmd/internal/obj/riscv/obj.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 { -- 2.50.0