Page MenuHomeFreeBSD

Fix logic error in gvinum's gv_set_sd_state()
ClosedPublic

Authored by dim on Jan 8 2017, 4:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 1 2025, 7:24 PM
Unknown Object (File)
Dec 19 2024, 11:59 AM
Unknown Object (File)
Sep 17 2024, 4:58 PM
Unknown Object (File)
Sep 8 2024, 10:45 AM
Unknown Object (File)
Sep 8 2024, 8:51 AM
Unknown Object (File)
Sep 8 2024, 5:10 AM
Unknown Object (File)
Aug 23 2024, 7:36 AM
Unknown Object (File)
Aug 12 2024, 12:56 AM
Subscribers

Details

Summary

With clang 4.0.0, I'm getting the following warnings:

sys/geom/vinum/geom_vinum_state.c:186:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
                if (!flags & GV_SETSTATE_FORCE)
                    ^      ~
sys/geom/vinum/geom_vinum_state.c:186:7: note: add parentheses after the '!' to evaluate the bitwise operator first
                if (!flags & GV_SETSTATE_FORCE)
                    ^
                     (                        )
sys/geom/vinum/geom_vinum_state.c:186:7: note: add parentheses around left hand side expression to silence this warning
                if (!flags & GV_SETSTATE_FORCE)
                    ^
                    (     )

The logical not operator should obiously be called after masking.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dim retitled this revision from to Fix logic error in gvinum's gv_set_sd_state().
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: hselasky, gjb, pfg, mav.
mav edited edge metadata.

I doubt anybody knows this code enough, but it seems logical.

This revision is now accepted and ready to land.Jan 8 2017, 4:25 PM
pfg edited edge metadata.

Nice catch, Coverity missed it completely.

This revision was automatically updated to reflect the committed changes.

I know too little of this code to comment.