Page MenuHomeFreeBSD

Fix issues identified by Coverity
ClosedPublic

Authored by ngie on Apr 19 2016, 10:49 PM.
Tags
None
Referenced Files
F105715985: D6012.diff
Thu, Dec 19, 3:18 PM
Unknown Object (File)
Sat, Dec 14, 10:52 AM
Unknown Object (File)
Thu, Dec 5, 10:03 AM
Unknown Object (File)
Mon, Nov 25, 8:16 PM
Unknown Object (File)
Mon, Nov 25, 8:14 PM
Unknown Object (File)
Nov 18 2024, 1:55 AM
Unknown Object (File)
Nov 17 2024, 9:28 PM
Unknown Object (File)
Nov 17 2024, 5:41 PM
Subscribers

Details

Reviewers
markj
Summary

Fix issues identified by Coverity

  • Always munmap memory regions after mmap'ing them.
  • Make sure getpagesize() returns a value greater than 0 and use a cached value instead of always calling getpagesize(3).
  • Remove intermediate variable for assigning from $TMPDIR if set in the environment to eliminate warnings about pointer conversions with "/tmp", and to mute an invalid buffer overflow concern from Coverity (snprintf and tacking on a NUL terminator was alleviating that concern before).
  • Remove useless self-test of psize before it's initialized.
  • Check the return values of getrlimit/setrlimit.

Cosmetic changes:

  • Replace a (void*)0 with NULL.
  • Do some minor whitespace clean up.
  • Remove an unnecessary cast to mmap.

CID: 1331351, 1331382-1331386, 1331513, 1331514, 1331565, 1331583, 1331694
MFC after: 2 weeks
Reported by: Coverity
Sponsored by: EMC / Isilon Storage Division

Test Plan

sudo kyua test -k /usr/tests/sys/posixshm

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 3333
Build 3368: arc lint + arc unit

Event Timeline

ngie retitled this revision from to Fix issues identified by Coverity.
ngie updated this object.
ngie edited the test plan for this revision. (Show Details)
ngie added subscribers: cem, markj.
lib/libc/gen/getpagesize.c
56 ↗(On Diff #15351)

Ignore this part; I'm going to commit this separately (I wish arc diff --create didn't grab everything in one's workspace..)

Remove getpagesize.c portion that accidentally snuck into the previous diff

markj added a reviewer: markj.

Looks ok to me.

tests/sys/posixshm/posixshm_test.c
174

In some places the return value of munmap() is checked, and in others it isn't.

This revision is now accepted and ready to land.Apr 19 2016, 11:04 PM
ngie marked an inline comment as done.
ngie added inline comments.
tests/sys/posixshm/posixshm_test.c
174

Fixed by using ATF_REQUIRE_MSG consistently. The old idiom was a bit awkward..