@@ -128,31 +128,19 @@ static void _init_caps(struct __test_metadata *const _metadata, bool drop_all)
128
128
EXPECT_EQ (0 , cap_set_secbits (noroot ));
129
129
130
130
cap_p = cap_get_proc ();
131
- EXPECT_NE (NULL , cap_p )
132
- {
133
- TH_LOG ("Failed to cap_get_proc: %s" , strerror (errno ));
134
- }
135
- EXPECT_NE (-1 , cap_clear (cap_p ))
136
- {
137
- TH_LOG ("Failed to cap_clear: %s" , strerror (errno ));
138
- }
131
+ EXPECT_NE (NULL , cap_p );
132
+ EXPECT_NE (-1 , cap_clear (cap_p ));
139
133
if (!drop_all ) {
140
134
EXPECT_NE (-1 , cap_set_flag (cap_p , CAP_PERMITTED ,
141
- ARRAY_SIZE (caps ), caps , CAP_SET ))
142
- {
143
- TH_LOG ("Failed to cap_set_flag: %s" , strerror (errno ));
144
- }
135
+ ARRAY_SIZE (caps ), caps , CAP_SET ));
145
136
}
146
137
147
138
/* Automatically resets ambient capabilities. */
148
139
EXPECT_NE (-1 , cap_set_proc (cap_p ))
149
140
{
150
- TH_LOG ("Failed to cap_set_proc: %s" , strerror (errno ));
151
- }
152
- EXPECT_NE (-1 , cap_free (cap_p ))
153
- {
154
- TH_LOG ("Failed to cap_free: %s" , strerror (errno ));
141
+ TH_LOG ("Failed to set capabilities: %s" , strerror (errno ));
155
142
}
143
+ EXPECT_NE (-1 , cap_free (cap_p ));
156
144
157
145
/* Quickly checks that ambient capabilities are cleared. */
158
146
EXPECT_NE (-1 , cap_get_ambient (caps [0 ]));
@@ -176,22 +164,13 @@ static void _change_cap(struct __test_metadata *const _metadata,
176
164
cap_t cap_p ;
177
165
178
166
cap_p = cap_get_proc ();
179
- EXPECT_NE (NULL , cap_p )
180
- {
181
- TH_LOG ("Failed to cap_get_proc: %s" , strerror (errno ));
182
- }
183
- EXPECT_NE (-1 , cap_set_flag (cap_p , flag , 1 , & cap , value ))
184
- {
185
- TH_LOG ("Failed to cap_set_flag: %s" , strerror (errno ));
186
- }
167
+ EXPECT_NE (NULL , cap_p );
168
+ EXPECT_NE (-1 , cap_set_flag (cap_p , flag , 1 , & cap , value ));
187
169
EXPECT_NE (-1 , cap_set_proc (cap_p ))
188
170
{
189
- TH_LOG ("Failed to cap_set_proc: %s" , strerror (errno ));
190
- }
191
- EXPECT_NE (-1 , cap_free (cap_p ))
192
- {
193
- TH_LOG ("Failed to cap_free: %s" , strerror (errno ));
171
+ TH_LOG ("Failed to set capability %d: %s" , cap , strerror (errno ));
194
172
}
173
+ EXPECT_NE (-1 , cap_free (cap_p ));
195
174
}
196
175
197
176
static void __maybe_unused set_cap (struct __test_metadata * const _metadata ,
0 commit comments