Skip to content

Commit

Permalink
FIX: sanity check after command match
Browse files Browse the repository at this point in the history
  • Loading branch information
pascaldekloe committed Jul 30, 2024
1 parent 015c0f7 commit f057311
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions part5.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit f057311

Please sign in to comment.