From f057311a91acf6edd3ec97e8645522385e4822fa Mon Sep 17 00:00:00 2001 From: "Pascal S. de Kloe" Date: Tue, 30 Jul 2024 21:42:56 +0200 Subject: [PATCH] FIX: sanity check after command match --- part5.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/part5.go b/part5.go index 7127e5a..cfa6d81 100644 --- a/part5.go +++ b/part5.go @@ -58,6 +58,14 @@ var ErrOtherCmd = errors.New("part5: response for other command") // confirmation of an activation or a deactivation req(uest). Valid alternatives // may include ErrNotCmd, ErrTerm or ErrConNeg. func ConOf[Orig info.OrigAddr, Com info.ComAddr, Obj info.ObjAddr](in, req info.DataUnit[Orig, Com, Obj]) error { + // command match + if !in.Mirrors(req) { + if !isCommand(in.Type) { + return ErrNotCmd + } + return ErrOtherCmd + } + // sanity check switch req.Cause &^ info.TestFlag { case info.Act, info.Deact: @@ -67,14 +75,6 @@ func ConOf[Orig info.OrigAddr, Com info.ComAddr, Obj info.ObjAddr](in, req info. return fmt.Errorf("part5: cause %s of request not act nor deact", req.Cause) } - // command match - if !in.Mirrors(req) { - if !isCommand(in.Type) { - return ErrNotCmd - } - return ErrOtherCmd - } - // match cause of transmission, or not switch in.Cause &^ info.TestFlag { case info.ActCon: