Skip to content

Davem/refactor warnings pl #19667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Closed

Davem/refactor warnings pl #19667

wants to merge 11 commits into from

Conversation

iabyn
Copy link
Contributor

@iabyn iabyn commented Apr 25, 2022

Refactor regen/warnings.pl. The src for this tool was a mess: it started out 20 years ago as a small utility, then grew. Lots of badly-named global variables, no comments about what subs do etc. This series of commits cleans things up, refactors, adds comments etc. In theory it makes no functional changes, and indeed as run currently it generates exactly the same warnings.h and lib/warning.pm files as before.

I think this can be safely merged before 5.36.0. It's a tool that's only used when developing the perl interpreter (and then only when adding a new warnings category), so even if were broken, it would make no different to an end user of 5.36.0.

Copy link
Contributor

@hvds hvds left a comment

Choose a reason for hiding this comment

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

All looks good to me. In commit messages:
s/orderValues()/valueWalk()/ in "eliminate broken dup check"
s/on;y/only/ in "eliminate global %v_list var"

Now that %tree has been renamed, it would also be nice to rename the various in-function $tre variables to $tree.

Copy link
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

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

LGTM

I'm in two minds about whether to merge it before 5.36 or not. As you observe, it's only used as part of the regen process when we add a new warning, which we're not going to do before 5.36. So on the one hand adding it now won't affect anything, but on the other hand there's no urgent need to.

We could merge it now, or apply the "defer-next-dev" tag to remind us to do it as part of 5.37 startup.

Copy link
Contributor

@Leont Leont left a comment

Choose a reason for hiding this comment

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

Given the fact that verifying it doesn't change any output is trivial, I don't really see a reason to postpone it.

@iabyn
Copy link
Contributor Author

iabyn commented Apr 29, 2022 via email

iabyn added 11 commits April 29, 2022 10:04
Move a couple of large chunks of <<'EOF' code text to the end of the file
(but before __END__) to make the flow of code easier to see.

The output generated is unchanged.
$offset was added in 2000, but hasn't actually been used for a long while
A block of code no longer declares any lexical variables, so remove the
block. Apart from removing a '{' and '}', this is a whitespace-only
change.
various lexical vars like $tree, $def are populated early on, then their
values are used later in many places, including directly in subs.

Rename these vars to be uppercase and with more meaningful names, to
emphasise their globalness.

(Ideally they really ought to be local and passed as arguments to all
the subs that use them, but that's more work.)
This doesn't seem to be used any more
This lexical had global scope. Instead, make it a parameter to
sub valueWalk(), since it's only used temporarily by two subs.
valueWalk() checks for a duplicate warnings name. However,
1) This is also done in walk(), so is redundant.
2) It is broken. Originally it declared @list but checked %list;
%list is global and was renamed to %CATEGORIES to make it clear it was a
global (and thus unrelated to @list). So its probably never worked.
rename my($warn, $pm) to ($warn_h, $warn_pm) to make it easier to
see that they're the filehandles for warnings.h and warnings.pm
Explain this structure, which is the input used to define all the
warnings.
Since the global variable $tree was renamed $TREE, we can now rename all
the instances of a sub parameter $tre to '$tree'.
@iabyn iabyn force-pushed the davem/refactor_warnings_pl branch from 9f1f50d to e2f858e Compare April 29, 2022 09:26
@iabyn
Copy link
Contributor Author

iabyn commented Apr 29, 2022

rebased, fixed the commit msgs and s/tre/tree as suggested by Hugo

@hvds
Copy link
Contributor

hvds commented Apr 29, 2022

rebased, fixed the commit msgs and s/tre/tree as suggested by Hugo

+1

@iabyn
Copy link
Contributor Author

iabyn commented May 4, 2022

I've now merged this. I'm not going to be very available for the next week or so, so if it causes any issues, feel free to revert it.

@iabyn iabyn closed this May 4, 2022
@iabyn iabyn deleted the davem/refactor_warnings_pl branch May 4, 2022 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants