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

Couple quick fixes/suggestions #27637

Open
wants to merge 5 commits into
base: bugfix-2.1.x
Choose a base branch
from

Conversation

classicrocker883
Copy link
Contributor

@classicrocker883 classicrocker883 commented Jan 12, 2025

Description

Under PlatformIO icon > Project Tasks > STM32F103RE_creality (or any other selected board) > Advanced > Check

this will perform a sort of debugging check, and I found some things that probably could use improvements.

For types.h

Warning

[low:style] Parameter 'data' can be declared as const array [constParameter] indicates that the parameter data can be declared as a constant array because it is not modified inside the constructor. Specifically, you're passing data[] as an array of uint8_t values to the constructor, but you don't modify the array, just use a reference to an element in it.

Problem

The warning suggests that you should use const for the data parameter to ensure that it is not accidentally modified, and to communicate clearly that the array will not be changed within the constructor.

Solution

Since you're only using data_ to refer to a specific element in the array and never modifying the array itself, you should declare data[] as a const uint8_t[] in the constructor.

Conclusion

However, making these changing causes errors.


Actual changes

Removed forward declaration of

  
// Forward declaration does not seem to be necessary 
class AxisBits;

class AxisBits {
public:
...

Used class BitProxy; as forward declaration instead

Requirements

Benefits

Configurations

Related Issues

One of these checks could be looked into.

Marlin/src/core/types.h:788: [low:performance] Function parameter 'pxy' should be passed by const reference. [passedByValue]

this basically is saying to add & to FI void set(const XYval<T> &pxy) ... to be passed by reference instead of value, which may free up some space or what not.

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.

1 participant