@@ -1004,6 +1004,7 @@ AttrInfo File::getNextAttr() {
1004
1004
AttrInfo info;
1005
1005
info.name = NULL_STR;
1006
1006
info.length = 0 ;
1007
+ info.type = NXnumtype::BINARY; // junk value that shouldn't be checked for
1007
1008
return info;
1008
1009
} else {
1009
1010
throw Exception (" NXgetnextattra failed" , status);
@@ -1095,8 +1096,7 @@ void File::getAttr(const std::string &name, std::vector<std::string> &array) {
1095
1096
int type;
1096
1097
int rank;
1097
1098
int dim[NX_MAXRANK];
1098
- NXstatus status = NXgetattrainfo (this ->m_file_id , attr_name, &rank, dim, &type);
1099
- if (status != NX_OK) {
1099
+ if (NXgetattrainfo (this ->m_file_id , attr_name, &rank, dim, &type) != NX_OK) {
1100
1100
throw Exception (" Attribute \" " + name + " \" not found" );
1101
1101
}
1102
1102
@@ -1107,7 +1107,8 @@ void File::getAttr(const std::string &name, std::vector<std::string> &array) {
1107
1107
// read data
1108
1108
std::string sep (" , " );
1109
1109
char *char_data = new char [dim[0 ] * (dim[1 ] + sep.size ())];
1110
- status = NXgetattra (this ->m_file_id , attr_name, char_data);
1110
+ if (NXgetattra (this ->m_file_id , attr_name, char_data) != NX_OK)
1111
+ throw Exception (" Could not iterate to next attribute" );
1111
1112
1112
1113
// split data to strings
1113
1114
std::string data (char_data);
@@ -1291,10 +1292,14 @@ template <typename NumT> void File::malloc(NumT *&data, const Info &info) {
1291
1292
if (getType<NumT>() != info.type ) {
1292
1293
throw Exception (" Type mismatch in malloc()" );
1293
1294
}
1295
+ // cppcheck-suppress cstyleCast
1294
1296
inner_malloc ((void *&)data, info.dims , info.type );
1295
1297
}
1296
1298
1297
- template <typename NumT> void File::free (NumT *&data) { inner_free ((void *&)data); }
1299
+ template <typename NumT> void File::free (NumT *&data) {
1300
+ // cppcheck-suppress cstyleCast
1301
+ inner_free ((void *&)data);
1302
+ }
1298
1303
1299
1304
} // namespace NeXus
1300
1305
0 commit comments