Page MenuHomeFreeBSD

Handle memory allocation errors.
Needs ReviewPublic

Authored by delphij on Jul 7 2017, 7:12 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 5 2024, 5:37 PM
Unknown Object (File)
Dec 25 2023, 9:38 AM
Unknown Object (File)
Dec 20 2023, 3:41 AM
Unknown Object (File)
Dec 27 2022, 9:50 AM
Subscribers

Details

Reviewers
kib
kevlo
emaste
Summary

Make init(8) more tolerate when memory allocation failed.

While there also eliminate use of strerror() by utilizing
existing library functionality.

Diff Detail

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

Event Timeline

I think that the patch should be split. Right now it is a mix of style, s/0/NULL/, use of %m, minor code fixes and so on.

sbin/init/init.c
666

It would be useful to print path in the error message.

689

And there too. But, in fact, I do not see much sense in checking close(2) error.

1259

The added NULL assignments above the free() line are pointless, the memory is freed.

1286

It would be useful to printf line which asprintf() was unable to handle.

1702
sp->se_getty != NULL ? strdup() : ...

Are you leaving strdup() result unchecked ?

1711

Write this as == NULL for all tests ?