Skip to content

Commit

Permalink
Fix missing "misc-const-correctness" hits in headers (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiselik authored Jan 8, 2025
1 parent 2464086 commit e1f5db0
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion sources/isal/igzip/bitbuf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static inline uint32_t buffer_bits_used(struct BitBuf2* me) {

static inline void flush_bits(struct BitBuf2* me) {
store_u64(me->m_out_buf, me->m_bits);
uint32_t bits = me->m_bit_count & ~7;
const uint32_t bits = me->m_bit_count & ~7;
me->m_bit_count -= bits;
me->m_out_buf += bits / 8;
me->m_bits >>= bits;
Expand Down
26 changes: 13 additions & 13 deletions sources/isal/igzip/huffman.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ static inline void get_dist_code(struct isal_hufftables* hufftables, uint32_t di
assert(dist >= 1U);
assert(dist <= 32768U);
if (dist <= IGZIP_DIST_TABLE_SIZE) {
uint64_t code_len = hufftables->dist_table[dist - 1U];
*code = code_len >> 5;
*len = code_len & 0x1F;
const uint64_t code_len = hufftables->dist_table[dist - 1U];
*code = code_len >> 5;
*len = code_len & 0x1F;
} else {
compute_dist_code(hufftables, dist, code, len);
}
Expand All @@ -117,9 +117,9 @@ static inline void get_len_code(struct isal_hufftables* hufftables, uint32_t len
assert(length >= 3U);
assert(length <= 258U);

uint64_t code_len = hufftables->len_table[length - 3U];
*code = code_len >> 5;
*len = code_len & 0x1F;
const uint64_t code_len = hufftables->len_table[length - 3U];
*code = code_len >> 5;
*len = code_len & 0x1F;
}

static inline void get_lit_code(struct isal_hufftables* hufftables, uint32_t lit, uint64_t* code, uint64_t* len) {
Expand All @@ -131,10 +131,10 @@ static inline void get_lit_code(struct isal_hufftables* hufftables, uint32_t lit

static void compute_dist_icf_code(uint32_t dist, uint32_t* code, uint32_t* extra_bits) {
dist -= 1U;
uint32_t msb = bsr(dist);
const uint32_t msb = bsr(dist);
assert(msb >= 2U);
uint32_t num_extra_bits = msb - 2U;
*extra_bits = dist & ((1 << num_extra_bits) - 1);
const uint32_t num_extra_bits = msb - 2U;
*extra_bits = dist & ((1 << num_extra_bits) - 1);
dist >>= num_extra_bits;
*code = dist + 2U * num_extra_bits;
assert(*code < 30U);
Expand Down Expand Up @@ -225,7 +225,7 @@ static inline int compare258(uint8_t* str1, uint8_t* str2, uint32_t max_length)

if (max_length > 258U) max_length = 258U;

uint64_t loop_length = max_length & ~0x7;
const uint64_t loop_length = max_length & ~0x7;

for (; count < loop_length; count += 8U) {
test = load_u64(str1);
Expand Down Expand Up @@ -276,9 +276,9 @@ static inline int compare258(uint8_t* str1, uint8_t* str2, uint32_t max_length)
* @param max_length: length of the smaller string.
*/
static inline int compare(uint8_t* str1, uint8_t* str2, uint32_t max_length) {
uint32_t count = 0U;
uint64_t test = 0U;
uint64_t loop_length = max_length & ~0x7;
uint32_t count = 0U;
uint64_t test = 0U;
const uint64_t loop_length = max_length & ~0x7;

for (; count < loop_length; count += 8U) {
test = load_u64(str1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class deflate_state_builder<execution_path_t::hardware> {

public:
static auto create(const util::linear_allocator& allocator) noexcept -> common_type {
bool init_compress_body = true;
const bool init_compress_body = true;
common_type builder(allocator, init_compress_body);

builder.state_.processing_step = util::multitask_status::multi_chunk_first_chunk;
Expand All @@ -186,12 +186,12 @@ class deflate_state_builder<execution_path_t::hardware> {
}

static auto restore(const util::linear_allocator& allocator) noexcept -> common_type {
bool init_compress_body = false;
const bool init_compress_body = false;
return common_type(allocator, init_compress_body);
};

static auto restore_with_init(const util::linear_allocator& allocator) noexcept -> common_type {
bool init_compress_body = true;
const bool init_compress_body = true;
return common_type(allocator, init_compress_body);
};

Expand Down
4 changes: 2 additions & 2 deletions sources/middle-layer/util/descriptor_processing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ inline auto process_descriptor(hw_descriptor* const desc
completion_record_ptr->status = AD_STATUS_INPROG;

auto enqueue_status = hw_enqueue_descriptor(descriptor_ptr, numa_id);
uint32_t status =
convert_hw_accelerator_status_to_qpl_status(enqueue_status); //NOLINT(misc-const-correctness)
uint32_t status = //NOLINT(misc-const-correctness)
convert_hw_accelerator_status_to_qpl_status(enqueue_status);
if (status_list::ok != status) {
if constexpr (std::is_same<decltype(status), return_t>::value) {
return status;
Expand Down
6 changes: 3 additions & 3 deletions tools/tests/common/analytic_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class AnalyticFixture
status = qpl_execute_job(deflate_job_ptr);

if (QPL_STS_OK != status) {
std::string error_message = "Compression returned " + std::to_string(status) + " status\n";
const std::string error_message = "Compression returned " + std::to_string(status) + " status\n";
throw std::runtime_error(error_message);
}

Expand Down Expand Up @@ -182,8 +182,8 @@ class AnalyticFixture
actual_out_bit_width = current_test_case.source_bit_width;
}

uint32_t dest_size = current_test_case.number_of_elements *
((actual_out_bit_width + max_bit_index) >> bit_to_byte_shift_offset);
const uint32_t dest_size = current_test_case.number_of_elements *
((actual_out_bit_width + max_bit_index) >> bit_to_byte_shift_offset);

std::fill(destination.begin(), destination.end(), 0);
std::fill(reference_destination.begin(), reference_destination.end(), 0);
Expand Down
10 changes: 5 additions & 5 deletions tools/tests/common/analytic_mask_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ class AnalyticMaskFixture : public AnalyticFixture {

ASSERT_NO_THROW(mask = mask_gen.get_source()); //NOLINT(cppcoreguidelines-avoid-goto)

uint32_t destination_bit_width = (1U == current_test_case.destination_bit_width)
? current_test_case.source_bit_width
: current_test_case.destination_bit_width;
const uint32_t destination_bit_width = (1U == current_test_case.destination_bit_width)
? current_test_case.source_bit_width
: current_test_case.destination_bit_width;

uint32_t destination_size = current_test_case.number_of_elements *
((destination_bit_width + max_bit_index) >> bit_to_byte_shift_offset);
const uint32_t destination_size = current_test_case.number_of_elements *
((destination_bit_width + max_bit_index) >> bit_to_byte_shift_offset);

destination.resize(destination_size);
reference_destination.resize(destination_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class BaseAnalyticsNegativeTestFixture : public JobFixture {

ASSERT_NO_THROW(source = source_gen.get_source()); //NOLINT(cppcoreguidelines-avoid-goto)

uint32_t actual_out_bit_width =
const uint32_t actual_out_bit_width =
(job_ptr->out_bit_width == qpl_ow_nom) ? job_ptr->src1_bit_width : 4U << (job_ptr->out_bit_width);

uint32_t dest_size =
const uint32_t dest_size =
job_ptr->num_input_elements * ((actual_out_bit_width + max_bit_index) >> bit_to_byte_shift_offset);

std::fill(destination.begin(), destination.end(), 0);
Expand Down Expand Up @@ -81,7 +81,7 @@ class BaseAnalyticsNegativeTestFixture : public JobFixture {
status = run_job_api(deflate_job_ptr);

if (QPL_STS_OK != status) {
std::string error_message = "Compression returned " + std::to_string(status) + " status\n";
const std::string error_message = "Compression returned " + std::to_string(status) + " status\n";
throw std::runtime_error(error_message);
}

Expand Down Expand Up @@ -129,7 +129,7 @@ class BaseAnalyticsNegativeTestFixture : public JobFixture {
job_ptr->available_in = static_cast<uint32_t>(source_is_short.size());
job_ptr->next_in_ptr = source_is_short.data();

testing::AssertionResult testStatus = RunStatusTest(QPL_STS_SRC_IS_SHORT_ERR);
const testing::AssertionResult testStatus = RunStatusTest(QPL_STS_SRC_IS_SHORT_ERR);

job_ptr->available_in = static_cast<uint32_t>(source.size());
job_ptr->next_in_ptr = source.data();
Expand Down
4 changes: 2 additions & 2 deletions tools/utils/common/huffman_table_unique.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ namespace qpl::test {
static qpl_huffman_table_t deflate_huffman_table_maker(const qpl_huffman_table_type_e type, const qpl_path_t path,
const allocator_t allocator) {
qpl_huffman_table_t table_ptr = nullptr;
qpl_status status = qpl_deflate_huffman_table_create(type, path, allocator, &table_ptr);
const qpl_status status = qpl_deflate_huffman_table_create(type, path, allocator, &table_ptr);
if (status != QPL_STS_OK) table_ptr = nullptr;
return table_ptr;
}

static qpl_huffman_table_t huffman_only_huffman_table_maker(const qpl_huffman_table_type_e type, const qpl_path_t path,
const allocator_t allocator) {
qpl_huffman_table_t table_ptr = nullptr;
qpl_status status = qpl_huffman_only_table_create(type, path, allocator, &table_ptr);
const qpl_status status = qpl_huffman_only_table_create(type, path, allocator, &table_ptr);
if (status != QPL_STS_OK) table_ptr = nullptr;
return table_ptr;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/utils/common/opcfg_checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ inline bool is_opcfg_capabilities_present() {
inline bool is_operation_disabled_on_all_wq_on_node(qpl_test_opcodes opcode) {
if (!is_opcfg_capabilities_present()) { return false; }

bool is_op_disabled = true;
int32_t numa_id = get_numa_id();
const bool is_op_disabled = true;
const int32_t numa_id = get_numa_id();

#if defined(__linux__)
static auto& dispatcher = hw_dispatcher::get_instance();
Expand Down

0 comments on commit e1f5db0

Please sign in to comment.