Skip to content

Commit

Permalink
cleanup: refactored initialization of DevLock from memset to assignment
Browse files Browse the repository at this point in the history
- this removes one compiler warning form the build
  • Loading branch information
franku committed Jul 3, 2018
1 parent 6faf687 commit 45257a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/src/lib/devlock.cc
Expand Up @@ -41,11 +41,23 @@
* errno on failure
*/

DevLock *new_devlock()
DevLock *DevLock::new_devlock()
{
DevLock *lock;
lock = (DevLock *)malloc(sizeof (DevLock));
memset(lock, 0, sizeof(DevLock));
lock->mutex = PTHREAD_MUTEX_INITIALIZER;
lock->read = PTHREAD_COND_INITIALIZER;
lock->write = PTHREAD_COND_INITIALIZER;
lock->writer_id = 0;
lock->priority = 0;
lock->valid = 0;
lock->r_active = 0;
lock->w_active = 0;
lock->r_wait = 0;
lock->w_wait = 0;
lock->reason = 0;
lock->prev_reason = 0;
lock->can_take = false;
return lock;
}

Expand Down
1 change: 1 addition & 0 deletions core/src/lib/devlock.h
Expand Up @@ -60,6 +60,7 @@ class DevLock {
public:
DevLock(int reason, bool can_take=false);
~DevLock();
static DevLock *new_devlock();
int init(int initial_priority);
int destroy();
int TakeLock(take_lock_t *hold, int reason);
Expand Down

0 comments on commit 45257a7

Please sign in to comment.