Skip to content

Commit aeea0a4

Browse files
committed
Fix clang-analyzer-core.NullDereference and avoid const_cast
1 parent 27c78a3 commit aeea0a4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/deps_log.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ bool DepsLog::OpenForWrite(const string& path, string* err) {
6262

6363
bool DepsLog::RecordDeps(Node* node, TimeStamp mtime,
6464
const vector<Node*>& nodes) {
65-
return RecordDeps(node, mtime, nodes.size(),
66-
nodes.empty() ? NULL : const_cast<Node**>(&nodes.front()));
65+
return RecordDeps(node, mtime, nodes.size(), nodes.data());
6766
}
6867

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

src/deps_log.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ struct DepsLog {
7272
// Writing (build-time) interface.
7373
bool OpenForWrite(const std::string& path, std::string* err);
7474
bool RecordDeps(Node* node, TimeStamp mtime, const std::vector<Node*>& nodes);
75-
bool RecordDeps(Node* node, TimeStamp mtime, int node_count, Node** nodes);
75+
bool RecordDeps(Node* node, TimeStamp mtime, int node_count,
76+
Node* const* nodes);
7677
void Close();
7778

7879
// Reading (startup-time) interface.

0 commit comments

Comments
 (0)