Page MenuHomeFreeBSD

Handle memory allocation errors.
Needs ReviewPublic

Authored by delphij on Jul 7 2017, 7:12 AM.

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 OK
Unit
No Unit 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 ?