Bug 217879 - [ufs] couple of cppcheck findings
Summary: [ufs] couple of cppcheck findings
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-fs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-03-17 19:06 UTC by chipitsine
Modified: 2017-03-19 14:19 UTC (History)
2 users (show)

See Also:


Attachments
patch related to this issue (1.00 KB, patch)
2017-03-17 19:06 UTC, chipitsine
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chipitsine 2017-03-17 19:06:39 UTC
Created attachment 180914 [details]
patch related to this issue

cppcheck findings on UFS code (patch attached)

[sys/ufs/ffs/ffs_softdep.c:1133] -> [sys/ufs/ffs/ffs_softdep.c:1135]: (warning) Either the condition 'wk==NULL' is redundant or there is possible null pointer dereference: wk.
[sys/ufs/ffs/ffs_softdep.c:8383] -> [sys/ufs/ffs/ffs_softdep.c:8385]: (warning) Either the condition 'wk==NULL' is redundant or there is possible null pointer dereference: wk.
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2017-03-19 14:19:23 UTC
The report is false, and patch is wrong.

The code tries to find a first element of the specific type (D_JSEGDEP in case of jwork_insert, D_ALLOCDIRECT for setup_newdir).  This is done by the LIST_FOREACH() loop.  If no element was found, i.e. the condition wk == NULL after the loop, then something other is done.

The patch breaks the logic.