Page MenuHomeFreeBSD

readelf(1): Speed up readelf -wo
ClosedPublic

Authored by borako.ozarslan_gmail.com on Jan 14 2019, 8:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 10, 6:58 AM
Unknown Object (File)
Jan 29 2024, 5:22 PM
Unknown Object (File)
Jan 22 2024, 11:12 AM
Unknown Object (File)
Dec 23 2023, 12:29 AM
Unknown Object (File)
Dec 11 2023, 12:12 AM
Unknown Object (File)
Dec 9 2023, 12:21 AM
Unknown Object (File)
Dec 2 2023, 3:08 AM
Unknown Object (File)
Nov 29 2023, 5:51 PM

Details

Reviewers
emaste
markj
Summary

Speed up readelf -wo by using an array instead of STAILQ and instead of adding new elements ordered, sorting them after the list is complete.

PR: 212539
Submitted by: Bora Ozarslan borako.ozarslan@gmail.com

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Sorry it took a while to get to this. Most of my comments are style nits.

readelf/readelf.c
5923 ↗(On Diff #52837)

"comparator"?

5926 ↗(On Diff #52837)

style(9) disallows mixed declaration and initialization.

5933 ↗(On Diff #52837)

Per style(9), continuation lines should be indented by four spaces.

5991 ↗(On Diff #52837)

style: there should be a space after control-flow keywords.

5992 ↗(On Diff #52837)

Memory allocation failures should be handled to be consistent within this program. Ditto below.

6002 ↗(On Diff #52837)

This can be written as *la_list_len++;.

6370 ↗(On Diff #52837)

BSD style(9) discourages C++ comments in C code.

Comments should be full sentences.

6376 ↗(On Diff #52837)

style(9) discourages nested declarations; these should be declared at the beginning of the function.

6385 ↗(On Diff #52837)

Are we leaking la_list here?

It also looks as though this check should logically come before we attempt to sort and remove duplicates.

I think you uploaded the diff between the first and second revision rather than the revision as a whole - could you upload the full diff?

contrib/elftoolchain/readelf/readelf.c
6051

Style: missing newline after declarations.

6121

The indentation should be by four spaces.

6126–6134

I'd suggest using a local variable for (*la_list)[*la_list_len].

6144

Style: indentation.

6152

Indentation.

6441

Extra calloc() call.

6464

Indentation.

6513

Style: missing space after for and if below.

For consistency with the rest of the code, postfix increment should be used in loop headers in places where it doesn't matter.

6518

You can just write duplicates++.

6523

Don't you want to subtract duplicates from la_list_len here?

Looks ok to me, modulo a couple more style nits.

contrib/elftoolchain/readelf/readelf.c
6074

This declaration should be at the top: wider types come first.

6124

errx() doesn't return, so the return statement is redundant.

This revision is now accepted and ready to land.Feb 22 2019, 6:06 PM
This revision now requires review to proceed.Feb 22 2019, 8:05 PM
This revision is now accepted and ready to land.Feb 22 2019, 8:33 PM
contrib/elftoolchain/readelf/readelf.c
6056

This feels too clever to me; would prefer a standard

if (left->la_off > right->la_off)
        return (1);
else if (left->la_off < right->la_off)
        return (-1);
else
        return (0);

markj@, your thoughts?
(I can just apply that change locally upon commit.)

contrib/elftoolchain/readelf/readelf.c
6056

I prefer your version too.