Skip to content

Commit

Permalink
cleanup: Ensure message structs don't have uninitialised members.
Browse files Browse the repository at this point in the history
Coverity tripped over this. In reality this is probably fine, but the
cost of this extra initialisation is negligible.
  • Loading branch information
iphydf committed Dec 21, 2024
1 parent 25a55e6 commit e73b138
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/model/ichatlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Q_DECLARE_METATYPE(ChatLogIdx)
struct SearchPos
{
// Index to the chat log item we want
ChatLogIdx logIdx;
ChatLogIdx logIdx{0};
// Number of matches we've had. This is always number of matches from the
// start even if we're searching backwards.
size_t numMatches;
size_t numMatches{0};

bool operator==(const SearchPos& other) const
{
Expand All @@ -54,10 +54,10 @@ struct SearchPos

struct SearchResult
{
bool found;
bool found{false};
SearchPos pos;
size_t start;
size_t len;
size_t start{0};
size_t len{0};

// This is unfortunately needed to shoehorn our API into the highlighting
// API of above classes. They expect to re-search the same thing we did
Expand Down
6 changes: 3 additions & 3 deletions src/model/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ struct MessageMetadata
{
MessageMetadataType type;
// Indicates start position within a Message::content
size_t start;
size_t start{0};
// Indicates end position within a Message::content
size_t end;
size_t end{0};
};

struct Message
{
bool isAction;
bool isAction{false};
QString content;
QDateTime timestamp;
std::vector<MessageMetadata> metadata;
Expand Down

0 comments on commit e73b138

Please sign in to comment.