Convert WARN_UNUSED_RESULT to [[nodiscard]] in //sql.
This is an automated conversion produced by the script and command in the attached bug. Bug: 1287045 Change-Id: I9d8f3319093d304432fb5dc89b2dde7041b6b6ba Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3387847 Commit-Queue: Daniel Cheng <dcheng@chromium.org> Auto-Submit: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Victor Costan <pwnall@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/main@{#958941}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
33e7345beb
commit
1ac0cadab9
@ -14,7 +14,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/component_export.h"
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/feature_list.h"
|
||||
@ -247,7 +246,7 @@ class COMPONENT_EXPORT(SQL) Database {
|
||||
// Runs "PRAGMA quick_check" and, unlike the FullIntegrityCheck method,
|
||||
// interprets the results returning true if the the statement executes
|
||||
// without error and results in a single "ok" value.
|
||||
bool QuickIntegrityCheck() WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool QuickIntegrityCheck();
|
||||
|
||||
// Meant to be called from a client error callback so that it's able to
|
||||
// get diagnostic information about the database.
|
||||
@ -261,18 +260,18 @@ class COMPONENT_EXPORT(SQL) Database {
|
||||
|
||||
// Initializes the SQL database for the given file, returning true if the
|
||||
// file could be opened. You can call this or OpenInMemory.
|
||||
bool Open(const base::FilePath& path) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool Open(const base::FilePath& path);
|
||||
|
||||
// Initializes the SQL database for a temporary in-memory database. There
|
||||
// will be no associated file on disk, and the initial database will be
|
||||
// empty. You can call this or Open.
|
||||
bool OpenInMemory() WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool OpenInMemory();
|
||||
|
||||
// Create a temporary on-disk database. The database will be
|
||||
// deleted after close. This kind of database is similar to
|
||||
// OpenInMemory() for small databases, but can page to disk if the
|
||||
// database becomes large.
|
||||
bool OpenTemporary() WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool OpenTemporary();
|
||||
|
||||
// Returns true if the database has been successfully opened.
|
||||
bool is_open() const { return static_cast<bool>(db_); }
|
||||
@ -421,7 +420,7 @@ class COMPONENT_EXPORT(SQL) Database {
|
||||
//
|
||||
// `sql` cannot have parameters. Statements with parameters can be handled by
|
||||
// sql::Statement. See GetCachedStatement() and GetUniqueStatement().
|
||||
bool Execute(const char* sql) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool Execute(const char* sql);
|
||||
|
||||
// Executes a sequence of SQL statements.
|
||||
//
|
||||
@ -431,7 +430,7 @@ class COMPONENT_EXPORT(SQL) Database {
|
||||
// The database's error handler is not invoked when errors occur. This method
|
||||
// is a convenience for setting up a complex on-disk database state, such as
|
||||
// an old schema version with test contents.
|
||||
bool ExecuteScriptForTesting(const char* sql_script) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool ExecuteScriptForTesting(const char* sql_script);
|
||||
|
||||
// Returns a statement for the given SQL using the statement cache. It can
|
||||
// take a nontrivial amount of work to parse and compile a statement, so
|
||||
@ -724,18 +723,17 @@ class COMPONENT_EXPORT(SQL) Database {
|
||||
//
|
||||
// This is only exposed to the Database implementation. Code that uses
|
||||
// sql::Database should not be concerned with SQLite error codes.
|
||||
int ExecuteAndReturnErrorCode(const char* sql) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] int ExecuteAndReturnErrorCode(const char* sql);
|
||||
|
||||
// Like |Execute()|, but retries if the database is locked.
|
||||
bool ExecuteWithTimeout(const char* sql,
|
||||
base::TimeDelta ms_timeout) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool ExecuteWithTimeout(const char* sql,
|
||||
base::TimeDelta ms_timeout);
|
||||
|
||||
// Implementation helper for GetUniqueStatement() and GetCachedStatement().
|
||||
scoped_refptr<StatementRef> GetStatementImpl(const char* sql);
|
||||
|
||||
bool IntegrityCheckHelper(const char* pragma_sql,
|
||||
std::vector<std::string>* messages)
|
||||
WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool IntegrityCheckHelper(const char* pragma_sql,
|
||||
std::vector<std::string>* messages);
|
||||
|
||||
// Release page-cache memory if memory-mapped I/O is enabled and the database
|
||||
// was changed. Passing true for |implicit_change_performed| allows
|
||||
|
@ -81,9 +81,9 @@ class COMPONENT_EXPORT(SQL) Recovery {
|
||||
// TODO(shess): Later versions of SQLite allow extracting the path
|
||||
// from the database.
|
||||
// TODO(shess): Allow specifying the connection point?
|
||||
static std::unique_ptr<Recovery> Begin(Database* database,
|
||||
const base::FilePath& db_path)
|
||||
WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] static std::unique_ptr<Recovery> Begin(
|
||||
Database* database,
|
||||
const base::FilePath& db_path);
|
||||
|
||||
// Mark recovery completed by replicating the recovery database over
|
||||
// the original database, then closing the recovery database. The
|
||||
@ -96,7 +96,7 @@ class COMPONENT_EXPORT(SQL) Recovery {
|
||||
// TODO(shess): At this time, this function can fail while leaving
|
||||
// the original database intact. Figure out which failure cases
|
||||
// should go to RazeAndClose() instead.
|
||||
static bool Recovered(std::unique_ptr<Recovery> r) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] static bool Recovered(std::unique_ptr<Recovery> r);
|
||||
|
||||
// Indicate that the database is unrecoverable. The original
|
||||
// database is razed, and the handle poisoned.
|
||||
@ -156,9 +156,9 @@ class COMPONENT_EXPORT(SQL) Recovery {
|
||||
// such as validating constraints not expressed in the schema.
|
||||
//
|
||||
// In case of SQLITE_NOTADB, the database is deemed unrecoverable and deleted.
|
||||
static std::unique_ptr<Recovery> BeginRecoverDatabase(
|
||||
[[nodiscard]] static std::unique_ptr<Recovery> BeginRecoverDatabase(
|
||||
Database* db,
|
||||
const base::FilePath& db_path) WARN_UNUSED_RESULT;
|
||||
const base::FilePath& db_path);
|
||||
|
||||
// Call BeginRecoverDatabase() to recover the database, then commit the
|
||||
// changes using Recovered(). After this call, the |db| handle will be
|
||||
@ -188,10 +188,10 @@ class COMPONENT_EXPORT(SQL) Recovery {
|
||||
|
||||
// Setup the recovery database handle for Begin(). Returns false in
|
||||
// case anything failed.
|
||||
bool Init(const base::FilePath& db_path) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool Init(const base::FilePath& db_path);
|
||||
|
||||
// Copy the recovered database over the original database.
|
||||
bool Backup() WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool Backup();
|
||||
|
||||
// Close the recovery database, and poison the original handle.
|
||||
// |raze| controls whether the original database is razed or just
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "sql/database.h"
|
||||
|
||||
// This is not strictly necessary for the operation of ScopedErrorExpecter, but
|
||||
@ -43,7 +42,7 @@ class ScopedErrorExpecter {
|
||||
|
||||
// Return |true| if the all of the expected errors were encountered. Failure
|
||||
// to call this results in an EXPECT failure when the instance is destructed.
|
||||
bool SawExpectedErrors() WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool SawExpectedErrors();
|
||||
|
||||
private:
|
||||
// The target of the callback passed to Database::SetErrorExpecter(). If
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/files/file_path.h"
|
||||
|
||||
// Collection of test-only convenience functions.
|
||||
@ -38,7 +37,7 @@ namespace test {
|
||||
// CorruptSizeInHeaderWithLock().
|
||||
//
|
||||
// Returns false if any error occurs accessing the file.
|
||||
bool CorruptSizeInHeader(const base::FilePath& db_path) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool CorruptSizeInHeader(const base::FilePath& db_path);
|
||||
|
||||
// Common implementation of CorruptSizeInHeader() which operates on loaded
|
||||
// memory. Shared between CorruptSizeInHeader() and the the mojo proxy testing
|
||||
@ -48,8 +47,7 @@ void CorruptSizeInHeaderMemory(unsigned char* header, int64_t db_size);
|
||||
// Call CorruptSizeInHeader() while holding a SQLite-compatible lock
|
||||
// on the database. This can be used to corrupt a database which is
|
||||
// already open elsewhere. Blocks until a write lock can be acquired.
|
||||
bool CorruptSizeInHeaderWithLock(
|
||||
const base::FilePath& db_path) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool CorruptSizeInHeaderWithLock(const base::FilePath& db_path);
|
||||
|
||||
// Frequently corruption is a result of failure to atomically update
|
||||
// pages in different structures. For instance, if an index update
|
||||
@ -67,20 +65,19 @@ bool CorruptSizeInHeaderWithLock(
|
||||
// TODO(shess): It would be very helpful to allow a parameter to the
|
||||
// sql statement. Perhaps a version with a string parameter would be
|
||||
// sufficient, given affinity rules?
|
||||
bool CorruptTableOrIndex(const base::FilePath& db_path,
|
||||
const char* tree_name,
|
||||
const char* update_sql) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool CorruptTableOrIndex(const base::FilePath& db_path,
|
||||
const char* tree_name,
|
||||
const char* update_sql);
|
||||
|
||||
// Return the number of tables in sqlite_schema.
|
||||
size_t CountSQLTables(sql::Database* db) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] size_t CountSQLTables(sql::Database* db);
|
||||
|
||||
// Return the number of indices in sqlite_schema.
|
||||
size_t CountSQLIndices(sql::Database* db) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] size_t CountSQLIndices(sql::Database* db);
|
||||
|
||||
// Returns the number of columns in the named table. 0 indicates an
|
||||
// error (probably no such table).
|
||||
size_t CountTableColumns(sql::Database* db,
|
||||
const char* table) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] size_t CountTableColumns(sql::Database* db, const char* table);
|
||||
|
||||
// Sets |*count| to the number of rows in |table|. Returns false in
|
||||
// case of error, such as the table not existing.
|
||||
@ -90,13 +87,13 @@ bool CountTableRows(sql::Database* db, const char* table, size_t* count);
|
||||
// at |sql_path|. Returns false if |db_path| already exists, or if
|
||||
// sql_path does not exist or cannot be read, or if there is an error
|
||||
// executing the statements.
|
||||
bool CreateDatabaseFromSQL(const base::FilePath& db_path,
|
||||
const base::FilePath& sql_path) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] bool CreateDatabaseFromSQL(const base::FilePath& db_path,
|
||||
const base::FilePath& sql_path);
|
||||
|
||||
// Return the results of running "PRAGMA integrity_check" on |db|.
|
||||
// TODO(shess): sql::Database::IntegrityCheck() is basically the
|
||||
// same, but not as convenient for testing. Maybe combine.
|
||||
std::string IntegrityCheck(sql::Database* db) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] std::string IntegrityCheck(sql::Database* db);
|
||||
|
||||
// ExecuteWithResult() executes |sql| and returns the first column of the first
|
||||
// row as a string. The empty string is returned for no rows. This makes it
|
||||
@ -135,10 +132,10 @@ struct ColumnInfo {
|
||||
//
|
||||
// This is a static method rather than a function so it can be listed in the
|
||||
// InternalApiToken access control list.
|
||||
static ColumnInfo Create(sql::Database* db,
|
||||
const std::string& db_name,
|
||||
const std::string& table_name,
|
||||
const std::string& column_name) WARN_UNUSED_RESULT;
|
||||
[[nodiscard]] static ColumnInfo Create(sql::Database* db,
|
||||
const std::string& db_name,
|
||||
const std::string& table_name,
|
||||
const std::string& column_name);
|
||||
|
||||
// The native data type. Example: "INTEGER".
|
||||
std::string data_type;
|
||||
|
Reference in New Issue
Block a user