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

Make single-argument string constructors explicit #2707

Merged
merged 150 commits into from
Apr 30, 2024

Conversation

bocchino
Copy link
Collaborator

@bocchino bocchino commented Apr 29, 2024

This PR makes single-argument string constructors explicit, where possible with the current code generation. Explicit single-argument constructors are recommended (including by the static analysis in this repo) because they avoid unwanted implicit conversions.

Note the following:

  • This PR incorporates the changes from Update to FPP v2.1.0a10 #2703. Review and merge that one first.
  • I revised the FSW and test code as necessary to eliminate implicit string conversions. In some cases they were doing implicit string copies that were not necessary.
  • For parameter, event, and telemetry strings, and for the char * constructor of Fw::String, we can't make the single-argument constructors explicit until we close this issue: Revise generated C++ that relies on implicit string constructors fpp#421.

bocchino and others added 30 commits December 7, 2022 13:35
TimeBaseStoreType is not the same as TimeBase
Cast to the TimeBaseStore type with a known size
Remove unnecessary const casting
@bocchino bocchino requested a review from LeStarch April 29, 2024 21:12
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

bocchino and others added 2 commits April 29, 2024 15:13
Remove explicit from char* constructor
The autocoder depends on the implicit constructor
Fw/Types/StringBase.cpp Outdated Show resolved Hide resolved

TaskString(const char* src) : StringBase() { *this = src; }
explicit TaskString(const char* src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

TaskString(const StringBase& src) : StringBase() { *this = src; }
explicit TaskString(const StringBase& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

TaskString() : StringBase() { *this = ""; }

TaskString(const TaskString& src) : StringBase() { *this = src; }
explicit TaskString(const TaskString& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

ObjectName(const char* src) : StringBase() { *this = src; }
explicit ObjectName(const char* src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

ObjectName(const StringBase& src) : StringBase() { *this = src; }
explicit ObjectName(const StringBase& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

FileNameString(const char* src) : StringBase() { *this = src; }
explicit FileNameString(const char* src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

FileNameString(const StringBase& src) : StringBase() { *this = src; }
explicit FileNameString(const StringBase& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.
};

FileNameString() : StringBase() { *this = ""; }

FileNameString(const FileNameString& src) : StringBase() { *this = src; }
explicit FileNameString(const FileNameString& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.
};

String() : StringBase() { *this = ""; }

String(const String& src) : StringBase() { *this = src; }
explicit String(const String& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

String(const StringBase& src) : StringBase() { *this = src; }
explicit String(const StringBase& src) : StringBase() { *this = src; }

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.
@LeStarch LeStarch merged commit cdac751 into nasa:devel Apr 30, 2024
48 checks passed
@bocchino bocchino deleted the string-explicit branch June 4, 2024 20:52
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.

2 participants