Skip to content
Open
Changes from all commits
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
10 changes: 8 additions & 2 deletions daemon/service-db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,15 @@
delete g_svcdb_instance;
}

g_svcdb_instance = new MLServiceDB (path);
try {
g_svcdb_instance = new MLServiceDB (path);

Check warning on line 880 in daemon/service-db.cc

View workflow job for this annotation

GitHub Actions / cpp-linter

daemon/service-db.cc:880:5 [cppcoreguidelines-owning-memory]

assigning newly created 'gsl::owner<>' to non-owner 'MLServiceDB *'
g_svcdb_instance->connectDB ();
} catch (const std::exception &e) {
ml_loge ("%s", e.what ());
svcdb_finalize ();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Code below is right ?

try {
    g_svcdb_instance = new MLServiceDB (path);
    g_svcdb_instance->connectDB ();
    g_assert (g_svcdb_instance);  // when succeed ?
  } catch (const std::exception &e) {
    ml_loge ("%s", e.what ());
    svcdb_finalize ();
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, db instance should be a valid pointer when calling initialization.

g_assert (g_svcdb_instance);
g_svcdb_instance->connectDB ();
}

/**
Expand Down