Skip to content
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

Add Coccinelle rule to use NameStr #6400

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Conversation

mkindahl
Copy link
Contributor

@mkindahl mkindahl commented Dec 11, 2023

Direct access of the .data member of NameData structures are discuraged and NameStr should be used instead.

Also adding one instance that was missed in #5336.

Disable-check: force-changelog-file

@mkindahl mkindahl marked this pull request as ready for review December 11, 2023 09:31
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (36c3656) 67.59% compared to head (78dc78a) 67.55%.

Files Patch % Lines
tsl/src/deparse.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6400      +/-   ##
==========================================
- Coverage   67.59%   67.55%   -0.05%     
==========================================
  Files         232      232              
  Lines       55677    55631      -46     
  Branches    12324    12305      -19     
==========================================
- Hits        37637    37583      -54     
- Misses      16196    16205       +9     
+ Partials     1844     1843       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@antekresic, @svenklemm: please review this pull request.

Powered by pull-review

NameData E;
@@
- E.data
+ NameStr(E)
Copy link
Contributor

Choose a reason for hiding this comment

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

In other rules, we also add a comment about the problem to the source code to make the diff output easier to understand (see this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but since these are expressions inside other expressions, it will look really ugly, so I didn't add them, but I am fine with adding them if you think it is useful. I though the change was clear enough anyway.

Copy link
Member

Choose a reason for hiding this comment

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

What does it look like with a comment? I think we have a similar one for OidIsValid and it was OK. I'd add it if possible because I'm always confused by these coccinelle checks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a commit with a comment just to demonstrate how it looks.


@@
typedef NameData;
typedef Name;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this typedef is not used in this rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but it is used in a later rule, so I though it was convenient to add all at the same place for clarity.

@fabriziomello
Copy link
Contributor

@mkindahl why not adding those rules to the existing coccinelle/namedata.cocci but instead creating a new one?

@mkindahl
Copy link
Contributor Author

mkindahl commented Dec 12, 2023

@mkindahl why not adding those rules to the existing coccinelle/namedata.cocci but instead creating a new one?

Was unsure how it worked, but tested by moving it to the existing file instead.

Direct access of the `.data` member of `NameData` structures are
discuraged and `NameStr` should be used instead.

Also adding one instance that was missed in timescale#5336.
@mkindahl mkindahl enabled auto-merge (rebase) December 12, 2023 21:14
@mkindahl mkindahl merged commit 4e17247 into timescale:main Dec 12, 2023
38 of 41 checks passed
@mkindahl mkindahl deleted the cocci-namestr branch December 12, 2023 21:49
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.

5 participants