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

MISRA compliance #77

Closed
sanderh255 opened this issue Dec 24, 2021 · 12 comments
Closed

MISRA compliance #77

sanderh255 opened this issue Dec 24, 2021 · 12 comments
Labels
help wanted Extra attention is needed resolved-on-develop A changeset fixing this issue has been commiutted to the development branch task

Comments

@sanderh255
Copy link

Critical embedded systems (medical and safety related) often require MISRA compliance. It would be great to implement this for the printf library.

@eyalroz eyalroz added help wanted Extra attention is needed task labels Dec 24, 2021
@eyalroz
Copy link
Owner

eyalroz commented Dec 24, 2021

You'll need to be more specific about what that means.

@sanderh255
Copy link
Author

MISRA is a set of guidelines for safety critical code. It includes things like restricting the usage of dynamic memory allocation (which is one of the reasons this project is pretty cool), avoiding side-effect in conditional statements and using clear control flow (single return point in a function, and not using break to terminate a loop). These rules may or may not be to your taste, so I would like to implement them in a personal fork so you can decide whether or not this is something you'd like to include.

@eyalroz
Copy link
Owner

eyalroz commented Dec 24, 2021

restricting the usage of dynamic memory allocation (which is one of the reasons this project is pretty cool)

Indeed, there is no dynamic memory allocation in libprintf.

avoiding side-effect in conditional statements

You mean, ternary operator applications? I have some of these which do a va_arg().

These rules may or may not be to your taste, so I would like to implement them in a personal fork so you can decide whether or not this is something you'd like to include.

Ok, sure. Please try to avoid any other changes though. When you have a PR, I'll consider it. Is there some sort of MISRA verification you want to have run? You could perhaps write a GitHub action for that.

eyalroz pushed a commit that referenced this issue Jan 5, 2022
eyalroz pushed a commit that referenced this issue Jan 5, 2022
…y be preceded by other preprocessor directives or comments.
eyalroz pushed a commit that referenced this issue Jan 5, 2022
… be used with either a preceding `&`, or with a parenthesized parameter list, which may be empty.
eyalroz pushed a commit that referenced this issue Jan 5, 2022
…sed. ... so, when printf is used in C++, we use the C++-version of the C library headers.
eyalroz pushed a commit that referenced this issue Jan 5, 2022
…-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
@eyalroz
Copy link
Owner

eyalroz commented Jan 5, 2022

So, I think this covers everything except the use of raw types.

Is there an online MISRA compliance checker, by the way?

@sanderh255
Copy link
Author

sanderh255 commented Jan 5, 2022

We use SonarQube (https://www.sonarqube.org/) which does have a free edition, but this edition does not include coverage for C/C++.
The only free one I'm aware of is https://www.sonarlint.org/, which comes in the form of an IDE plugin.

@eyalroz
Copy link
Owner

eyalroz commented Jan 5, 2022

MISRA specs links (for myself...):

@sanderh255
Copy link
Author

It does seem the last commits somehow caused #if PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS to be duplicated instead of moved. It is now on line 417 and 513, but there does not seem to be a terminating #endif.
Did you mean to remove the one on line 513?

eyalroz added a commit that referenced this issue Jan 5, 2022
eyalroz added a commit that referenced this issue Jan 5, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
@eyalroz
Copy link
Owner

eyalroz commented Jan 5, 2022

Umm... I don't see a duplicate #if... if it had existed, compilation should have failed.

@sanderh255
Copy link
Author

You're right, my bad. I seem to be unable to keep my fork up to date with your changes. Merging your changes into my develop did not do what I would expect it to.

@eyalroz
Copy link
Owner

eyalroz commented Jan 5, 2022

@sanderh255 : I'm partly to blame, since I often rewrite the history of the develop branch. Only master is safe in that respect. So when working with the develop branch here it's usually better to rebase -i develop , and remove the redundant commits from the todo list.

@sanderh255
Copy link
Author

sanderh255 commented Jan 5, 2022 via email

eyalroz added a commit that referenced this issue Jan 6, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
eyalroz pushed a commit that referenced this issue Jan 8, 2022
eyalroz pushed a commit that referenced this issue Jan 8, 2022
…y be preceded by other preprocessor directives or comments.
eyalroz pushed a commit that referenced this issue Jan 8, 2022
… be used with either a preceding `&`, or with a parenthesized parameter list, which may be empty.
eyalroz pushed a commit that referenced this issue Jan 8, 2022
…sed. ... so, when printf is used in C++, we use the C++-version of the C library headers.
eyalroz pushed a commit that referenced this issue Jan 8, 2022
…-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
eyalroz added a commit that referenced this issue Jan 8, 2022
eyalroz added a commit that referenced this issue Jan 8, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
eyalroz pushed a commit that referenced this issue Jan 9, 2022
…sed. ... so, when printf is used in C++, we use the C++-version of the C library headers.
eyalroz pushed a commit that referenced this issue Jan 9, 2022
…-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
eyalroz added a commit that referenced this issue Jan 9, 2022
eyalroz added a commit that referenced this issue Jan 9, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
@eyalroz
Copy link
Owner

eyalroz commented Jan 25, 2022

So, I think we're done with this issue. If I've missed something, please reopen.

@eyalroz eyalroz closed this as completed Jan 25, 2022
@eyalroz eyalroz added the resolved-on-develop A changeset fixing this issue has been commiutted to the development branch label Jan 25, 2022
eyalroz pushed a commit that referenced this issue Jan 26, 2022
eyalroz pushed a commit that referenced this issue Jan 26, 2022
…y be preceded by other preprocessor directives or comments.
eyalroz pushed a commit that referenced this issue Jan 26, 2022
… be used with either a preceding `&`, or with a parenthesized parameter list, which may be empty.
eyalroz pushed a commit that referenced this issue Jan 26, 2022
…sed. ... so, when printf is used in C++, we use the C++-version of the C library headers.
eyalroz pushed a commit that referenced this issue Jan 26, 2022
…-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
eyalroz added a commit that referenced this issue Jan 26, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
eyalroz pushed a commit that referenced this issue Feb 21, 2022
eyalroz pushed a commit that referenced this issue Feb 21, 2022
…y be preceded by other preprocessor directives or comments.
eyalroz pushed a commit that referenced this issue Feb 21, 2022
… be used with either a preceding `&`, or with a parenthesized parameter list, which may be empty.
eyalroz pushed a commit that referenced this issue Feb 21, 2022
…sed. ... so, when printf is used in C++, we use the C++-version of the C library headers.
eyalroz pushed a commit that referenced this issue Feb 21, 2022
…-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of `#` or `##`.
eyalroz added a commit that referenced this issue Feb 21, 2022
* More use of typedef's over raw primitive C types. Specifically, using `printf_size_t` in many relevant places
* Regards #77
* Removed redundant parentheses
* Comment tweaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed resolved-on-develop A changeset fixing this issue has been commiutted to the development branch task
Projects
None yet
Development

No branches or pull requests

2 participants