Skip to content

Commit 9ca4a08

Browse files
committed
Add nodiscard attribute to Structure{,Builder}::{GetMemberByName,GetMemberByOffset}
Failing to check the return value is almost always a bug.
1 parent 351f1ba commit 9ca4a08

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

binaryninjaapi.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11424,15 +11424,15 @@ namespace BinaryNinja {
1142411424
\param result Reference to a StructureMember to copy the result to
1142511425
\return Whether a member was found
1142611426
*/
11427-
bool GetMemberByName(const std::string& name, StructureMember& result) const;
11427+
[[nodiscard]] bool GetMemberByName(const std::string& name, StructureMember& result) const;
1142811428

1142911429
/*! Get a structure member at a certain offset
1143011430

1143111431
\param offset Offset to check
1143211432
\param result Reference to a StructureMember to copy the result to
1143311433
\return Whether a member was found
1143411434
*/
11435-
bool GetMemberAtOffset(int64_t offset, StructureMember& result) const;
11435+
[[nodiscard]] bool GetMemberAtOffset(int64_t offset, StructureMember& result) const;
1143611436

1143711437
/*! Get a structure member and its index at a certain offset
1143811438

@@ -11441,7 +11441,7 @@ namespace BinaryNinja {
1144111441
\param idx Reference to a size_t to copy the index to
1144211442
\return Whether a member was found
1144311443
*/
11444-
bool GetMemberAtOffset(int64_t offset, StructureMember& result, size_t& idx) const;
11444+
[[nodiscard]] bool GetMemberAtOffset(int64_t offset, StructureMember& result, size_t& idx) const;
1144511445

1144611446
/*! Get the structure width in bytes
1144711447

@@ -11554,10 +11554,10 @@ namespace BinaryNinja {
1155411554
\param result Reference to a StructureMember object the field will be passed to
1155511555
\return Whether a StructureMember was successfully retrieved
1155611556
*/
11557-
bool GetMemberByName(const std::string& name, StructureMember& result) const;
11557+
[[nodiscard]] bool GetMemberByName(const std::string& name, StructureMember& result) const;
1155811558
// TODO: GetMember at offset also needs to pass a bit position.
11559-
bool GetMemberAtOffset(int64_t offset, StructureMember& result) const;
11560-
bool GetMemberAtOffset(int64_t offset, StructureMember& result, size_t& idx) const;
11559+
[[nodiscard]] bool GetMemberAtOffset(int64_t offset, StructureMember& result) const;
11560+
[[nodiscard]] bool GetMemberAtOffset(int64_t offset, StructureMember& result, size_t& idx) const;
1156111561
uint64_t GetWidth() const;
1156211562
StructureBuilder& SetWidth(size_t width);
1156311563
int64_t GetPointerOffset() const;

0 commit comments

Comments
 (0)