@@ -204,15 +204,16 @@ static int tr2_dst_try_uds_connect(const char *path, int sock_type, int *out_fd)
204
204
205
205
fd = socket (AF_UNIX , sock_type , 0 );
206
206
if (fd == -1 )
207
- return errno ;
207
+ return -1 ;
208
208
209
209
sa .sun_family = AF_UNIX ;
210
210
strlcpy (sa .sun_path , path , sizeof (sa .sun_path ));
211
211
212
212
if (connect (fd , (struct sockaddr * )& sa , sizeof (sa )) == -1 ) {
213
- int e = errno ;
213
+ int saved_errno = errno ;
214
214
close (fd );
215
- return e ;
215
+ errno = saved_errno ;
216
+ return -1 ;
216
217
}
217
218
218
219
* out_fd = fd ;
@@ -227,7 +228,6 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,
227
228
{
228
229
unsigned int uds_try = 0 ;
229
230
int fd ;
230
- int e ;
231
231
const char * path = NULL ;
232
232
233
233
/*
@@ -271,23 +271,21 @@ static int tr2_dst_try_unix_domain_socket(struct tr2_dst *dst,
271
271
}
272
272
273
273
if (uds_try & TR2_DST_UDS_TRY_STREAM ) {
274
- e = tr2_dst_try_uds_connect (path , SOCK_STREAM , & fd );
275
- if (!e )
274
+ if (!tr2_dst_try_uds_connect (path , SOCK_STREAM , & fd ))
276
275
goto connected ;
277
- if (e != EPROTOTYPE )
276
+ if (errno != EPROTOTYPE )
278
277
goto error ;
279
278
}
280
279
if (uds_try & TR2_DST_UDS_TRY_DGRAM ) {
281
- e = tr2_dst_try_uds_connect (path , SOCK_DGRAM , & fd );
282
- if (!e )
280
+ if (!tr2_dst_try_uds_connect (path , SOCK_DGRAM , & fd ))
283
281
goto connected ;
284
282
}
285
283
286
284
error :
287
285
if (tr2_dst_want_warning ())
288
286
warning ("trace2: could not connect to socket '%s' for '%s' tracing: %s" ,
289
287
path , tr2_sysenv_display_name (dst -> sysenv_var ),
290
- strerror (e ));
288
+ strerror (errno ));
291
289
292
290
tr2_dst_trace_disable (dst );
293
291
return 0 ;
0 commit comments