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

PS-9504: Replace MY_NODISCARD with [[nodiscard]] #5488

Open
wants to merge 1 commit into
base: 8.4
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions include/my_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ constexpr bool unlikely(bool expr) { return expr; }
#define __func__ __FUNCTION__
#endif

#if defined(__cplusplus) && defined(__cpp_attributes) && \
defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard)
#define MY_NODISCARD [[nodiscard]]
#elif __has_cpp_attribute(gnu::warn_unused_result)
#define MY_NODISCARD [[gnu::warn_unused_result]]
#endif /* __has_cpp_attribute(gnu::warn_unused_result) */
#endif /* defined(__cplusplus) && defined(__cpp_attributes) && \
defined(__has_cpp_attribute) */

#ifndef MY_NODISCARD
#define MY_NODISCARD MY_ATTRIBUTE((warn_unused_result))
#endif /* MY_NODISCARD */

#if defined(_MSC_VER)
#define ALWAYS_INLINE __forceinline
#else
Expand Down
24 changes: 12 additions & 12 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,30 +529,30 @@ inline int my_b_get(IO_CACHE *info) {
return _my_b_get(info);
}

MY_NODISCARD
[[nodiscard]]
inline my_off_t my_b_tell(const IO_CACHE *info) {
return info->pos_in_file + *info->current_pos - info->request_pos;
}

MY_NODISCARD
[[nodiscard]]
inline uchar *my_b_get_buffer_start(const IO_CACHE *info) {
return info->request_pos;
}

MY_NODISCARD
[[nodiscard]]
inline size_t my_b_get_bytes_in_buffer(const IO_CACHE *info) {
return info->read_end - my_b_get_buffer_start(info);
}

MY_NODISCARD
[[nodiscard]]
inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info) {
return info->pos_in_file;
}

/* tell write offset in the SEQ_APPEND cache */
int my_b_copy_to_file(IO_CACHE *cache, FILE *file);

MY_NODISCARD
[[nodiscard]]
inline size_t my_b_bytes_in_cache(const IO_CACHE *info) {
return *info->current_end - *info->current_pos;
}
Expand Down Expand Up @@ -748,31 +748,31 @@ extern bool array_append_string_unique(const char *str, const char **array,

void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
MY_NODISCARD
[[nodiscard]]
extern int init_io_cache_ext(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
bool use_async_io, myf cache_myflags,
PSI_file_key file_key);
MY_NODISCARD
[[nodiscard]]
extern int init_io_cache(IO_CACHE *info, File file, size_t cachesize,
enum cache_type type, my_off_t seek_offset,
bool use_async_io, myf cache_myflags);
MY_NODISCARD
[[nodiscard]]
extern bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
my_off_t seek_offset, bool use_async_io,
bool clear_cache);
extern void setup_io_cache(IO_CACHE *info);
MY_NODISCARD
[[nodiscard]]
extern int _my_b_read(IO_CACHE *info, uchar *Buffer, size_t Count);
MY_NODISCARD
[[nodiscard]]
extern int _my_b_read_r(IO_CACHE *info, uchar *Buffer, size_t Count);
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
IO_CACHE *write_cache, uint num_threads);
extern void remove_io_thread(IO_CACHE *info);
MY_NODISCARD
[[nodiscard]]
extern int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count);
extern int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t Count);
MY_NODISCARD
[[nodiscard]]
extern int _my_b_write(IO_CACHE *info, const uchar *Buffer, size_t Count);
extern int my_b_append(IO_CACHE *info, const uchar *Buffer, size_t Count);
extern int my_b_safe_write(IO_CACHE *info, const uchar *Buffer, size_t Count);
Expand Down
10 changes: 5 additions & 5 deletions sql/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5553,7 +5553,7 @@ class handler {
*/

virtual bool is_ignorable_error(int error);
MY_NODISCARD virtual bool continue_partition_copying_on_error(
[[nodiscard]] virtual bool continue_partition_copying_on_error(
int error [[maybe_unused]]) {
return false;
}
Expand Down Expand Up @@ -6778,7 +6778,7 @@ class handler {
@brief Offload an update to the storage engine. See handler::fast_update()
for details.
*/
MY_NODISCARD int ha_fast_update(THD *thd,
[[nodiscard]] int ha_fast_update(THD *thd,
mem_root_deque<Item *> &update_fields,
mem_root_deque<Item *> &update_values,
Item *conds);
Expand All @@ -6787,7 +6787,7 @@ class handler {
@brief Offload an upsert to the storage engine. See handler::upsert()
for details.
*/
MY_NODISCARD int ha_upsert(THD *thd, mem_root_deque<Item *> &update_fields,
[[nodiscard]] int ha_upsert(THD *thd, mem_root_deque<Item *> &update_fields,
mem_root_deque<Item *> &update_values);

private:
Expand All @@ -6810,7 +6810,7 @@ class handler {
@note HA_READ_BEFORE_WRITE_REMOVAL flag doesn not fit there because
handler::ha_update_row(...) does not accept conditions.
*/
MY_NODISCARD virtual int fast_update(THD *thd [[maybe_unused]],
[[nodiscard]] virtual int fast_update(THD *thd [[maybe_unused]],
mem_root_deque<Item *> &update_fields
[[maybe_unused]],
mem_root_deque<Item *> &update_values
Expand All @@ -6835,7 +6835,7 @@ class handler {

@return an error if the insert should be terminated.
*/
MY_NODISCARD virtual int upsert(THD *thd [[maybe_unused]],
[[nodiscard]] virtual int upsert(THD *thd [[maybe_unused]],
mem_root_deque<Item *> &update_fields
[[maybe_unused]],
mem_root_deque<Item *> &update_values
Expand Down
2 changes: 1 addition & 1 deletion sql/partition_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ static inline void init_all_partitions_iterator(partition_info *part_info,
@return true - On failure.
@return false - On success.
*/
MY_NODISCARD
[[nodiscard]]
bool fill_first_partition_name(const partition_info *part_info,
const char *normalized_path, char *first_name);

Expand Down
2 changes: 1 addition & 1 deletion sql/set_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ collation_unordered_map<std::string, sys_var *>
extern bool get_sysvar_source(const char *name, uint length,
enum enum_variable_source *source);

MY_NODISCARD
[[nodiscard]]
int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool opened);
bool keyring_access_test();
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static bool is_name_in_list(const char *name, List<String> list_names) {
false Success
*/

MY_NODISCARD
[[nodiscard]]
static bool partition_default_handling(Partition_handler *part_handler,
partition_info *part_info,
bool is_create_table_ind,
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info,
@retval true - On failure.
@retval false - On success.
*/
MY_NODISCARD
[[nodiscard]]
bool get_first_partition_name(THD *thd, Partition_handler *part_handler,
const char *normalized_path,
const char *partition_info_str,
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/handler/ha_innodb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ will be closed before the index creation/drop.
@param[in,out] share share structure where index translation table
will be constructed in.
@return true if index translation table built successfully */
MY_NODISCARD
[[nodiscard]]
bool innobase_build_index_translation(const TABLE *table,
dict_table_t *ib_table,
INNOBASE_SHARE *share);
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/data0data.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ occupied by the field structs or the tuple struct is not counted.
@param[in] tuple typed data tuple
@param[in] comp nonzero=ROW_FORMAT=COMPACT
@return sum of data lens */
MY_NODISCARD
[[nodiscard]]
static inline ulint dtuple_get_data_size(const dtuple_t *tuple, ulint comp);
/** Compare two data tuples.
@param[in] tuple1 first data tuple
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/dict0crea.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static const constexpr auto ZIP_DICT_MAX_DATA_LENGTH = 32506;
@param[out] dict_id dict id
@param[in,out] trx transaction
@return error code or DB_SUCCESS */
MY_NODISCARD
[[nodiscard]]
dberr_t dict_create_get_zip_dict_id_by_reference(table_id_t table_id,
ulint column_pos,
ulint *dict_id, trx_t *trx);
Expand All @@ -134,7 +134,7 @@ Must be freed with my_free().
@param[out] data_len dict data length
@param[in,out] trx transaction
@return error code or DB_SUCCESS */
MY_NODISCARD
[[nodiscard]]
dberr_t dict_create_get_zip_dict_info_by_id(ulint dict_id, char **name,
ulint *name_len, char **data,
ulint *data_len, trx_t *trx);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/dict0dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ extern bool dict_upgrade_zip_dict_missing;
@param[out] dict_id zip_dict id
@retval DB_SUCCESS if OK
@retval DB_RECORD_NOT_FOUND if not found */
MY_NODISCARD
[[nodiscard]]
dberr_t dict_get_dictionary_id_by_key(table_id_t table_id, ulint column_pos,
ulint *dict_id);

Expand All @@ -1679,7 +1679,7 @@ Must be freed with mem_free().
@param[out] data_len dictionary data length
@retval DB_SUCCESS if OK
@retval DB_RECORD_NOT_FOUND if not found */
MY_NODISCARD
[[nodiscard]]
dberr_t dict_get_dictionary_info_by_id(ulint dict_id, char **name,
ulint *name_len, char **data,
ulint *data_len);
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/dict0load.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ information from the record and returns to caller.
@param[out] data dict data
@param[out] data_len dict data length
@return error message, or NULL on success */
MY_NODISCARD
[[nodiscard]]
const char *dict_process_sys_zip_dict(mem_heap_t *heap,
const dict_index_t &index,
const rec_t *rec, ulint *id,
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ inline void fil_space_open_if_needed(fil_space_t *space) {
/** Enable encryption of temporary tablespace
@param[in,out] space tablespace object
@return DB_SUCCESS on success, DB_ERROR on failure */
MY_NODISCARD
[[nodiscard]]
dberr_t fil_temp_update_encryption(fil_space_t *space);

#ifdef UNIV_LINUX
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/fsp0fsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ uint32_t fsp_flags_to_dict_tf(uint32_t fsp_flags, bool compact);
/** Enable encryption for already existing tablespace.
@param[in,out] space tablespace object
@return true if success, else false */
MY_NODISCARD
[[nodiscard]]
bool fsp_enable_encryption(fil_space_t *space);

/** Calculates the descriptor index within a descriptor page.
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/include/ha_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void thd_set_lock_wait_time(THD *thd,
/** Is FT ignore stopwords variable set.
@param thd Thread object
@return true if ft_ignore_stopwords is set, false otherwise. */
MY_NODISCARD
[[nodiscard]]
bool thd_has_ft_ignore_stopwords(THD *thd) noexcept;

/** Get the value of innodb_tmpdir.
Expand Down Expand Up @@ -473,13 +473,13 @@ void innobase_commit_low(trx_t *trx);

/** Get the transaction of the current connection handle, if either exists.
@return transaction of the current connection handle or NULL. */
MY_NODISCARD
[[nodiscard]]
trx_t *innobase_get_trx(void);

/** Get the transaction of the current connection handle if slow query log
InnoDB extended statistics should be collected.
@return transaction object if statistics should be collected, or NULL. */
MY_NODISCARD
[[nodiscard]]
trx_t *innobase_get_trx_for_slow_log(void) noexcept;

extern bool innodb_inited;
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/os0enc.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class Encryption {
specified explicitly
@param[in] algorithm Encryption algorithm to check
@return true if no algorithm explicitly requested */
MY_NODISCARD static bool none_explicitly_specified(
[[nodiscard]] static bool none_explicitly_specified(
bool explicit_encryption, const char *algorithm) noexcept;

/** Generate random encryption value for key and iv.
Expand Down Expand Up @@ -379,7 +379,7 @@ class Encryption {
byte *tmp, ulint tmp_len) const noexcept;

/** Check if keyring plugin loaded. */
MY_NODISCARD static bool check_keyring() noexcept;
[[nodiscard]] static bool check_keyring() noexcept;

/** Get encryption type
@return encryption type **/
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/os0file.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ class IORequest {
}

/** @return true if the page write should not be encrypted */
MY_NODISCARD bool is_encryption_disabled() const noexcept {
[[nodiscard]] bool is_encryption_disabled() const noexcept {
return ((m_type & NO_ENCRYPTION) != 0);
}

Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/os0thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ using Atomic_xor_of_thread_id =
thread. On Linux, returns tid. On other systems currently returns
os_thread_get_curr_id().
@return current thread identifier */
MY_NODISCARD os_tid_t os_thread_get_tid() noexcept;
[[nodiscard]] os_tid_t os_thread_get_tid() noexcept;

/** Set relative scheduling priority for a given thread on
Linux. Currently a no-op on other systems.
@param[in] thread_id thread id
@param[in] relative_priority system-specific priority value
@return An actual thread priority after the update */
MY_NODISCARD
[[nodiscard]]
unsigned long int os_thread_set_priority(
os_tid_t thread_id, unsigned long int relative_priority) noexcept;

Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/include/row0log.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ ulint row_log_estimate_work(const dict_index_t *index);

/** Find out if temporary log files encrypted.
@return true if temporary log file should be encrypted, false if not */
MY_NODISCARD
[[nodiscard]]
bool log_tmp_is_encrypted() noexcept;

/** Check the row log encryption is enabled or not.
Expand All @@ -226,7 +226,7 @@ void log_tmp_enable_encryption_if_set();
@param[in] offs offset to block
@param[in] space_id tablespace id
@return whether the operation succeeded */
MY_NODISCARD
[[nodiscard]]
bool log_tmp_block_encrypt(const byte *src_block, ulint size, byte *dst_block,
os_offset_t offs, space_id_t space_id);

Expand All @@ -237,7 +237,7 @@ bool log_tmp_block_encrypt(const byte *src_block, ulint size, byte *dst_block,
@param[in] offs offset to block
@param[in] space_id tablespace id
@return whether the operation succeeded */
MY_NODISCARD
[[nodiscard]]
bool log_tmp_block_decrypt(const byte *src_block, ulint size, byte *dst_block,
os_offset_t offs, space_id_t space_id);

Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/row0mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void row_mysql_prebuilt_free_compress_heap(row_prebuilt_t *prebuilt) noexcept;
@param[in] compress_heap memory heap used to compress/decompress
blob column
@return pointer to the uncompressed data */
MY_NODISCARD
[[nodiscard]]
const byte *row_decompress_column(const byte *data, ulint *len,
const byte *dict_data, ulint dict_data_len,
mem_heap_t **compress_heap);
Expand All @@ -128,7 +128,7 @@ const byte *row_decompress_column(const byte *data, ulint *len,
@param[in] compress_heap memory heap used to compress/decompress
blob column
@return pointer to the compressed data */
MY_NODISCARD
[[nodiscard]]
byte *row_compress_column(const byte *data, ulint *len, ulint lenlen,
const byte *dict_data, ulint dict_data_len,
mem_heap_t **compress_heap);
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/srv0srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ void srv_master_thread_disabled_debug_update(THD *thd, SYS_VAR *var,
innodb_temp_tablespace_encrypt is TRUE
@param[in] enable true to enable encryption, false to disable
@return DB_SUCCESS on success, DB_ERROR on failure */
MY_NODISCARD
[[nodiscard]]
dberr_t srv_temp_encryption_update(bool enable);

/** Status variables to be passed to MySQL */
Expand Down
Loading
Loading