Skip to content

Commit

Permalink
Fix clang-analyzer-core.NullDereference and avoid const_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Nov 7, 2024
1 parent 27c78a3 commit aeea0a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/deps_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ bool DepsLog::OpenForWrite(const string& path, string* err) {

bool DepsLog::RecordDeps(Node* node, TimeStamp mtime,
const vector<Node*>& nodes) {
return RecordDeps(node, mtime, nodes.size(),
nodes.empty() ? NULL : const_cast<Node**>(&nodes.front()));
return RecordDeps(node, mtime, nodes.size(), nodes.data());
}

bool DepsLog::RecordDeps(Node* node, TimeStamp mtime,
int node_count, Node** nodes) {
bool DepsLog::RecordDeps(Node* node, TimeStamp mtime, int node_count,
Node* const* nodes) {
// Track whether there's any new data to be recorded.
bool made_change = false;

Expand Down
3 changes: 2 additions & 1 deletion src/deps_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ struct DepsLog {
// Writing (build-time) interface.
bool OpenForWrite(const std::string& path, std::string* err);
bool RecordDeps(Node* node, TimeStamp mtime, const std::vector<Node*>& nodes);
bool RecordDeps(Node* node, TimeStamp mtime, int node_count, Node** nodes);
bool RecordDeps(Node* node, TimeStamp mtime, int node_count,
Node* const* nodes);
void Close();

// Reading (startup-time) interface.
Expand Down

0 comments on commit aeea0a4

Please sign in to comment.