[Bug 229715] src/lib/libdevstat/devstat.c:760]: (style) Redundant condition

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jul 12 09:46:41 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229715

            Bug ID: 229715
           Summary: src/lib/libdevstat/devstat.c:760]: (style) Redundant
                    condition
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs at FreeBSD.org
          Reporter: dcb314 at hotmail.com

src/lib/libdevstat/devstat.c:760]: (style) Redundant condition:
(matches[i].match_fields&DEVSTAT_MATCH_PASS)==0. 'A || (!A && B)' is equivalent
to 'A || B'
[src/lib/libdevstat/devstat.c:769]: (style) Redundant condition:
(matches[i].match_fields&DEVSTAT_MATCH_PASS)==0. 'A || (!A && B)' is equivalent
to 'A || B'

Source code is

                        if ((((matches[i].match_fields &
DEVSTAT_MATCH_TYPE)!=0)
                          && ((devices[j].device_type & DEVSTAT_TYPE_MASK) ==
                                (matches[i].device_type & DEVSTAT_TYPE_MASK))
                          &&(((matches[i].match_fields &
DEVSTAT_MATCH_PASS)!=0)
                           || (((matches[i].match_fields &
                                DEVSTAT_MATCH_PASS) == 0)
                            && ((devices[j].device_type &
                                DEVSTAT_TYPE_PASS) == 0)))
                          && (--num_match_categories == 0))
                         || (((matches[i].match_fields & DEVSTAT_MATCH_IF) !=
0)
                          && ((devices[j].device_type & DEVSTAT_TYPE_IF_MASK)
==
                                (matches[i].device_type &
DEVSTAT_TYPE_IF_MASK))
                          &&(((matches[i].match_fields &
DEVSTAT_MATCH_PASS)!=0)
                           || (((matches[i].match_fields &
                                DEVSTAT_MATCH_PASS) == 0)
                            && ((devices[j].device_type &
                                DEVSTAT_TYPE_PASS) == 0)))
                          && (--num_match_categories == 0))
                         || (((matches[i].match_fields &
DEVSTAT_MATCH_PASS)!=0)
                          && ((devices[j].device_type & DEVSTAT_TYPE_PASS) !=
0)
                          && (--num_match_categories == 0))) {

20 or so lines of if statement could IMHO do with some simplifying.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list