Page MenuHomeFreeBSD

config: push path() into moveifchanged()
ClosedPublic

Authored by kevans on Feb 16 2023, 5:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 26 2024, 8:47 AM
Unknown Object (File)
Apr 26 2024, 8:46 AM
Unknown Object (File)
Apr 26 2024, 8:46 AM
Unknown Object (File)
Apr 26 2024, 1:39 AM
Unknown Object (File)
Apr 21 2024, 6:46 PM
Unknown Object (File)
Mar 22 2024, 11:03 PM
Unknown Object (File)
Mar 22 2024, 11:03 PM
Unknown Object (File)
Mar 22 2024, 11:03 PM
Subscribers
None

Details

Summary

Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged(). This fixes a number of memory leaks since
path() allocates memory.

While we're here, make sure we close from_fd/to_fd appropriately and
have path() error out if the allocation fails.

CID: 1471040, 1471714, 1472045, 1505250, 1006907, 1006908

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans created this revision.

These look good. I'd be half tempted to do the memory cleanup and fd leaks as separate commits, but it's not terrible if they wind up being one.

usr.sbin/config/main.cc
461

Good change, but not mentioned in commit log.

This revision is now accepted and ready to land.Feb 16 2023, 5:31 PM
emaste added inline comments.
usr.sbin/config/main.cc
611

these error messages don't necessarily have to change (I have no opinion on which is better)

usr.sbin/config/main.cc
461

This was glossed over as "have path() error out if the allocation fails."

This revision was automatically updated to reflect the committed changes.