Bug 229551 - src/sys/dev/trm/trm.c:2484: bad if logic
Summary: src/sys/dev/trm/trm.c:2484: bad if logic
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-scsi (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-07-05 20:28 UTC by David Binderman
Modified: 2019-02-16 00:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2018-07-05 20:28:18 UTC
src/sys/dev/trm/trm.c:2484] -> [src/sys/dev/trm/trm.c:2486]: (warning) Identical inner 'if' condition is always true.

Source code is

 if ((((ptr->Vers & 0x07) >= 2) ||
                                              ((ptr->RDF & 0x0F) == 2)) &&
                                            (ptr->Flags & SCSI_INQ_CMDQUEUE) &&
                                            (pDCB->DevMode & TAG_QUEUING_) &&
                                            (pDCB->DevMode & EN_DISCONNECT_)) {
                                                if (pDCB->DevMode &
                                                    TAG_QUEUING_) {
                                                        pDCB->
                                                            MaxActiveCommandCnt =
                                                          pACB->TagMaxNum;
                                                        pDCB->SyncMode |=
                                                          EN_TAG_QUEUING;
                                                        pDCB->tinfo.disc_tag |=
                                                          TRM_CUR_TAGENB;
                                                } else {

Duplicate in the TAG_QUEUING. Else clause can never run.
Comment 1 Andriy Voskoboinyk freebsd_committer freebsd_triage 2019-02-16 00:53:21 UTC
I assume that

(pDCB->DevMode & TAG_QUEUING_) && (pDCB->DevMode & EN_DISCONNECT_)

should be changed to

((pDCB->DevMode & TAG_QUEUING_) || (pDCB->DevMode & EN_DISCONNECT_))

however, I don't think this fix should be committed to the tree without testing with real device and / or specs verification.