Page MenuHomeFreeBSD

Fix issues identified by Coverity
ClosedPublic

Authored by ngie on Apr 19 2016, 10:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 1:55 AM
Unknown Object (File)
Sun, Nov 17, 9:28 PM
Unknown Object (File)
Sun, Nov 17, 5:41 PM
Unknown Object (File)
Oct 1 2024, 10:38 PM
Unknown Object (File)
Sep 29 2024, 9:35 PM
Unknown Object (File)
Sep 22 2024, 7:36 PM
Unknown Object (File)
Sep 18 2024, 7:21 PM
Unknown Object (File)
Sep 18 2024, 5:47 AM
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..