{
int sd;
int status;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_return;
struct addrinfo *ai_list;
/* TODO: Change this to `AF_UNSPEC' if apcupsd can handle IPv6 */
- ai_hints.ai_family = AF_INET;
- ai_hints.ai_socktype = SOCK_STREAM;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_INET,
+ .ai_socktype = SOCK_STREAM
+ };
status = getaddrinfo (node, service, &ai_hints, &ai_return);
if (status != 0)
connect_client(const char *p_hostname,
const char *p_service, int p_family, int p_socktype)
{
- struct addrinfo hints = { 0 };
- struct addrinfo *res = NULL, *ressave = NULL;
+ struct addrinfo *res, *ressave;
int n, sockfd;
- hints.ai_family = p_family;
- hints.ai_socktype = p_socktype;
+ struct addrinfo ai_hints = {
+ .ai_family = p_family,
+ .ai_socktype = p_socktype
+ };
- n = getaddrinfo(p_hostname, p_service, &hints, &res);
+ n = getaddrinfo(p_hostname, p_service, &ai_hints, &res);
if (n < 0)
{
{
const char *str;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (IS_FALSE (str))
return (0);
- ai_hints.ai_flags = AI_CANONNAME;
+ struct addrinfo ai_hints = {
+ .ai_flags = AI_CANONNAME
+ };
status = getaddrinfo (hostname_g, NULL, &ai_hints, &ai_list);
if (status != 0)
{
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints = { 0 };
int status;
int service_number;
return (-1);
ai_list = NULL;
- ai_hints.ai_family = AF_UNSPEC;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC
+ };
status = getaddrinfo (/* node = */ NULL, service_name,
&ai_hints, &ai_list);
size_t *ret_sockets_num,
const char *node, const char *service, int listen)
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int ai_return;
if (*ret_sockets != NULL)
return (EINVAL);
- ai_hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_protocol = IPPROTO_UDP;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG | AI_PASSIVE,
+ .ai_protocol = IPPROTO_UDP,
+ .ai_socktype = SOCK_DGRAM
+ };
ai_return = getaddrinfo (node, service, &ai_hints, &ai_list);
if (ai_return != 0)
const char *host;
const char *port;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = PF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = IPPROTO_TCP;
-
host = hddtemp_host;
if (host == NULL)
host = HDDTEMP_DEF_HOST;
if (strlen (port) == 0)
port = HDDTEMP_DEF_PORT;
+ struct addrinfo ai_hints = {
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_family = PF_UNSPEC,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_socktype = SOCK_STREAM
+ };
+
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
char errbuf[1024];
static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */
const char *addr_orig)
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_res;
struct addrinfo *ai_ptr;
char addr_copy[NI_MAXHOST];
addr_copy[sizeof(addr_copy) - 1] = '\0';
addr = addr_copy;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
-
port = NULL;
if (*addr == '[') /* IPv6+port format */
{
}
ai_res = NULL;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM
+ };
+
status = getaddrinfo (addr,
port == NULL ? LCC_DEFAULT_PORT : port,
&ai_hints, &ai_res);
static int server_open_socket (lcc_server_t *srv) /* {{{ */
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list = NULL;
struct addrinfo *ai_ptr;
int status;
if (srv->fd >= 0)
server_close_socket (srv);
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_DGRAM
+ };
status = getaddrinfo (srv->node, srv->service, &ai_hints, &ai_list);
if (status != 0)
const char *host;
const char *port;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = PF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = IPPROTO_TCP;
-
host = mbmon_host;
if (host == NULL)
host = MBMON_DEF_HOST;
if (port == NULL)
port = MBMON_DEF_PORT;
+ struct addrinfo ai_hints = {
+ .ai_family = PF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_socktype = SOCK_STREAM
+ };
+
if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
char errbuf[1024];
const char *host;
const char *port;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int status;
int fd = -1;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = 0;
-
host = (st->host != NULL) ? st->host : MEMCACHED_DEF_HOST;
port = (st->port != NULL) ? st->port : MEMCACHED_DEF_PORT;
ai_list = NULL;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM
+ };
+
status = getaddrinfo (host, port, &ai_hints, &ai_list);
if (status != 0)
{
{
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints = { 0 };
int status;
if ((host == NULL) || (address == NULL))
return (EINVAL);
- ai_hints.ai_flags = AI_ADDRCONFIG;
- /* XXX: libmodbus can only handle IPv4 addresses. */
- ai_hints.ai_family = AF_INET;
- ai_hints.ai_addr = NULL;
- ai_hints.ai_canonname = NULL;
- ai_hints.ai_next = NULL;
-
ai_list = NULL;
+
+ struct addrinfo ai_hints = {
+ /* XXX: libmodbus can only handle IPv4 addresses. */
+ .ai_family = AF_INET,
+ .ai_flags = AI_ADDRCONFIG
+ };
+
status = getaddrinfo (address, /* service = */ NULL,
&ai_hints, &ai_list);
if (status != 0)
static c_complain_t complaint = C_COMPLAIN_INIT_STATIC;
struct sockent_client *client;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list = NULL, *ai_ptr;
int status;
_Bool reconnect = 0;
if (client->fd >= 0 && !reconnect) /* already connected and not stale*/
return (0);
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_protocol = IPPROTO_UDP;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_protocol = IPPROTO_UDP,
+ .ai_socktype = SOCK_DGRAM
+ };
status = getaddrinfo (se->node,
(se->service != NULL) ? se->service : NET_DEFAULT_PORT,
/* Open the file descriptors for a initialized sockent structure. */
static int sockent_server_listen (sockent_t *se) /* {{{ */
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int status;
DEBUG ("network plugin: sockent_server_listen: node = %s; service = %s;",
node, service);
- ai_hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_protocol = IPPROTO_UDP;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG | AI_PASSIVE,
+ .ai_protocol = IPPROTO_UDP,
+ .ai_socktype = SOCK_DGRAM
+ };
status = getaddrinfo (node, service, &ai_hints, &ai_list);
if (status != 0)
const char *host;
const char *port;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (strlen (port) == 0)
port = NTPD_DEFAULT_PORT;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = PF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_protocol = IPPROTO_UDP;
+ struct addrinfo ai_hints = {
+ .ai_family = PF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_protocol = IPPROTO_UDP,
+ .ai_socktype = SOCK_DGRAM
+ };
if ((status = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
{
static FILE *olsrd_connect (void) /* {{{ */
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list, *ai_ptr;
int ai_return;
FILE *fh;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = PF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = IPPROTO_TCP;
-
ai_list = NULL;
+
+ struct addrinfo ai_hints = {
+ .ai_family = PF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_socktype = SOCK_STREAM
+ };
+
ai_return = getaddrinfo (olsrd_get_node (), olsrd_get_service (),
&ai_hints, &ai_list);
if (ai_return != 0)
pinba_socket_t *s;
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints = { 0 };
int status;
- ai_hints.ai_flags = AI_PASSIVE;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_addr = NULL;
- ai_hints.ai_canonname = NULL;
- ai_hints.ai_next = NULL;
-
if (node == NULL)
node = PINBA_DEFAULT_NODE;
service = PINBA_DEFAULT_SERVICE;
ai_list = NULL;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_PASSIVE,
+ .ai_socktype = SOCK_DGRAM
+ };
+
status = getaddrinfo (node, service,
&ai_hints, &ai_list);
if (status != 0)
struct pollfd *fds = NULL;
size_t fds_num = 0;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list = NULL;
struct addrinfo *ai_ptr;
int status;
char const *service = (conf_service != NULL)
? conf_service : STATSD_DEFAULT_SERVICE;
- ai_hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_DGRAM;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_PASSIVE | AI_ADDRCONFIG,
+ .ai_socktype = SOCK_DGRAM
+ };
status = getaddrinfo (node, service, &ai_hints, &ai_list);
if (status != 0)
* Returns connected file objects or establishes the connection
* if it's not already present
*/
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_head;
struct addrinfo *ai_ptr;
int sd = -1;
}
/* Get all addrs for this hostname */
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM
+ };
status = getaddrinfo ((config_host != NULL) ? config_host : DEFAULT_HOST,
(config_port != NULL) ? config_port : DEFAULT_PORT,
static int wg_callback_init (struct wg_callback *cb)
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
cdtime_t now;
return (EAGAIN);
cb->last_connect_time = now;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG
+ };
if (0 == strcasecmp ("tcp", cb->protocol))
ai_hints.ai_socktype = SOCK_STREAM;
static int sensu_connect(struct sensu_host *host) /* {{{ */
{
int e;
- struct addrinfo *ai, hints;
+ struct addrinfo *ai;
char const *node;
char const *service;
// Resolve the target if we haven't done already
if (!(host->flags & F_READY)) {
- memset(&hints, 0, sizeof(hints));
memset(&service, 0, sizeof(service));
host->res = NULL;
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_ADDRCONFIG;
node = (host->node != NULL) ? host->node : SENSU_HOST;
service = (host->service != NULL) ? host->service : SENSU_PORT;
- if ((e = getaddrinfo(node, service, &hints, &(host->res))) != 0) {
+ struct addrinfo ai_hints = {
+ .ai_family = AF_INET,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM
+ };
+
+ if ((e = getaddrinfo(node, service, &ai_hints, &(host->res))) != 0) {
ERROR("write_sensu plugin: Unable to resolve host \"%s\": %s",
node, gai_strerror(e));
return -1;
static int wt_callback_init(struct wt_callback *cb)
{
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
int status;
if (cb->sock_fd > 0)
return 0;
- ai_hints.ai_flags = AI_ADDRCONFIG;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
-
ai_list = NULL;
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_ADDRCONFIG,
+ .ai_socktype = SOCK_STREAM
+ };
+
status = getaddrinfo(node, service, &ai_hints, &ai_list);
if (status != 0)
{
{
int sk = -1;
int status;
- struct addrinfo ai_hints = { 0 };
struct addrinfo *ai;
struct addrinfo *ai_list;
const char *host;
const char *port;
- ai_hints.ai_family = AF_UNSPEC;
- ai_hints.ai_socktype = SOCK_STREAM;
-
host = (zk_host != NULL) ? zk_host : ZOOKEEPER_DEF_HOST;
port = (zk_port != NULL) ? zk_port : ZOOKEEPER_DEF_PORT;
+
+ struct addrinfo ai_hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_socktype = SOCK_STREAM
+ };
+
status = getaddrinfo (host, port, &ai_hints, &ai_list);
if (status != 0)
{