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)
May 8 2024, 3:58 PM
Unknown Object (File)
May 8 2024, 3:11 PM
Unknown Object (File)
Feb 23 2024, 5:00 PM
Unknown Object (File)
Jan 7 2024, 10:27 PM
Unknown Object (File)
Dec 20 2023, 12:29 AM
Unknown Object (File)
Aug 23 2023, 8:17 PM
Unknown Object (File)
Aug 13 2023, 12:46 PM
Unknown Object (File)
Aug 3 2023, 2:39 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..