Skip to content

Remove a lot of unwanted ifdef'd out code#826

Closed
kinkie wants to merge 96 commits intosquid-cache:masterfrom
kinkie:remove-silly-code
Closed

Remove a lot of unwanted ifdef'd out code#826
kinkie wants to merge 96 commits intosquid-cache:masterfrom
kinkie:remove-silly-code

Conversation

@kinkie
Copy link
Contributor

@kinkie kinkie commented May 15, 2021

We examined most #if... clauses and removed those we decided are
clearly unwanted now. Most of the removed code snippets were unused for
many years or represented stale ideas. We tried to check (at least
superficially) all clauses, but most likely missed some good candidates.

@squid-anubis squid-anubis added M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels labels May 15, 2021
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for cleaning this up!

What is the exact scope of this PR? AFAICT, it is 0 and SILLY_CODE which feels rather odd. Why not add UNUSED_CODE? There is also UNREACHABLECODE to consider (among other candidates). Please explain what code this PR removes in the PR description. We cannot hope to remove every code snippet that should be removed, of course, but we should be clear about what we are removing.

src/adaptation/ecap/XactionRep.cc:#if 0 /* XXX: implement */

Also, please double check that you did not miss any 0 cases (or explicitly mention in the PR description that you left some in on purpose). AFAICT, some are still present, but I did not check carefully.

@kinkie
Copy link
Contributor Author

kinkie commented May 15, 2021 via email

@kinkie
Copy link
Contributor Author

kinkie commented May 15, 2021

Thank you for cleaning this up!

What is the exact scope of this PR? AFAICT, it is 0 and SILLY_CODE which feels rather odd. Why not add UNUSED_CODE? There is also UNREACHABLECODE to consider (among other candidates). Please explain what code this PR removes in the PR description. We cannot hope to remove every code snippet that should be removed, of course, but we should be clear about what we are removing.

I started with SILLY_CODE and if 0.
I can also go after UNUSED_CODE and UNREACHABLECODE

src/adaptation/ecap/XactionRep.cc:#if 0 /* XXX: implement */

Also, please double check that you did not miss any 0 cases (or explicitly mention in the PR description that you left some in on purpose). AFAICT, some are still present, but I did not check carefully.

I left behind about 5 intentionally.
While going over the cases, I tried to classify intent in each location, and deleted those that had clearly outlived their usefulness, or were very old and stable and unlikely to be ever used.

Those I left behind, I did because I had the impression that they served an useful purpose, maybe as documentation, maybe it an attempted and aborted implementation that might be still taken up and would be wasteful to restart from scratch.

@yadij
Copy link
Contributor

yadij commented May 16, 2021

RFC1035_UNPACK_DEBUG is defined as (void)0. This has been off forever, the intent seems quite clear to me

FYI, I turned it on privately to test the EDNS packets arriving from various DNS servers when that feature went in and first bugs found. Its just not been turned on publicly for everyone (yet).

@kinkie
Copy link
Contributor Author

kinkie commented May 16, 2021 via email

@kinkie kinkie requested a review from rousskov May 16, 2021 21:13
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinkie requested a review from rousskov 4 hours ago

If you recall, I suggested changes to the PR description (i.e. the future commit message). It looks like you have not changed it. Do you want me to edit the description to reflect (my understanding of) your response? Or perhaps this review request was just for the existing code changes, and you plan to work on the description later?

I can also go after UNUSED_CODE and UNREACHABLECODE.

Thank you. How about LINGERING_CLOSE that is marked (in comm.cc) as "broken, unused, and untested since 933dd09"? I know that code wasted quite a bit of time in relatively recent developments. IIRC, it cannot even compile since that ten-year old commit.

I would also look at #if SIZEOF_INT64_T == 4 for (hopefully) obvious reasons. If that can be removed, that would remove the whole clientHttpRequestStatus() function and quite a bit of calling code, right?

@kinkie
Copy link
Contributor Author

kinkie commented May 17, 2021 via email

@rousskov
Copy link
Contributor

I don't recall noticing that comment and when I went over the comments again on your second iteration I could not find it.

FYI: The comment came from the review heading/description at #826 (review) which was explicitly linked from the next iteration text as well. You should also have an email notification from GitHub with that same text. You did read it because you responded to (and even quoted) some of the suggestions in my text. Searching this PR page in a browser for "PR description" works as well (for me).

Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some whitespace polish needed.

I missed the fact that some of the #if 0 being removed are in the third-party libraries we ship in compat/, lib/, and includes/. Those are there to ease future sync with third-party changes from the original source source, or security patching we may have to apply.

@kinkie kinkie changed the title Remove dead code Remove ifdef'd out code May 18, 2021
@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label May 18, 2021
@kinkie
Copy link
Contributor Author

kinkie commented May 18, 2021

Other #ifdefd-code I could consider candidates for removal but would :

ADD_X_REQUEST_URI - conditionally add a header for pconn debugging
ASYNC_CREATE - default 1 since 2000
ASYNC_READ - default 1 since 2000
SSL2_VERSION
MERGING_BREAKS_NOTHING

There's a few more that I think serve some purpose as comments or work in progress although there are a lot that haven't changed in a lot of time

@kinkie
Copy link
Contributor Author

kinkie commented May 18, 2021

@rousskov , @yadij , I have - I think - gone over most if not all relevant preprocessor macros. One (httpClientRequestStatus) highlighted quite a bit of very useless code..

I have isolated most changes in a single commit to facilitate reverting if needed. Please recheck

@kinkie kinkie requested review from rousskov and yadij May 18, 2021 20:14
@rousskov
Copy link
Contributor

Amos: I missed the fact that some of the #if 0 being removed are in the third-party libraries we ship in compat/, lib/, and includes/. Those are there to ease future sync with third-party changes from the original source source, or security patching we may have to apply.

@yadij, please note that @kinkie has responded to your request but his response is currently inside the PR description:

Francesco: I can revert those if you want; but a lot of that code hasn't been touched in years. Are we talking about a theoretical or practical problem?

FWIW, I will accept whatever decision you two can agree on here. I just did not want Amos to miss Francesco's response due to its odd location. I will edit the PR description when doing the review, per Francesco's earlier request.

@kinkie
Copy link
Contributor Author

kinkie commented May 20, 2021

Amos: I missed the fact that some of the #if 0 being removed are in the third-party libraries we ship in compat/, lib/, and includes/. Those are there to ease future sync with third-party changes from the original source source, or security patching we may have to apply.

@yadij, please note that @kinkie has responded to your request but his response is currently inside the PR description:

Francesco: I can revert those if you want; but a lot of that code hasn't been touched in years. Are we talking about a theoretical or practical problem?

FWIW, I will accept whatever decision you two can agree on here. I just did not want Amos to miss Francesco's response due to its odd location. I will edit the PR description when doing the review, per Francesco's earlier request.

@yadij , any input from you on this?

@kinkie
Copy link
Contributor Author

kinkie commented May 20, 2021

I think I have addressed all outsdanding comments except for the one on third-party libraries being left alone.
Unfortunately I have shown in the past that I am challenged in navigating the github comments interface, so I may have missed some. Apologies if that's the case

I'm requesting a review to get this moving again

@kinkie kinkie requested review from rousskov and yadij May 20, 2021 06:01
@kinkie kinkie added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label May 20, 2021
@yadij
Copy link
Contributor

yadij commented May 21, 2021

Amos: I missed the fact that some of the #if 0 being removed are in the third-party libraries we ship in compat/, lib/, and includes/. Those are there to ease future sync with third-party changes from the original source source, or security patching we may have to apply.

@yadij, please note that @kinkie has responded to your request but his response is currently inside the PR description:

Francesco: I can revert those if you want; but a lot of that code hasn't been touched in years. Are we talking about a theoretical or practical problem?

The compat/ and third-party lib/ are by intention code we should not be touching regularly. So years between touches is not a sign of ability to remove code there.

The situations I mentioned are ones which have occured. Though admittedly years ago when I did an audit to see how what we could drop completely or upgrade from ancient code to newer third-party releases. smblib and rfcnb libs got security patches and upgrades respectively.

kinkie and others added 7 commits May 21, 2021 09:50
Also add comment for future work
Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
That file is being reworked as part of PR squid-cache#827
@kinkie kinkie force-pushed the remove-silly-code branch from 4582838 to e05a085 Compare May 21, 2021 09:51
@kinkie
Copy link
Contributor Author

kinkie commented May 21, 2021

@rousskov , any objections to merging?

@rousskov
Copy link
Contributor

rousskov, any objections to merging?

I still need to adjust the PR description and review the PR itself.

FYI: I am doing my best to follow a certain unofficial PR review order (subject to S-waiting-for-reviewer labels in PRs authored by folks who have permissions to set labels). As a PR author with core developer rights, you can partially control that order by using review-* labels (as documented on that linked page).

@kinkie
Copy link
Contributor Author

kinkie commented May 21, 2021 via email

@rousskov rousskov changed the title Remove ifdef'd out code Remove a lot of unwanted ifdef'd out code May 25, 2021
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest removing NOT_IMPLEMENTED as well, but I do not insist on that removal.

I changed PR title/description to better reflect the scope of this PR. Please adjust further if needed.

Please clear for merge when ready -- no need for another review round AFAICT. The remaining changes are very minor/simple (and only one -- non_get -- is required)

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels May 25, 2021
@kinkie
Copy link
Contributor Author

kinkie commented May 26, 2021

Commit c4335a6 is for me a candidate for merge, according to Alex' comment . I'll wait until tomorrow (CEST) for any last-minute requests

@rousskov rousskov dismissed their stale review May 26, 2021 15:27

The change requests in this old review were addressed and/or superseded by my no-objection comment

@rousskov rousskov added S-waiting-for-committer privileged action is expected (and usually required) and removed S-waiting-for-author author action is expected (and usually required) labels May 26, 2021
squid-anubis pushed a commit that referenced this pull request May 26, 2021
We examined most `#if...` clauses and removed those we decided are
clearly unwanted now. Most of the removed code snippets were unused for
many years or represented stale ideas. We tried to check (at least
superficially) all clauses, but most likely missed some good candidates.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label May 26, 2021
@yadij yadij added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels and removed S-waiting-for-committer privileged action is expected (and usually required) labels May 27, 2021
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 27, 2021
@kinkie kinkie deleted the remove-silly-code branch January 5, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-merged https://github.com/measurement-factory/anubis#pull-request-labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants