Skip to content

Commit

Permalink
Enable all compilation warnings, and fix a few of them.
Browse files Browse the repository at this point in the history
These warnings are not promoted to errors are some of them might come from Rcpp
and we don't have any control over that.
  • Loading branch information
LTLA committed Aug 6, 2023
1 parent 4b8a0c4 commit a239a0c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/tatami_r/COO_SparseMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Parsed<Data_, Index_> parse_COO_SparseMatrix_internal(Rcpp::RObject seed, InputO
}

const size_t nnz = temp_i.nrow();
if (nnz != val.size()) {
if (nnz != static_cast<size_t>(val.size())) {
auto ctype = get_class_name(seed);
throw std::runtime_error(std::string("incompatible 'nzcoo' and 'nzdata' lengths in a ") + ctype + " object");
}
Expand Down
14 changes: 7 additions & 7 deletions include/tatami_r/UnknownMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class UnknownMatrix : public tatami::Matrix<Value_, Index_> {
}

cache_size = cache;
if (cache_size == -1) {
if (cache_size == static_cast<size_t>(-1)) {
Rcpp::Function fun = delayed_env["getAutoBlockSize"];
Rcpp::NumericVector output = fun();
if (output.size() != 1 || output[0] < 0) {
Expand Down Expand Up @@ -179,8 +179,8 @@ class UnknownMatrix : public tatami::Matrix<Value_, Index_> {

// We define the number of chunks in the extracted block,
// as well as the size of the extracted block itself.
Index_ max_block_size_in_chunks;
Index_ max_block_size_in_elements;
size_t max_block_size_in_chunks;
size_t max_block_size_in_elements;

// No oracle, we just go for blocks.
Index_ primary_block_start, primary_block_len;
Expand Down Expand Up @@ -317,8 +317,8 @@ class UnknownMatrix : public tatami::Matrix<Value_, Index_> {

template<bool byrow_, bool sparse_, bool sparse_err = sparse_>
void check_buffered_dims(const tatami::Matrix<Value_, Index_>* parsed, const Workspace<sparse_>* work) const {
size_t parsed_primary = (byrow_ ? parsed->nrow() : parsed->ncol());
size_t parsed_secondary = (byrow_ ? parsed->ncol() : parsed->nrow());
Index_ parsed_primary = (byrow_ ? parsed->nrow() : parsed->ncol());
Index_ parsed_secondary = (byrow_ ? parsed->ncol() : parsed->nrow());

if (parsed_primary != work->primary_block_len || parsed_secondary != work->secondary_len) {
auto ctype = get_class_name(original_seed);
Expand Down Expand Up @@ -551,12 +551,12 @@ class UnknownMatrix : public tatami::Matrix<Value_, Index_> {
// Need to adjust the indices.
if (output.index) {
if constexpr(selection_ == tatami::DimensionSelectionType::BLOCK) {
for (size_t i = 0; i < output.number; ++i) {
for (Index_ i = 0; i < output.number; ++i) {
ibuffer[i] = output.index[i] + this->block_start;
}
output.index = ibuffer;
} else if constexpr(selection_ == tatami::DimensionSelectionType::INDEX) {
for (size_t i = 0; i < output.number; ++i) {
for (Index_ i = 0; i < output.number; ++i) {
ibuffer[i] = this->indices[output.index[i]];
}
output.index = ibuffer;
Expand Down
3 changes: 2 additions & 1 deletion tests/src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ PKG_CPPFLAGS=-I../../include \
-Wformat \
-Werror=format-security \
-Wdate-time \
-D_FORTIFY_SOURCE=2
-D_FORTIFY_SOURCE=2 \
-Wall -Wextra -Wpedantic
6 changes: 0 additions & 6 deletions tests/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ Rcpp::List sparse_rows(Rcpp::RObject parsed) {
RatXPtr ptr(parsed);

size_t nr = ptr->nrow();
size_t nc = ptr->ncol();
Rcpp::List output(nr);

auto wrk = ptr->sparse_row();
Expand All @@ -267,7 +266,6 @@ Rcpp::List sparse_rows_subset(Rcpp::RObject parsed, int first, int last) {
RatXPtr ptr(parsed);

size_t nr = ptr->nrow();
size_t len = last - first + 1;
Rcpp::List output(nr);

auto wrk = ptr->sparse_row(first - 1, last - first + 1);
Expand All @@ -284,7 +282,6 @@ Rcpp::List sparse_rows_subset(Rcpp::RObject parsed, int first, int last) {
Rcpp::List sparse_columns(Rcpp::RObject parsed) {
RatXPtr ptr(parsed);

size_t nr = ptr->nrow();
size_t nc = ptr->ncol();
Rcpp::List output(nc);

Expand All @@ -303,7 +300,6 @@ Rcpp::List sparse_columns_subset(Rcpp::RObject parsed, int first, int last) {
RatXPtr ptr(parsed);

size_t nc = ptr->ncol();
size_t len = last - first + 1;
Rcpp::List output(nc);

auto wrk = ptr->sparse_column(first - 1, last - first + 1);
Expand Down Expand Up @@ -410,7 +406,6 @@ Rcpp::List sparse_rows_guided(Rcpp::RObject parsed, Rcpp::IntegerVector targets)
auto wrk = ptr->sparse_row();
auto copy = prepare_indices(targets, wrk);

size_t nc = ptr->ncol();
Rcpp::List output(copy.size());
size_t counter = 0;
for (auto r : copy) {
Expand All @@ -428,7 +423,6 @@ Rcpp::List sparse_columns_guided(Rcpp::RObject parsed, Rcpp::IntegerVector targe
auto wrk = ptr->sparse_column();
auto copy = prepare_indices(targets, wrk);

size_t nr = ptr->nrow();
size_t counter = 0;
Rcpp::List output(copy.size());
for (auto c : copy) {
Expand Down

0 comments on commit a239a0c

Please sign in to comment.