Page MenuHomeFreeBSD

style: Remove remaining deprecated MALLOC/FREE macros
ClosedPublic

Authored by cem on Jan 24 2018, 8:24 PM.

Details

Summary

Mechanically replace uses of MALLOC/FREE with appropriate invocations of
malloc(9) / free(9) (a series of sed expressions).

No functional change.

For now, punt on modifying contrib ipfilter code, leaving a definition of
the macro in its KMALLOC().

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

cem created this revision.Jan 24 2018, 8:24 PM
markj added a reviewer: cy.Jan 24 2018, 8:42 PM
cy accepted this revision.Jan 24 2018, 8:59 PM

The ipf bits are acceptable.

This revision is now accepted and ready to land.Jan 24 2018, 8:59 PM
imp accepted this revision.Jan 24 2018, 9:25 PM
markj accepted this revision.Jan 24 2018, 9:45 PM
cem added inline comments.Jan 24 2018, 10:41 PM
sys/fs/nfs/nfsport.h
635 ↗(On Diff #38406)

This could just be an M_ZERO allocation.

This macro is only used in 3 places. Does anyone feel strongly about getting rid of it? (Ditto the FREE version, except like 8 places.)

It could be done separately / in a subsequent patch.

markj added inline comments.Jan 25 2018, 2:57 PM
sys/fs/nfs/nfsport.h
635 ↗(On Diff #38406)

I don't see any reason to keep it, but it's rmacklem's call. It's probably best left to another patch though.

rmacklem accepted this revision.Jan 25 2018, 10:03 PM

The replacement of MALLOC/FREE in the NFS code looks ok to me.
As I noted in the inline comment, I used to care about portability to
other BSDen, but I don't any more. (None of them seem interested
in the code..)

Btw, as an historical note, some of this code is so old that I think
the 4BSD rule of "use the macros for frequently executed code,
since the macros had a fast path" might still have applied, but
obviously this is no more;-)

I could be style nitpicky and mention that many of the
MALLOC->malloc cases have resulted in short statements
over two lines that could probably bow be on a single line,
but I don't really care about this, either.

Thanks for doing this. I'm too lazy to do this kind of editting, rick.

sys/fs/nfs/nfsport.h
635 ↗(On Diff #38406)

Yea, I have no problem with replacing the NFSBZERO() with a M_ZERO flag.
There was a time when I worried about portability to other BSDen, which is
why these macros exist, but I don't much care any more, so if you have burning
desire to replace the NFSSOCKADDR() and NFSSOCKADDRALLOC() macros,
I don't mind.

cem added a comment.Jan 25 2018, 10:22 PM

I could be style nitpicky and mention that many of the
MALLOC->malloc cases have resulted in short statements
over two lines that could probably bow be on a single line,
but I don't really care about this, either.

Yep, those are intentionally left as-is for now to minimize the diff.

sys/fs/nfs/nfsport.h
635 ↗(On Diff #38406)

Ok, will do.

This revision was automatically updated to reflect the committed changes.