diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-12-17 13:43:17 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-12-19 00:12:28 +0000 |
commit | 6ab8e91658f1efc894b648cc0748af8d804915e4 (patch) | |
tree | c33da7914793452ecb37084e505230171d4eff9e /util/lock | |
parent | e5935f17d1798a1f19c6003e57f140446774484f (diff) | |
download | chrome-ec-6ab8e91658f1efc894b648cc0748af8d804915e4.tar.gz |
cleanup: Remove checkpatch warnings
This make minor syntactic changes and renames some camel-cased symbols
to keep checkpatch from complaining. The goal is to reduce the
temptation to use 'repo upload --no-verify'.
This is a big furball of find/replace, but no functional changes.
BUG=chromium:322144
BRANCH=none
TEST=build all boards; pass unit tests
Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180495
Diffstat (limited to 'util/lock')
-rw-r--r-- | util/lock/csem.c | 32 | ||||
-rw-r--r-- | util/lock/ipc_lock.c | 15 |
2 files changed, 21 insertions, 26 deletions
diff --git a/util/lock/csem.c b/util/lock/csem.c index a84cbbb2b1..bdb49fd1da 100644 --- a/util/lock/csem.c +++ b/util/lock/csem.c @@ -72,9 +72,8 @@ static int does_semctl_set_otime(void) /* create a test semaphore */ sem_id = semget(IPC_PRIVATE, 1, S_IRUSR|S_IWUSR); - if (sem_id < 0) { + if (sem_id < 0) return -1; - } /* set the value */ if (csem_setval(sem_id, 1) < 0) { @@ -99,22 +98,21 @@ int csem_create(key_t key, unsigned val) /* see if we need to trigger a semop to set sem_otime */ if (need_otime_hack < 0) { int ret = does_semctl_set_otime(); - if (ret < 0) { + if (ret < 0) return -1; - } + need_otime_hack = !ret; } /* create it or fail */ sem_id = semget(key, 1, IPC_CREAT|IPC_EXCL | S_IRUSR|S_IWUSR); - if (sem_id < 0) { + if (sem_id < 0) return -1; - } /* initalize the value */ - if (need_otime_hack) { + if (need_otime_hack) val++; - } + if (csem_setval(sem_id, val) < 0) { csem_destroy(sem_id); return -1; @@ -145,9 +143,8 @@ int csem_get(key_t key) /* get the (assumed existing) semaphore */ sem_id = semget(key, 1, S_IRUSR|S_IWUSR); - if (sem_id < 0) { + if (sem_id < 0) return -1; - } /* loop until sem_otime != 0, which means it has been initialized */ for (i = 0; i < MAX_OTIME_LOOPS; i++) { @@ -181,9 +178,8 @@ int csem_get_or_create(key_t key, unsigned val) /* it must exist already - get it */ sem_id = csem_get(key); - if (sem_id < 0) { + if (sem_id < 0) return -1; - } return sem_id; } @@ -202,9 +198,9 @@ int csem_setval(int sem_id, unsigned val) { union semun arg; arg.val = val; - if (semctl(sem_id, 0, SETVAL, arg) < 0) { + if (semctl(sem_id, 0, SETVAL, arg) < 0) return -1; - } + return 0; } @@ -247,8 +243,8 @@ int csem_down_undo(int sem_id) } static int csem_down_timeout_undoflag(int sem_id, - struct timespec *timeout, - int undoflag) + struct timespec *timeout, + int undoflag) { struct sembuf sops; sops.sem_num = 0; @@ -272,8 +268,8 @@ time_t csem_get_otime(int sem_id) union semun arg; struct semid_ds ds; arg.buf = &ds; - if (semctl(sem_id, 0, IPC_STAT, arg) < 0) { + if (semctl(sem_id, 0, IPC_STAT, arg) < 0) return -1; - } + return ds.sem_otime; } diff --git a/util/lock/ipc_lock.c b/util/lock/ipc_lock.c index 5bc816c894..790014e67b 100644 --- a/util/lock/ipc_lock.c +++ b/util/lock/ipc_lock.c @@ -40,9 +40,9 @@ static int lock_init(struct ipc_lock *lock) if (lock->sem < 0) { /* get or create the semaphore, init to 1 if needed */ int sem = csem_get_or_create(lock->key, 1); - if (sem < 0) { + if (sem < 0) return -1; - } + lock->sem = sem; } return 0; @@ -63,14 +63,13 @@ int acquire_lock(struct ipc_lock *lock, int timeout_msecs) /* initialize the lock */ if (lock_init(lock) < 0) { fprintf(stderr, "%s(): failed to init lock 0x%08x\n", - __func__, (uint32_t)lock->key); + __func__, (uint32_t)lock->key); return -1; } /* check if it is already held */ - if (lock->is_held) { + if (lock->is_held) return 1; - } /* calculate the timeout */ if (timeout_msecs >= 0) { @@ -84,7 +83,7 @@ int acquire_lock(struct ipc_lock *lock, int timeout_msecs) ret = csem_down_timeout_undo(lock->sem, timeout_ptr); if (ret < 0) { fprintf(stderr, "%s(): failed to acquire lock 0x%08x\n", - __func__, (uint32_t)lock->key); + __func__, (uint32_t)lock->key); return -1; } @@ -101,6 +100,6 @@ int release_lock(struct ipc_lock *lock) /* NOTE: do not destroy the semaphore, we want it to persist */ return 0; } - /* did not hold the lock */ - return -1; + /* did not hold the lock */ + return -1; } |