@@ -290,7 +290,7 @@ PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short
290
290
}
291
291
}
292
292
293
- snprintf (port_buf , 7 , "%u" , port );
293
+ snprintf (port_buf , sizeof ( port_buf ) , "%u" , port );
294
294
if (!any_addr ) {
295
295
rc = getaddrinfo (addr , port_buf , & hints , & res );
296
296
} else {
@@ -301,20 +301,18 @@ PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short
301
301
#ifndef PHP_WIN32
302
302
if (rc == EAI_SYSTEM ) {
303
303
char buf [128 ];
304
- int wrote ;
305
304
306
- wrote = snprintf (buf , 128 , "Could not translate address '%s'" , addr );
307
- buf [ wrote ] = '\0' ;
305
+ snprintf (buf , sizeof ( buf ) , "Could not translate address '%s'" , addr );
306
+
308
307
zend_quiet_write (PHPDBG_G (io )[PHPDBG_STDERR ].fd , buf , strlen (buf ));
309
308
310
309
return sock ;
311
310
} else {
312
311
#endif
313
312
char buf [256 ];
314
- int wrote ;
315
313
316
- wrote = snprintf (buf , 256 , "Host '%s' not found. %s" , addr , estrdup (gai_strerror (rc )));
317
- buf [ wrote ] = '\0' ;
314
+ snprintf (buf , sizeof ( buf ) , "Host '%s' not found. %s" , addr , estrdup (gai_strerror (rc )));
315
+
318
316
zend_quiet_write (PHPDBG_G (io )[PHPDBG_STDERR ].fd , buf , strlen (buf ));
319
317
320
318
return sock ;
@@ -324,13 +322,10 @@ PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, unsigned short
324
322
return sock ;
325
323
}
326
324
327
- if ((sock = socket (res -> ai_family , res -> ai_socktype , res -> ai_protocol )) == -1 ) {
328
- char buf [128 ];
329
- int wrote ;
325
+ if ((sock = socket (res -> ai_family , res -> ai_socktype , res -> ai_protocol )) == -1 ) {
326
+ const char * msg = "Unable to create socket" ;
330
327
331
- wrote = sprintf (buf , "Unable to create socket" );
332
- buf [wrote ] = '\0' ;
333
- zend_quiet_write (PHPDBG_G (io )[PHPDBG_STDERR ].fd , buf , strlen (buf ));
328
+ zend_quiet_write (PHPDBG_G (io )[PHPDBG_STDERR ].fd , msg , strlen (msg ));
334
329
335
330
return sock ;
336
331
}
0 commit comments