Skip to content

Enforce C standard compliance and fix ACPI null pointer dereference - #22

Closed
ghost wants to merge 2 commits into
mainfrom
unknown repository
Closed

ghost wants to merge 2 commits into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented May 12, 2022

Copy link
Copy Markdown

Simple fix for a minor compiler warning to dip my toes into this codebase.

@CLAassistant

CLAassistant commented May 12, 2022 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Det87

Det87 commented May 12, 2022

Copy link
Copy Markdown

Is C90 still relevant?

@baryluk

baryluk commented May 12, 2022

Copy link
Copy Markdown

NACK

Conforming strictly to C90 makes code less readable.

Leave it as is and just bump flags to the compiler to use gnu99.

@jackghg

jackghg commented May 12, 2022

Copy link
Copy Markdown

pointless

@ghost

ghost commented May 12, 2022 •

Copy link
Copy Markdown
Author

I agree that c99 is a much better, more readable and more relevant standard, but I'd guess that the standard NVIDIA is using here was a deliberate choice so this PR just falls in line. Also as a note, commenting that a PR is pointless discourages new contributors from engaging, and ultimately just hurts the project since it doesn't influence NVIDIA's decision to merge or close it.

@jackghg

jackghg commented May 12, 2022

Copy link
Copy Markdown

speachless

@ghost ghost changed the title Remove mixed declarations and code to comply with C standard Enforce C standard compliance and fix ACPI null pointer dereference May 12, 2022
@ghost ghost mentioned this pull request May 12, 2022
@ghost

ghost commented May 12, 2022

Copy link
Copy Markdown
Author

This PR now also addresses issue #109

@ryao

ryao commented May 13, 2022

Copy link
Copy Markdown

I feel like there should be 1 PR per issue. Also, most projects do not like to see merge commits in PRs. Each logical change should be its own commit, but merge commits just document how things were put into the git repository, which make them clutter. I suggest rebasing, cherry-picking and force pushing to clean up the PR.

@ghost

ghost commented May 13, 2022

Copy link
Copy Markdown
Author

I feel like there should be 1 PR per issue. Also, most projects do not like to see merge commits in PRs. Each logical change should be its own commit, but merge commits just document how things were put into the git repository, which make them clutter. I suggest rebasing, cherry-picking and force pushing to clean up the PR.

Thanks for the friendly advice, I'm relatively new to open-source contributing and it's nice to be given some constructive advice. I went ahead and cleaned up the merge commit, but I don't necessarily want this PR to get drowned out so I won't be splitting the commits into separate PRs (however that's duly noted for the future, I know it's not ideal for the maintainers).

@mtijanic

Copy link
Copy Markdown
Collaborator

For context, our guidelines (which we hope to publish soon) generally say that we should prefer C90 in the general case due to some UB related to C99 mixed declarations, but strict C90 compatibility is not a goal and it is okay to use C99 style declarations when there is a strong justification to deviate from the guidelines.

Also, for what it's worth, some of the platforms we support from the shared codebases will accept most C99 features but not for (int i;;), so this one is avoided more strictly.

@ghost

ghost commented May 13, 2022 •

Copy link
Copy Markdown
Author

For context, our guidelines (which we hope to publish soon) generally say that we should prefer C90 in the general case due to some UB related to C99 mixed declarations, but strict C90 compatibility is not a goal and it is okay to use C99 style declarations when there is a strong justification to deviate from the guidelines.

Also, for what it's worth, some of the platforms we support from the shared codebases will accept most C99 features but not for (int i;;), so this one is avoided more strictly.

Thanks for clarifying. I made this change initially based on the C90 standard, but it was also consistency with other functions within the file and as such makes sense to implement for coherence reasons as well.

Also a quick note for reviewers since I just saw the CONTRIBUTING update: this PR isn't exclusively for cosmetic/readability.

@ghost

ghost commented May 17, 2022

Copy link
Copy Markdown
Author

Hello, just checking in - any updates? Normally I wouldn't bump an issue like this, but there have been several PRs reviewed since this one.

Comment thread kernel-open/nvidia/nv-acpi.c Resolved
@mtijanic

Copy link
Copy Markdown
Collaborator

As @ryao mentioned, it is best to not group unrelated changes into a single PR. Particularly if they also touch different kernel modules, as these are often maintained by different people and have to be merged separately anyway.

My advice is to close this and open new individual PRs per issue (or class of issues) that you want to address. Keeping in mind that cosmetic stuff will just be tagged appropriately and deferred for now.

By the way, this device null deref is only partially fixed, as NV_ACPI_BUS_GET_DEVICE_PRESENT could be undefined in which case your nullcheck is skipped.

@ghost

ghost commented May 17, 2022

Copy link
Copy Markdown
Author

Alright, thank you all for the explanation and your time.

@ghost

ghost commented May 17, 2022

Copy link
Copy Markdown
Author

This PR's useful changes to nv_acpi.c have been modified with the suggestions above and migrated to #216.

@jackghg

jackghg commented May 24, 2022

Copy link
Copy Markdown

kernel just moved to c11... just to let you know...

This pull request was closed.
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.

7 participants