Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply git clang-format suggested changes
Signed-off-by: David Abdurachmanov <[email protected]>
  • Loading branch information
davidlt committed May 26, 2017
commit be8dddd13f1fb758a9cb546a1441e18d24c2fbfe
2 changes: 1 addition & 1 deletion io/io/v7/src/TFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TV6Storage: public ROOT::Experimental::Internal::TFileStorageInterface {
}

void WriteMemoryWithType(std::string_view name, const void* address, TClass* cl) final {
fOldFile->WriteObjectAny(address, cl, name.data());
fOldFile->WriteObjectAny(address, cl, name.data());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't data() not guaranteed to be null terminated? (which WriteObjectAny requires)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Starting C++11 std::string .data() and .c_str() both provide null-terminated result, but the same does not apply to std::string_view. The example I am looking even shows that one needs to create a temporary string and then call .data().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me to the comment in the code which states that it's required? At first look I don't see it explicitly mentioned in TBufferFile::WriteObjectClass or TBufferFile::WriteObjectAny and I didn't see any breakage in CMSSW.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops, it should be TDirectoryFile::WriteObjectAny, but same story. No comments mention that it should be null-terminated. Even provided example is not null-terminated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting C++11 std::string .data() and .c_str() both provide null-terminated result

I somehow did not catch that. Thanks!

Could you point me to the comment in the code which states that it's required?

Humm ... WriteObjectAny takes a const char* and use it as null terminated string, I am not sure why there would be a 'special' comment in this routine to make that explicit ...

It is clear that std::string_view::data is not appropriate here, as this returns the first characters of the view, which could for example be a sub-part of a larger string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weekend already. I was looking at completely different argument :)

}
};
}
Expand Down