qsharedmemory_systemv.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qsharedmemory_systemv.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13key_t QSharedMemoryPrivate::handle()-
14{-
15-
16 if (unix_key
unix_keyDescription
TRUEnever evaluated
FALSEevaluated 3537 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
)
0-3537
17 return
never executed: return unix_key;
unix_key;
never executed: return unix_key;
0
18-
19-
20 if (nativeKey.isEmpty()
nativeKey.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3536 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
1-3536
21 errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:"));-
22 error = QSharedMemory::KeyError;-
23 return
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QSharedMemory
0;
executed 1 time by 1 test: return 0;
Executed by:
  • tst_QSharedMemory
1
24 }-
25-
26-
27 if (!QFile::exists(nativeKey)
!QFile::exists(nativeKey)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3534 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
2-3534
28 errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:"));-
29 error = QSharedMemory::NotFound;-
30 return
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QSharedMemory
0;
executed 2 times by 1 test: return 0;
Executed by:
  • tst_QSharedMemory
2
31 }-
32-
33 unix_key = qt_safe_ftok(QFile::encodeName(nativeKey), 'Q');-
34 if (-
-1 == unix_keyDescription
TRUEnever evaluated
FALSEevaluated 3534 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
1 == unix_key
-1 == unix_keyDescription
TRUEnever evaluated
FALSEevaluated 3534 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
0-3534
35 errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:"));-
36 error = QSharedMemory::KeyError;-
37 unix_key = 0;-
38 }
never executed: end of block
0
39 return
executed 3534 times by 2 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
unix_key;
executed 3534 times by 2 tests: return unix_key;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
3534
40}-
41int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName)-
42{-
43 int fd = qt_safe_open(QFile::encodeName(fileName).constData(),-
44 0200 | 0100 | 02, 0640);-
45 if (-
-1 == fdDescription
TRUEevaluated 3666 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 6986 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
1 == fd
-1 == fdDescription
TRUEevaluated 3666 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 6986 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
) {
3666-6986
46 if ((*
(*__errno_location ()) == 17Description
TRUEevaluated 3613 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 53 times by 1 test
Evaluated by:
  • tst_QSharedMemory
__errno_location ()) == 17
(*__errno_location ()) == 17Description
TRUEevaluated 3613 times by 3 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
FALSEevaluated 53 times by 1 test
Evaluated by:
  • tst_QSharedMemory
)
53-3613
47 return
executed 3613 times by 3 tests: return 0;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
0;
executed 3613 times by 3 tests: return 0;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
  • tst_qsystemsemaphore - unknown status
3613
48 return
executed 53 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
-1;
executed 53 times by 1 test: return -1;
Executed by:
  • tst_QSharedMemory
53
49 } else {-
50 close(fd);-
51 }
executed 6986 times by 3 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
6986
52 return
executed 6986 times by 3 tests: return 1;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
1;
executed 6986 times by 3 tests: return 1;
Executed by:
  • tst_QSharedMemory
  • tst_QSystemSemaphore
  • tst_qsharedmemory - unknown status
6986
53}-
54-
55-
56-
57-
58bool QSharedMemoryPrivate::cleanHandle()-
59{-
60 unix_key = 0;-
61 return
executed 14289 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
true;
executed 14289 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
14289
62}-
63-
64bool QSharedMemoryPrivate::create(int size)-
65{-
66-
67 bool createdFile = false;-
68 int built = createUnixKeyFile(nativeKey);-
69 if (built == -1
built == -1Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3467 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
53-3467
70 errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:"));-
71 error = QSharedMemory::KeyError;-
72 return
executed 53 times by 1 test: return false;
Executed by:
  • tst_QSharedMemory
false;
executed 53 times by 1 test: return false;
Executed by:
  • tst_QSharedMemory
53
73 }-
74 if (built == 1
built == 1Description
TRUEevaluated 3465 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
2-3465
75 createdFile = true;-
76 }
executed 3465 times by 2 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
3465
77-
78-
79 if (!handle()
!handle()Description
TRUEnever evaluated
FALSEevaluated 3467 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
0-3467
80 if (createdFile
createdFileDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
81 QFile::remove(nativeKey);
never executed: QFile::remove(nativeKey);
0
82 return
never executed: return false;
false;
never executed: return false;
0
83 }-
84-
85-
86 if (-
-1 == shmget(u...01000 | 02000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3465 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
1 == shmget(unix_key, size, 0600 | 01000 | 02000)
-1 == shmget(u...01000 | 02000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 3465 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
2-3465
87 const QLatin1String function("QSharedMemory::create");-
88 switch ((*__errno_location ())) {-
89 case
never executed: case 22:
22:
never executed: case 22:
0
90 errorString = QSharedMemory::tr("%1: system-imposed size restrictions").arg(QLatin1String("QSharedMemory::handle"));-
91 error = QSharedMemory::InvalidSize;-
92 break;
never executed: break;
0
93 default
executed 2 times by 1 test: default:
Executed by:
  • tst_QSharedMemory
:
executed 2 times by 1 test: default:
Executed by:
  • tst_QSharedMemory
2
94 setErrorString(function);-
95 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QSharedMemory
2
96 if (createdFile
createdFileDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedMemory
&& error != QSharedMemory::AlreadyExists
error != QShar...:AlreadyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-2
97 QFile::remove(nativeKey);
never executed: QFile::remove(nativeKey);
0
98 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
99 }-
100-
101 return
executed 3465 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
true;
executed 3465 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
3465
102}-
103-
104bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)-
105{-
106-
107 int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0400 : 0600));-
108 if (-
-1 == idDescription
TRUEnever evaluated
FALSEevaluated 3532 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
1 == id
-1 == idDescription
TRUEnever evaluated
FALSEevaluated 3532 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
0-3532
109 setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));-
110 return
never executed: return false;
false;
never executed: return false;
0
111 }-
112-
113-
114 memory = shmat(id, 0, (mode == QSharedMemory::ReadOnly ? 010000 : 0));-
115 if ((
(void*) - 1 == memoryDescription
TRUEnever evaluated
FALSEevaluated 3532 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
void*) - 1 == memory
(void*) - 1 == memoryDescription
TRUEnever evaluated
FALSEevaluated 3532 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
) {
0-3532
116 memory = 0;-
117 setErrorString(QLatin1String("QSharedMemory::attach (shmat)"));-
118 return
never executed: return false;
false;
never executed: return false;
0
119 }-
120-
121-
122 shmid_ds shmid_ds;-
123 if (!shmctl(id, 2, &shmid_ds)
!shmctl(id, 2, &shmid_ds)Description
TRUEevaluated 3532 times by 2 tests
Evaluated by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
FALSEnever evaluated
) {
0-3532
124 size = (int)shmid_ds.shm_segsz;-
125 }
executed 3532 times by 2 tests: end of block
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
else {
3532
126 setErrorString(QLatin1String("QSharedMemory::attach (shmctl)"));-
127 return
never executed: return false;
false;
never executed: return false;
0
128 }-
129-
130 return
executed 3532 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
true;
executed 3532 times by 2 tests: return true;
Executed by:
  • tst_QSharedMemory
  • tst_qsharedmemory - unknown status
3532
131}-
132-
133bool QSharedMemoryPrivate::detach()-
134{-
135-
136 if (-
-1 == shmdt(memory)Description
TRUEnever evaluated
FALSEevaluated 3531 times by 1 test
Evaluated by:
  • tst_QSharedMemory
1 == shmdt(memory)
-1 == shmdt(memory)Description
TRUEnever evaluated
FALSEevaluated 3531 times by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
0-3531
137 const QLatin1String function("QSharedMemory::detach");-
138 switch ((*__errno_location ())) {-
139 case
never executed: case 22:
22:
never executed: case 22:
0
140 errorString = QSharedMemory::tr("%1: not attached").arg(function);-
141 error = QSharedMemory::NotFound;-
142 break;
never executed: break;
0
143 default
never executed: default:
:
never executed: default:
0
144 setErrorString(function);-
145 }
never executed: end of block
0
146 return
never executed: return false;
false;
never executed: return false;
0
147 }-
148 memory = 0;-
149 size = 0;-
150-
151-
152 int id = shmget(unix_key, 0, 0400);-
153 cleanHandle();-
154-
155 struct shmid_ds shmid_ds;-
156 if (0 != shmctl(id, 2, &shmid_ds)
0 != shmctl(id, 2, &shmid_ds)Description
TRUEnever evaluated
FALSEevaluated 3531 times by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
0-3531
157 switch ((*__errno_location ())) {-
158 case
never executed: case 22:
22:
never executed: case 22:
0
159 return
never executed: return true;
true;
never executed: return true;
0
160 default
never executed: default:
:
never executed: default:
0
161 return
never executed: return false;
false;
never executed: return false;
0
162 }-
163 }-
164-
165 if (shmid_ds.shm_nattch == 0
shmid_ds.shm_nattch == 0Description
TRUEevaluated 3465 times by 1 test
Evaluated by:
  • tst_QSharedMemory
FALSEevaluated 66 times by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
66-3465
166-
167 if (-
-1 == shmctl(id, 0, &shmid_ds)Description
TRUEnever evaluated
FALSEevaluated 3465 times by 1 test
Evaluated by:
  • tst_QSharedMemory
1 == shmctl(id, 0, &shmid_ds)
-1 == shmctl(id, 0, &shmid_ds)Description
TRUEnever evaluated
FALSEevaluated 3465 times by 1 test
Evaluated by:
  • tst_QSharedMemory
) {
0-3465
168 setErrorString(QLatin1String("QSharedMemory::remove"));-
169 switch ((*__errno_location ())) {-
170 case
never executed: case 22:
22:
never executed: case 22:
0
171 return
never executed: return true;
true;
never executed: return true;
0
172 default
never executed: default:
:
never executed: default:
0
173 return
never executed: return false;
false;
never executed: return false;
0
174 }-
175 }-
176-
177-
178 if (!QFile::remove(nativeKey)
!QFile::remove(nativeKey)Description
TRUEnever evaluated
FALSEevaluated 3465 times by 1 test
Evaluated by:
  • tst_QSharedMemory
)
0-3465
179 return
never executed: return false;
false;
never executed: return false;
0
180 }
executed 3465 times by 1 test: end of block
Executed by:
  • tst_QSharedMemory
3465
181 return
executed 3531 times by 1 test: return true;
Executed by:
  • tst_QSharedMemory
true;
executed 3531 times by 1 test: return true;
Executed by:
  • tst_QSharedMemory
3531
182}-
183-
184-
185-
Switch to Source codePreprocessed file

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