Skip to content

Commit

Permalink
Merge pull request #18960 from mantidproject/suspicious-string-compare
Browse files Browse the repository at this point in the history
Fix misc-suspicious-string-compare warning.
  • Loading branch information
martyngigg committed Feb 23, 2017
2 parents 3acb069 + 3bb578f commit 0d4c9b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ int SaveToSNSHistogramNexus::WriteAttributes(int is_definition) {
NXname attrName;
void *attrBuffer;

std::array<const char *, 6> attrs = {{"NeXus_version", "XML_version",
"HDF_version", "HDF5_Version",
"file_name", "file_time"}};

do {
#ifdef NEXUS43
status = NXgetnextattr(inId, attrName, &attrLen, &attrType);
Expand All @@ -669,10 +673,10 @@ int SaveToSNSHistogramNexus::WriteAttributes(int is_definition) {
return NX_ERROR;
attrLen = dims[0];
#endif
if (strcmp(attrName, "NeXus_version") &&
strcmp(attrName, "XML_version") && strcmp(attrName, "HDF_version") &&
strcmp(attrName, "HDF5_Version") && strcmp(attrName, "file_name") &&
strcmp(attrName, "file_time")) {
if (std::none_of(attrs.cbegin(), attrs.cend(),
[&attrName](const char *name) {
return strcmp(attrName, name) == 0;
})) {
attrLen++; /* Add space for string termination */
if (NXmalloc(&attrBuffer, 1, &attrLen, attrType) != NX_OK)
return NX_ERROR;
Expand Down

0 comments on commit 0d4c9b9

Please sign in to comment.