Skip to content

Commit

Permalink
logd: clarify release_Locked() for static analyzer
Browse files Browse the repository at this point in the history
release_Locked() is called with a reference count and threadRunning,
the static analyzer can not tell this and estimates that a call to
delete this will occur. So let us invent a new call
release_nodelete_Locked() to ensure it is clear we will not be
arranging a delete this in the context of this code path. The
delete this will follow in the immediate codepath in this function
after threadRunning is cleared, and decRef_Locked() is called.

Change will also remove any developer FUD regarding release_Locked()
usage at this location.

SideEffects: None

Bug: 27434831
Change-Id: I91b060b2dadc72cc449fa381c934afb577bee037
  • Loading branch information
Mark Salyzyn authored and spezi77 committed Mar 13, 2016
1 parent cb12b16 commit e1a4c62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion logd/LogTimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void LogTimeEntry::threadStop(void *obj) {
while(it != times.end()) {
if (*it == me) {
times.erase(it);
me->release_Locked();
me->release_nodelete_Locked();
break;
}
it++;
Expand Down
8 changes: 7 additions & 1 deletion logd/LogTimes.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ class LogTimeEntry {
void triggerSkip_Locked(log_id_t id, unsigned int skip) { skipAhead[id] = skip; }
void cleanSkip_Locked(void);

// Called after LogTimeEntry removed from list, lock implicitly held
// These called after LogTimeEntry removed from list, lock implicitly held
void release_nodelete_Locked(void) {
mRelease = true;
pthread_cond_signal(&threadTriggeredCondition);
// assumes caller code path will call decRef_Locked()
}

void release_Locked(void) {
mRelease = true;
pthread_cond_signal(&threadTriggeredCondition);
Expand Down

0 comments on commit e1a4c62

Please sign in to comment.