Skip to content

Coverity rule of 4#3803

Open
dkalinowski wants to merge 5 commits intomainfrom
coverity5
Open

Coverity rule of 4#3803
dkalinowski wants to merge 5 commits intomainfrom
coverity5

Conversation

@dkalinowski
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@rasapala rasapala left a comment

Choose a reason for hiding this comment

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

find other classes with missing definitions

it->second->shutdown();
}

class ModulesShutdownGuard {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@dkalinowski dkalinowski changed the title [2026.0] rule of 4 Coverity rule of 4 Feb 6, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 13:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements the "Rule of 4" for RAII guard classes by explicitly deleting copy and move constructors and assignment operators. This prevents accidental copying or moving of resource management objects that should have unique ownership semantics.

Changes:

  • Added deleted special member functions to ModulesShutdownGuard class
  • Added deleted special member functions to OvmsExitGuard class
  • Added deleted special member functions to V3StreamCallbackResourceGuard class

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/server.cpp Added deleted copy/move constructors and assignment operators to ModulesShutdownGuard and OvmsExitGuard guard classes
src/http_rest_api_handler.cpp Added deleted copy/move constructors and assignment operators to V3StreamCallbackResourceGuard class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +446 to +447
OvmsExitGuard& operator=(OvmsExitGuard&&) = delete;
OvmsExitGuard(OvmsExitGuard&&) = delete;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The order of deleted special member functions is inconsistent. The move assignment operator appears before the move constructor, while in ModulesShutdownGuard the move constructor appears before the move assignment operator. For consistency and readability, follow the canonical order: copy constructor, copy assignment, move constructor, move assignment.

Suggested change
OvmsExitGuard& operator=(OvmsExitGuard&&) = delete;
OvmsExitGuard(OvmsExitGuard&&) = delete;
OvmsExitGuard(OvmsExitGuard&&) = delete;
OvmsExitGuard& operator=(OvmsExitGuard&&) = delete;

Copilot uses AI. Check for mistakes.
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