Skip to content

Commit 81c12c3

Browse files
committed
Merge branch '174-refactor-eliminate-compile-warnings' into staging
2 parents 913d0d6 + 289c07d commit 81c12c3

53 files changed

Lines changed: 330 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,17 @@ target_link_libraries(examples-xtensor ${LIBS} libxtensor)
149149
add_dependencies(examples examples-xtensor)
150150

151151
find_package(BLAS)
152-
if(BLAS_FOUND)
152+
if(BLAS_FOUND AND XFLENS_FOUND)
153153
message( "-- Vendored: xtensor-blas added to examples" )
154154
add_executable(examples-xtensor-blas EXCLUDE_FROM_ALL "linalg/xtensor-blas.cpp")
155155
target_link_libraries(examples-xtensor-blas ${LIBS} libxtensor-blas ${BLAS_LIBRARIES})
156156
add_dependencies(examples examples-xtensor-blas)
157157
else()
158-
message("-- BLAS not found — xtensor-blas example disabled")
158+
if(BLAS_FOUND)
159+
message("-- xflens not found — xtensor-blas example disabled")
160+
else()
161+
message("-- BLAS not found — xtensor-blas example disabled")
162+
endif()
159163
endif()
160164

161165
# ublas headers are vendored but rely on system Boost config/compiler headers

examples/basics/basics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ int main(){
6969
// h5::lcpl_t lcpl = h5::create_path | h5::utf8;
7070
}
7171
{ // all resources follow RAII idiom / managed
72-
h5::fd_t fd = h5::create("001.h5", H5F_ACC_TRUNC); // f5::fd_t is managed resource, will call H5Fclose upon leaving code block
73-
hid_t ref = static_cast<hid_t>( fd ); // static cast to hid_t is always allowed, ref must be treated as managed reference,
74-
// must not call CAPI H5Fclose( ref ) on it. This explicit or implicit conversion
72+
h5::fd_t fd = h5::create("001.h5", H5F_ACC_TRUNC); // f5::fd_t is managed resource, will call H5Fclose upon leaving code block
73+
hid_t ref = static_cast<hid_t>( fd ); // static cast to hid_t is always allowed, ref must be treated as managed reference,
74+
(void)ref;
75+
// must not call CAPI H5Fclose( ref ) on it. This explicit or implicit conversion
7576
// is to support CAPI interop.
7677
}
7778
{ // file create example:
@@ -108,4 +109,3 @@ int main(){
108109
}
109110

110111
}
111-

examples/compound/utils.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ namespace h5::utils {
99
// template specialization
1010
template <> inline std::vector<sn::example::Record> get_test_data( size_t n ){
1111
std::vector<sn::example::Record> vec (n);
12-
for(int i=0; i<n; i++ )
12+
for(size_t i=0; i<n; i++ )
1313
vec[i].idx = i;
1414
return vec;
1515
}
1616
template <> inline std::vector<int> get_test_data( size_t n ){
1717
std::vector<int> vec (n);
18-
for(int i=0; i<n; i++ )
18+
for(size_t i=0; i<n; i++ )
1919
vec[i] = i;
2020
return vec;
2121
}

examples/csv/csv.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ namespace io{
7373
std::memset(file_name, 0, sizeof(file_name));
7474
}
7575

76-
void set_file_name(const char*file_name){
77-
if(file_name != nullptr){
78-
strncpy(this->file_name, file_name, sizeof(this->file_name));
79-
this->file_name[sizeof(this->file_name)-1] = '\0';
80-
}else{
76+
void set_file_name(const char*file_name){
77+
if(file_name != nullptr){
78+
std::snprintf(this->file_name, sizeof(this->file_name), "%s", file_name);
79+
}else{
8180
this->file_name[0] = '\0';
8281
}
8382
}
@@ -420,11 +419,10 @@ namespace io{
420419
set_file_name(file_name.c_str());
421420
}
422421

423-
void set_file_name(const char*file_name){
424-
if(file_name != nullptr){
425-
strncpy(this->file_name, file_name, sizeof(this->file_name));
426-
this->file_name[sizeof(this->file_name)-1] = '\0';
427-
}else{
422+
void set_file_name(const char*file_name){
423+
if(file_name != nullptr){
424+
std::snprintf(this->file_name, sizeof(this->file_name), "%s", file_name);
425+
}else{
428426
this->file_name[0] = '\0';
429427
}
430428
}
@@ -1265,4 +1263,3 @@ namespace io{
12651263
};
12661264
}
12671265
#endif
1268-

examples/csv/csv2hdf5.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ int main(){
3434
input_t row; // buffer to read line by line
3535
char* ptr; // indirection, as `read_row` doesn't take array directly
3636
while(in.read_row(row.MasterRecordNumber, row.Hour, ptr, row.Latitude, row.Longitude)){
37-
strncpy(row.ReportedLocation, ptr, STR_ARRAY_SIZE); // defined in struct.h
37+
memset(row.ReportedLocation, 0, STR_ARRAY_SIZE);
38+
strncpy(row.ReportedLocation, ptr, STR_ARRAY_SIZE - 1); // defined in struct.h
3839
h5::append(pt, row);
3940
std::cout << std::string(ptr) << "\n";
4041
}

examples/datatypes/n-bit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ int main(){
7575
h5::write<bs::n_bit>(ds, V.data(), h5::count{12,8}); // single shot write
7676

7777
auto data = h5::read<std::vector<bs::n_bit>>(fd, "stl");
78-
for( int i=0; i<V.size(); i++ )
78+
for( size_t i=0; i<V.size(); i++ )
7979
std::cout << static_cast<unsigned int>( data[i] ) << " ";
8080
std::cout << "\n\ncomputing difference ||saved - read|| expecting norm to be zero:\n";
81-
for( int i=0; i<V.size(); i++ )
81+
for( size_t i=0; i<V.size(); i++ )
8282
std::cout << abs(V[i].value - data[i].value) <<" ";
8383
}
8484
}
85-

examples/datatypes/n-bit.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ std::ostream& operator<<(std::ostream& os, const bitstring::n_bit& data){
5151

5252
std::ostream& operator<<(std::ostream& os, const
5353
Eigen::Matrix<bitstring::n_bit, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>& M){
54-
for( size_t i=0; i<M.rows(); i++){
55-
for( size_t j=0; j<M.cols(); j++) os << static_cast<unsigned int>( M(i,j)) <<" ";
54+
for( Eigen::Index i=0; i<M.rows(); i++){
55+
for( Eigen::Index j=0; j<M.cols(); j++) os << static_cast<unsigned int>( M(i,j)) <<" ";
5656
os<<std::endl;
5757
}
5858
return os;
5959
}
60-

examples/datatypes/two-bit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ int main(){
2525
h5::write(fd,"data", vec); // single shot write
2626
auto data = h5::read<std::vector<nm::two_bit>>(fd, "data");
2727

28-
for( int i=0; i<vec.size(); i++ )
28+
for( size_t i=0; i<vec.size(); i++ )
2929
std::cout << "[" << i << ": " << vec[i] << " " <<"]";
3030
std::cout << "\n\ncomputing difference ||saved - read|| expecting norm to be zero:\n";
31-
for( int i=0; i<vec.size(); i++ )
31+
for( size_t i=0; i<vec.size(); i++ )
3232
std::cout << abs(vec[i].value - data[i].value) <<" ";
3333
}
34-

examples/multi-tu/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace h5 { namespace utils {
1010
// template specialization
1111
template <> inline std::vector<sn::example::Record> get_test_data( size_t n ){
1212
std::vector<sn::example::Record> vec (n);
13-
for(int i=0; i<n; i++ )
13+
for(size_t i=0; i<n; i++ )
1414
vec[i].idx = i;
1515
return vec;
1616
}

examples/packet-table/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace h5 { namespace utils {
1010
// template specialization
1111
template <> inline std::vector<sn::example::Record> get_test_data( size_t n ){
1212
std::vector<sn::example::Record> vec (n);
13-
for(int i=0; i<n; i++ )
13+
for(size_t i=0; i<n; i++ )
1414
vec[i].idx = i;
1515
return vec;
1616
}

0 commit comments

Comments
 (0)