qsystemsemaphore_systemv.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qsystemsemaphore_systemv.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)-
18{-
19 if (key.isEmpty()
key.isEmpty()Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 22452 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
){
59-22452
20 errorString = QCoreApplication::tr("%1: key is empty", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));-
21 error = QSystemSemaphore::KeyError;-
22 return
executed 59 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
-1;
executed 59 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
59
23 }-
24-
25-
26 if (-
-1 != unix_keyDescription
TRUEevaluated 15320 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 != unix_key
-1 != unix_keyDescription
TRUEevaluated 15320 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
)
7132-15320
27 return
executed 15320 times by 4 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
unix_key;
executed 15320 times by 4 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
15320
28-
29-
30 int built = QSharedMemoryPrivate::createUnixKeyFile(fileName);-
31 if (-
-1 == builtDescription
TRUEnever evaluated
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 == built
-1 == builtDescription
TRUEnever evaluated
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
0-7132
32 errorString = QCoreApplication::tr("%1: unable to make key", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));-
33 error = QSystemSemaphore::KeyError;-
34 return
never executed: return -1;
-1;
never executed: return -1;
0
35 }-
36 createdFile = (1 == built);-
37-
38-
39 unix_key = qt_safe_ftok(QFile::encodeName(fileName), 'Q');-
40 if (-
-1 == unix_keyDescription
TRUEnever evaluated
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 == unix_key
-1 == unix_keyDescription
TRUEnever evaluated
FALSEevaluated 7132 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
0-7132
41 errorString = QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));-
42 error = QSystemSemaphore::KeyError;-
43 return
never executed: return -1;
-1;
never executed: return -1;
0
44 }-
45-
46-
47 semaphore = semget(unix_key, 1, 0600 | 01000 | 02000);-
48 if (-
-1 == semaphoreDescription
TRUEevaluated 3613 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 3519 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
1 == semaphore
-1 == semaphoreDescription
TRUEevaluated 3613 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 3519 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
) {
3519-3613
49 if ((*
(*__errno_location ()) == 17Description
TRUEevaluated 3611 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
__errno_location ()) == 17
(*__errno_location ()) == 17Description
TRUEevaluated 3611 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
)
2-3611
50 semaphore = semget(unix_key, 1, 0600 | 01000);
executed 3611 times by 3 tests: semaphore = semget(unix_key, 1, 0600 | 01000);
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
3611
51 if (-
-1 == semaphoreDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3611 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 == semaphore
-1 == semaphoreDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3611 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
2-3611
52 setErrorString(QLatin1String("QSystemSemaphore::handle"));-
53 cleanHandle();-
54 return
executed 2 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
-1;
executed 2 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
2
55 }-
56 }
executed 3611 times by 3 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
else {
3611
57 createdSemaphore = true;-
58-
59 createdFile = true;-
60 }
executed 3519 times by 3 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
3519
61-
62 if (mode == QSystemSemaphore::Create
mode == QSyste...aphore::CreateDescription
TRUEevaluated 3513 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
FALSEevaluated 3617 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
3513-3617
63 createdSemaphore = true;-
64 createdFile = true;-
65 }
executed 3513 times by 3 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
3513
66-
67-
68 if (createdSemaphore
createdSemaphoreDescription
TRUEevaluated 6987 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
FALSEevaluated 143 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsystemsemaphore - unknown status
&& initialValue >= 0
initialValue >= 0Description
TRUEevaluated 6987 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
FALSEnever evaluated
) {
0-6987
69 qt_semun init_op;-
70 init_op.val = initialValue;-
71 if (-
-1 == semctl(s..., 16, init_op)Description
TRUEnever evaluated
FALSEevaluated 6987 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
1 == semctl(semaphore, 0, 16, init_op)
-1 == semctl(s..., 16, init_op)Description
TRUEnever evaluated
FALSEevaluated 6987 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
) {
0-6987
72 setErrorString(QLatin1String("QSystemSemaphore::handle"));-
73 cleanHandle();-
74 return
never executed: return -1;
-1;
never executed: return -1;
0
75 }-
76 }
executed 6987 times by 3 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
6987
77-
78 return
executed 7130 times by 4 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
unix_key;
executed 7130 times by 4 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
7130
79}-
80-
81-
82-
83-
84-
85-
86void QSystemSemaphorePrivate::cleanHandle()-
87{-
88 unix_key = -1;-
89-
90-
91 if (createdFile
createdFileDescription
TRUEevaluated 3522 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
FALSEevaluated 3937 times by 5 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qapplication - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
3522-3937
92 QFile::remove(fileName);-
93 createdFile = false;-
94 }
executed 3522 times by 2 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
3522
95-
96 if (createdSemaphore
createdSemaphoreDescription
TRUEevaluated 3520 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
FALSEevaluated 3939 times by 5 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qapplication - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
3520-3939
97 if (-
-1 != semaphoreDescription
TRUEevaluated 3519 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSharedMemory
1 != semaphore
-1 != semaphoreDescription
TRUEevaluated 3519 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
1-3519
98 if (-
-1 == semctl(s...hore, 0, 0, 0)Description
TRUEnever evaluated
FALSEevaluated 3519 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
1 == semctl(semaphore, 0, 0, 0)
-1 == semctl(s...hore, 0, 0, 0)Description
TRUEnever evaluated
FALSEevaluated 3519 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
) {
0-3519
99 setErrorString(QLatin1String("QSystemSemaphore::cleanHandle"));-
100-
101-
102-
103 }
never executed: end of block
0
104 semaphore = -1;-
105 }
executed 3519 times by 2 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
3519
106 createdSemaphore = false;-
107 }
executed 3520 times by 2 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
3520
108}
executed 7459 times by 5 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qapplication - unknown status
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
7459
109-
110-
111-
112-
113bool QSystemSemaphorePrivate::modifySemaphore(int count)-
114{-
115 if (-
-1 == handle()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 15320 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 == handle()
-1 == handle()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 15320 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
)
2-15320
116 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSharedMemory
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QSharedMemory
2
117-
118 struct sembuf operation;-
119 operation.sem_num = 0;-
120 operation.sem_op = count;-
121 operation.sem_flg = 0x1000;-
122-
123 int res;-
124 do { res = semop(semaphore, &operation, 1); }
executed 15320 times by 4 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
while (res == -1
res == -1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 15318 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
&& (*
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
__errno_location ()) == 4
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
);
0-15320
125 if (-
-1 == resDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 15318 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
1 == res
-1 == resDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 15318 times by 4 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
) {
2-15318
126-
127 if ((*
(*__errno_location ()) == 22Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEnever evaluated
__errno_location ()) == 22
(*__errno_location ()) == 22Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEnever evaluated
|| (*
(*__errno_location ()) == 43Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ()) == 43
(*__errno_location ()) == 43Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-2
128 semaphore = -1;-
129 cleanHandle();-
130 handle();-
131 return
executed 2 times by 1 test: return modifySemaphore(count);
Executed by:
  • tst_QSharedMemory
modifySemaphore(count);
executed 2 times by 1 test: return modifySemaphore(count);
Executed by:
  • tst_QSharedMemory
2
132 }-
133 setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));-
134-
135-
136-
137 return
never executed: return false;
false;
never executed: return false;
0
138 }-
139-
140 clearError();-
141 return
executed 15318 times by 4 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
true;
executed 15318 times by 4 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
15318
142}-
143-
144-
145-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9