Skip to content

CXX-3043 Address Coverity warnings for Ro3/Ro5 violations #1142

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

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class value {
value(const value&);
value& operator=(const value&);

value(value&&) noexcept = default;
value& operator=(value&&) noexcept = default;
value(value&&) = default;
value& operator=(value&&) = default;

///
/// Get a view over the document owned by this value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class array : public sub_array {
return *this;
}

array(const array&) = delete;
array& operator=(const array&) = delete;

///
/// @return A view of the BSON array.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class document : public sub_document {
///
BSONCXX_INLINE document() : sub_document(&_core), _core(false) {}

~document() = default;

///
/// Move constructor
///
Expand All @@ -56,6 +58,9 @@ class document : public sub_document {
return *this;
}

document(const document&) = delete;
document& operator=(const document&) = delete;

///
/// @return A view of the BSON document.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ namespace builder {
struct concatenate_doc {
document::view_or_value doc;

// MSVC seems to need a hint that it should always
// inline this destructor.
BSONCXX_INLINE ~concatenate_doc() = default;

///
/// Conversion operator that provides a view of the wrapped concatenate
/// document.
Expand Down Expand Up @@ -64,10 +60,6 @@ struct concatenate_doc {
struct concatenate_array {
array::view_or_value array;

// MSVC seems to need a hint that it should always
// inline this destructor.
BSONCXX_INLINE ~concatenate_array() = default;

///
/// Conversion operator that provides a view of the wrapped concatenate
/// array.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class core {

~core();

core(const core&) = delete;
core& operator=(const core&) = delete;

///
/// Appends a key passed as a non-owning stdx::string_view.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ class value {
///
explicit value(document::view view);

~value() = default;

value(const value&);
value& operator=(const value&);

value(value&&) noexcept = default;
value& operator=(value&&) noexcept = default;
value(value&&) = default;
value& operator=(value&&) = default;

///
/// Constructor used for serialization of user objects. This uses argument-dependent lookup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class view_or_value : public bsoncxx::v_noabi::view_or_value<stdx::string_view,
///
/// Default constructor, equivalent to using an empty string.
///
BSONCXX_INLINE view_or_value() = default;
view_or_value() = default;

///
/// Construct a string::view_or_value using a null-terminated const char *.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ class view_or_value {
static_assert(std::is_default_constructible<View>::value,
"View type must be default constructible");

///
/// Destroys a view_or_value.
///
~view_or_value() = default;

///
/// Default-constructs a view_or_value. This is equivalent to constructing a
/// view_or_value with a default-constructed View.
///
BSONCXX_INLINE view_or_value() = default;
view_or_value() = default;

///
/// Construct a view_or_value from a View. When constructed with a View,
Expand Down
5 changes: 5 additions & 0 deletions src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/private/itoa.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class BSONCXX_TEST_API itoa {
public:
explicit itoa(uint32_t i = 0);

~itoa() = default;

itoa(itoa&& rhs) = delete;
itoa& operator=(itoa&&) = delete;

itoa(const itoa& rhs) = delete;
itoa& operator=(const itoa&) = delete;

Expand Down
6 changes: 6 additions & 0 deletions src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/private/stack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class stack {
}
}

stack(stack&&) = delete;
stack& operator=(stack&&) = delete;

stack(const stack&) = delete;
stack& operator=(const stack&) = delete;

bool empty() const {
return _is_empty;
}
Expand Down
3 changes: 3 additions & 0 deletions src/mongocxx/include/mongocxx/v_noabi/mongocxx/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class client {
///
~client();

client(const client&) = delete;
client& operator=(const client&) = delete;

///
/// Returns true if the client is valid, meaning it was not default constructed
/// or moved from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ class client_encryption {
///
/// Destroys a client_encryption.
///
~client_encryption() noexcept;
~client_encryption();

///
/// Move-constructs a client_encryption object.
///
client_encryption(client_encryption&&);
client_encryption(client_encryption&&) noexcept;

///
/// Move-assigns a client_encryption object.
///
client_encryption& operator=(client_encryption&&);
client_encryption& operator=(client_encryption&&) noexcept;

client_encryption(const client_encryption&) = delete;
client_encryption& operator=(const client_encryption&) = delete;
Expand Down
3 changes: 3 additions & 0 deletions src/mongocxx/include/mongocxx/v_noabi/mongocxx/cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class cursor {
///
~cursor();

cursor(const cursor&) = delete;
cursor& operator=(const cursor&) = delete;

///
/// A cursor::iterator that points to the beginning of any available
/// results. If begin() is called more than once, the cursor::iterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class command_failed_event {
///
~command_failed_event();

command_failed_event(command_failed_event&&) = default;
command_failed_event& operator=(command_failed_event&&) = default;

command_failed_event(const command_failed_event&) = default;
command_failed_event& operator=(const command_failed_event&) = default;

///
/// Returns the server’s reply to the failed operation.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class command_started_event {
///
~command_started_event();

command_started_event(command_started_event&&) = default;
command_started_event& operator=(command_started_event&&) = default;

command_started_event(const command_started_event&) = default;
command_started_event& operator=(const command_started_event&) = default;

///
/// Returns the command that has been started.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class command_succeeded_event {
///
~command_succeeded_event();

command_succeeded_event(command_succeeded_event&&) = default;
command_succeeded_event& operator=(command_succeeded_event&&) = default;

command_succeeded_event(const command_succeeded_event&) = default;
command_succeeded_event& operator=(const command_succeeded_event&) = default;

///
/// Returns the server reply for the succeeded operation.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class heartbeat_failed_event {
///
~heartbeat_failed_event();

heartbeat_failed_event(heartbeat_failed_event&&) = default;
heartbeat_failed_event& operator=(heartbeat_failed_event&&) = default;

heartbeat_failed_event(const heartbeat_failed_event&) = default;
heartbeat_failed_event& operator=(const heartbeat_failed_event&) = default;

///
/// Returns the failed operation's error message.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class heartbeat_started_event {
///
~heartbeat_started_event();

heartbeat_started_event(heartbeat_started_event&&) = default;
MONGOCXX_INLINE heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
MONGOCXX_INLINE heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =
heartbeat_started_event& operator=(heartbeat_started_event&&) noexcept =

default;

heartbeat_started_event(const heartbeat_started_event&) = default;
heartbeat_started_event& operator=(const heartbeat_started_event&) = default;

///
/// Returns the host name.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class heartbeat_succeeded_event {
///
~heartbeat_succeeded_event();

heartbeat_succeeded_event(heartbeat_succeeded_event&&) = default;
heartbeat_succeeded_event& operator=(heartbeat_succeeded_event&&) = default;

heartbeat_succeeded_event(const heartbeat_succeeded_event&) = default;
heartbeat_succeeded_event& operator=(const heartbeat_succeeded_event&) = default;

///
/// Returns the server reply for the succeeded operation.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class server_changed_event {
///
~server_changed_event();

server_changed_event(server_changed_event&&) = default;
server_changed_event& operator=(server_changed_event&&) = default;

server_changed_event(const server_changed_event&) = default;
server_changed_event& operator=(const server_changed_event&) = default;

///
/// Returns the server host name.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ class server_closed_event {
///
~server_closed_event();

server_closed_event(server_closed_event&&) = default;
server_closed_event& operator=(server_closed_event&&) = default;

server_closed_event(const server_closed_event&) = default;
server_closed_event& operator=(const server_closed_event&) = default;

///
/// Returns the server host name.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class server_description {
///
~server_description();

server_description(server_description&&) = default;
server_description& operator=(server_description&&) = default;

server_description(const server_description&) = default;
server_description& operator=(const server_description&) = default;

///
/// An opaque id, unique to this server for this mongocxx::v_noabi::client or
/// mongocxx::v_noabi::pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class server_opening_event {
///
~server_opening_event();

server_opening_event(server_opening_event&&) = default;
server_opening_event& operator=(server_opening_event&&) = default;

server_opening_event(const server_opening_event&) = default;
server_opening_event& operator=(const server_opening_event&) = default;

///
/// Returns the server host name.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class topology_changed_event {
///
~topology_changed_event();

topology_changed_event(topology_changed_event&&) = default;
topology_changed_event& operator=(topology_changed_event&&) = default;

topology_changed_event(const topology_changed_event&) = default;
topology_changed_event& operator=(const topology_changed_event&) = default;

///
/// An opaque id, unique to this topology for this mongocxx::v_noabi::client or
/// mongocxx::v_noabi::pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class topology_closed_event {
///
~topology_closed_event();

topology_closed_event(topology_closed_event&&) = default;
topology_closed_event& operator=(topology_closed_event&&) = default;

topology_closed_event(const topology_closed_event&) = default;
topology_closed_event& operator=(const topology_closed_event&) = default;

///
/// An opaque id, unique to this topology for this mongocxx::v_noabi::client or
/// mongocxx::v_noabi::pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class topology_description {
///
~topology_description();

topology_description(topology_description&&) = default;
topology_description& operator=(topology_description&&) = default;

topology_description(const topology_description&) = default;
topology_description& operator=(const topology_description&) = default;

///
/// The topology type: "Unknown", "Sharded", "ReplicaSetNoPrimary", "ReplicaSetWithPrimary", or
/// "Single".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class topology_opening_event {
///
~topology_opening_event();

topology_opening_event(topology_opening_event&&) = default;
topology_opening_event& operator=(topology_opening_event&&) = default;

topology_opening_event(const topology_opening_event&) = default;
topology_opening_event& operator=(const topology_opening_event&) = default;

///
/// An opaque id, unique to this topology for this mongocxx::v_noabi::client or
/// mongocxx::v_noabi::pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ class index_model {
///
index_model(const index_model&);

index_model& operator=(const index_model&) = delete;
///
/// Copy assigns an index_model.
///
index_model& operator=(const index_model&) = default;

///
/// Destroys an index_model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class index_view {

~index_view();

index_view(const index_view&) = delete;
index_view& operator=(const index_view&) = delete;

///
/// @{
///
Expand Down
3 changes: 3 additions & 0 deletions src/mongocxx/include/mongocxx/v_noabi/mongocxx/instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class instance {
///
~instance();

instance(const instance&) = delete;
instance& operator=(const instance&) = delete;

///
/// Returns the current unique instance of the driver. If an instance was explicitly created,
/// that will be returned. If no instance has yet been created, a default instance will be
Expand Down
Loading