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

RULE-11-9: Consider more types of assignment #671

Open
lcartey opened this issue Sep 6, 2024 · 0 comments
Open

RULE-11-9: Consider more types of assignment #671

lcartey opened this issue Sep 6, 2024 · 0 comments
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium

Comments

@lcartey
Copy link
Collaborator

lcartey commented Sep 6, 2024

Affected rules

  • RULE-11-9

Description

Rule 11.9 prohibits the use of 0 as a null pointer constant when assigning to a pointer. However, we do not capture all the types of assignments. The Glossary (Appendix J) states:

Assigned

An expression is assigned if it is the subject of an assignment.

Assignment

It is sometimes convenient to use the term assignment to denote any operation which takes place as if it were by assignment. The operations covered by this term are:
• Assignment by means of one of the assignment operators;
• Passing an argument to a function, in which case the argument is copied as if by assignment to the corresponding parameter;
• Returning an expression from a function, in which case the result is copied as if by assignment to an object with the function’s return type;
• Using an expression to initialize all or part of an object, including a compound literal in C99, in which case the expression is copied as if by assignment to the destination.

This may also impact other MISRA rules that refer to the term assignment or assigned.

Example

void* myfunc() {
  return 0; // NON_COMPLIANT
}
@lcartey lcartey added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium labels Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium
Projects
Development

No branches or pull requests

1 participant