summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-06-01 14:49:41 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2011-06-01 14:49:41 (GMT)
commit4134cb7dfc04ca7721277772c41b678bac6b33a0 (patch)
treea6574aa57d531d934ede1d70cd62220511ee14ca
parentb840d8255196241fa7c2684c0443471330f94046 (diff)
downloadQt-4134cb7dfc04ca7721277772c41b678bac6b33a0.zip
Qt-4134cb7dfc04ca7721277772c41b678bac6b33a0.tar.gz
Qt-4134cb7dfc04ca7721277772c41b678bac6b33a0.tar.bz2
simplify the code by using the EINTR_LOOP macro
the sembuf structure now initializes out of the loop (nano-opt) Merge-request: 1237 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
-rw-r--r--src/gui/embedded/qwslock.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/gui/embedded/qwslock.cpp b/src/gui/embedded/qwslock.cpp
index ae168df..d8996d6 100644
--- a/src/gui/embedded/qwslock.cpp
+++ b/src/gui/embedded/qwslock.cpp
@@ -116,59 +116,59 @@ QWSLock::~QWSLock()
static bool forceLock(int semId, unsigned short semNum, int)
{
int ret;
- do {
- sembuf sops = { semNum, -1, 0 };
- // As the BackingStore lock is a mutex, and only one process may own
- // the lock, it's safe to use SEM_UNDO. On the other hand, the
- // Communication lock is locked by the client but unlocked by the
- // server and therefore can't use SEM_UNDO.
- if (semNum == QWSLock::BackingStore)
- sops.sem_flg |= SEM_UNDO;
-
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::lock: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
+ sembuf sops = { semNum, -1, 0 };
+ // As the BackingStore lock is a mutex, and only one process may own
+ // the lock, it's safe to use SEM_UNDO. On the other hand, the
+ // Communication lock is locked by the client but unlocked by the
+ // server and therefore can't use SEM_UNDO.
+ if (semNum == QWSLock::BackingStore)
+ sops.sem_flg |= SEM_UNDO;
+
+ EINTR_LOOP(ret, semop(semId, &sops, 1));
+ if (ret == -1) {
+ qDebug("QWSLock::lock(): %s", strerror(errno));
+ return false;
+ }
- return (ret != -1);
+ return true;
}
static bool up(int semId, unsigned short semNum)
{
int ret;
- do {
- sembuf sops = { semNum, 1, 0 };
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::up: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
- return (ret != -1);
+ sembuf sops = { semNum, 1, 0 };
+
+ EINTR_LOOP(ret, semop(semId, &sops, 1));
+ if (ret == -1) {
+ qDebug("QWSLock::up(): %s", strerror(errno));
+ return false;
+ }
+
+ return true;
}
static bool down(int semId, unsigned short semNum)
{
int ret;
- do {
- sembuf sops = { semNum, -1, 0 };
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::down: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
- return (ret != -1);
+ sembuf sops = { semNum, -1, 0 };
+
+ EINTR_LOOP(ret, semop(semId, &sops, 1));
+ if (ret == -1) {
+ qDebug("QWSLock::down(): %s", strerror(errno));
+ return false;
+ }
+
+ return true;
}
static int getValue(int semId, unsigned short semNum)
{
- int ret;
- do {
- ret = semctl(semId, semNum, GETVAL, 0);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::getValue: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-
+ int ret = semctl(semId, semNum, GETVAL, 0);
+ if (ret == -1)
+ qDebug("QWSLock::getValue(): %s", strerror(errno));
return ret;
}
@@ -218,7 +218,7 @@ void QWSLock::unlock(LockType type)
ret = semop(semId, &sops, 1);
if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::unlock: %s", strerror(errno));
+ qDebug("QWSLock::unlock(): %s", strerror(errno));
} while (ret == -1 && errno == EINTR);
}