From 66142b071a2497d7e3cf58d7bf5159bb1c970d84 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 2 Aug 2005 14:08:18 +0000 Subject: [PATCH] * allow caller to specifiy additional CFLAGS arguments to bootstrap.sh * fix some warnings (and some real errors) found when compiling avahi with excessive GCC warnings git-svn-id: file:///home/lennart/svn/public/avahi/trunk@209 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-common/address.c | 8 +-- avahi-common/strlst-test.c | 2 +- avahi-common/strlst.c | 6 +- avahi-core/announce.h | 6 +- avahi-core/avahi-test.c | 8 +-- avahi-core/browse.c | 2 +- avahi-core/cache.c | 2 +- avahi-core/conformance-test.c | 3 +- avahi-core/dns-test.c | 3 +- avahi-core/dns.c | 59 +++++++++--------- avahi-core/dns.h | 6 +- avahi-core/iface.c | 53 +++++++++-------- avahi-core/iface.h | 10 ++-- avahi-core/netlink.c | 27 +++++---- avahi-core/resolve-service.c | 8 +-- avahi-core/server.c | 49 +++++++-------- avahi-core/socket.c | 16 ++--- avahi-core/socket.h | 8 +-- avahi-core/timeeventq-test.c | 2 +- avahi-daemon/main.c | 105 +++++++++++++++++---------------- avahi-daemon/simple-protocol.c | 2 +- avahi-daemon/static-services.c | 1 + avahi-dnsconfd/main.c | 2 +- bootstrap.sh | 2 +- 24 files changed, 201 insertions(+), 189 deletions(-) diff --git a/avahi-common/address.c b/avahi-common/address.c index b982a2c..8f1848e 100644 --- a/avahi-common/address.c +++ b/avahi-common/address.c @@ -142,9 +142,9 @@ AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddres ret_addr->family = sa->sa_family; if (sa->sa_family == AF_INET) - memcpy(&ret_addr->data.ipv4, &((struct sockaddr_in*) sa)->sin_addr, sizeof(ret_addr->data.ipv4)); + memcpy(&ret_addr->data.ipv4, &((const struct sockaddr_in*) sa)->sin_addr, sizeof(ret_addr->data.ipv4)); else - memcpy(&ret_addr->data.ipv6, &((struct sockaddr_in6*) sa)->sin6_addr, sizeof(ret_addr->data.ipv6)); + memcpy(&ret_addr->data.ipv6, &((const struct sockaddr_in6*) sa)->sin6_addr, sizeof(ret_addr->data.ipv6)); return ret_addr; } @@ -155,9 +155,9 @@ guint16 avahi_port_from_sockaddr(const struct sockaddr* sa) { g_assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6); if (sa->sa_family == AF_INET) - return ntohs(((struct sockaddr_in*) sa)->sin_port); + return ntohs(((const struct sockaddr_in*) sa)->sin_port); else - return ntohs(((struct sockaddr_in6*) sa)->sin6_port); + return ntohs(((const struct sockaddr_in6*) sa)->sin6_port); } gboolean avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) { diff --git a/avahi-common/strlst-test.c b/avahi-common/strlst-test.c index afc13b1..58ca60d 100644 --- a/avahi-common/strlst-test.c +++ b/avahi-common/strlst-test.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) { a = avahi_string_list_add(a, "foo"); a = avahi_string_list_add(a, "bar"); a = avahi_string_list_add(a, "quux"); - a = avahi_string_list_add_arbitrary(a, (guint8*) "null\0null", 9); + a = avahi_string_list_add_arbitrary(a, (const guint8*) "null\0null", 9); a = avahi_string_list_add(a, "end"); t = avahi_string_list_to_string(a); diff --git a/avahi-common/strlst.c b/avahi-common/strlst.c index d8206e1..d4d67da 100644 --- a/avahi-common/strlst.c +++ b/avahi-common/strlst.c @@ -246,12 +246,12 @@ AvahiStringList *avahi_string_list_copy(const AvahiStringList *l) { AvahiStringList *avahi_string_list_new_from_array(const gchar *array[], gint length) { AvahiStringList *r = NULL; - gint index; + gint i; g_assert(array); - for (index = 0; length >= 0 ? index < length : !!array[index]; index++) - r = avahi_string_list_add(r, array[index]); + for (i = 0; length >= 0 ? i < length : !!array[i]; i++) + r = avahi_string_list_add(r, array[i]); return r; } diff --git a/avahi-core/announce.h b/avahi-core/announce.h index 244a00f..1cab21f 100644 --- a/avahi-core/announce.h +++ b/avahi-core/announce.h @@ -64,10 +64,10 @@ void avahi_entry_group_check_probed(AvahiEntryGroup *g, gboolean immediately); gboolean avahi_entry_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i); gboolean avahi_entry_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i); -void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, gboolean send); -void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, gboolean send); +void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, gboolean send_goodbye); +void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, gboolean send_goodbye); -void avahi_goodbye_all(AvahiServer *s, gboolean send); +void avahi_goodbye_all(AvahiServer *s, gboolean send_goodbye); AvahiAnnouncement *avahi_get_announcement(AvahiServer *s, AvahiEntry *e, AvahiInterface *i); diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c index 5953937..f966659 100644 --- a/avahi-core/avahi-test.c +++ b/avahi-core/avahi-test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -180,18 +181,17 @@ static void sb_callback(AvahiServiceBrowser *b, gint iface, guchar protocol, Ava avahi_log_debug("SB: (%i.%i) <%s> as %s in <%s> [%s]", iface, protocol, name, service_type, domain, event == AVAHI_BROWSER_NEW ? "new" : "remove"); } - -static void sr_callback(AvahiServiceResolver *r, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *service_name, const gchar*service_type, const gchar*domain_name, const gchar*hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) { +static void sr_callback(AvahiServiceResolver *r, gint iface, guchar protocol, AvahiBrowserEvent event, const gchar *name, const gchar*service_type, const gchar*domain_name, const gchar*hostname, const AvahiAddress *a, guint16 port, AvahiStringList *txt, gpointer userdata) { if (event == AVAHI_RESOLVER_TIMEOUT) - avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, service_name, service_type, domain_name); + avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s> [timeout]", iface, protocol, name, service_type, domain_name); else { gchar t[64], *s; avahi_address_snprint(t, sizeof(t), a); s = avahi_string_list_to_string(txt); - avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [found]", iface, protocol, service_name, service_type, domain_name, hostname, t, port, s); + avahi_log_debug("SR: (%i.%i) <%s> as %s in <%s>: %s/%s:%i (%s) [found]", iface, protocol, name, service_type, domain_name, hostname, t, port, s); g_free(s); } } diff --git a/avahi-core/browse.c b/avahi-core/browse.c index 2d14c90..897cb2b 100644 --- a/avahi-core/browse.c +++ b/avahi-core/browse.c @@ -105,7 +105,7 @@ static void scan_interface_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, avahi_cache_walk(i->cache, s->key, scan_cache_callback, &cbdata); } -gboolean scan_idle_callback(gpointer data) { +static gboolean scan_idle_callback(gpointer data) { AvahiRecordBrowser *b = data; g_assert(b); diff --git a/avahi-core/cache.c b/avahi-core/cache.c index 7060433..174fceb 100644 --- a/avahi-core/cache.c +++ b/avahi-core/cache.c @@ -224,7 +224,7 @@ static void next_expiry(AvahiCache *c, AvahiCacheEntry *e, guint percent) { usec = ((AvahiUsec) e->record->ttl) * 10000; /* 2% jitter */ - usec = (AvahiUsec) g_random_double_range(usec*percent, usec*(percent+2)); + usec = (AvahiUsec) g_random_double_range((gdouble) (usec*percent), (gdouble) (usec*(percent+2))); /* g_message("next expiry: %lli (%s)", usec / 1000000, txt = avahi_record_to_string(e->record)); */ /* g_free(txt); */ diff --git a/avahi-core/conformance-test.c b/avahi-core/conformance-test.c index f7eba12..f8e0c93 100644 --- a/avahi-core/conformance-test.c +++ b/avahi-core/conformance-test.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "core.h" #include "util.h" @@ -50,7 +51,7 @@ static gboolean dump_timeout(gpointer data) { static void entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata); -static void create_service(gchar *t) { +static void create_service(const gchar *t) { gchar *n; g_assert(t || name); diff --git a/avahi-core/dns-test.c b/avahi-core/dns-test.c index 07cd529..6b98ef3 100644 --- a/avahi-core/dns-test.c +++ b/avahi-core/dns-test.c @@ -28,7 +28,8 @@ #include "log.h" int main(int argc, char *argv[]) { - gchar t[256], *a, *b, *c, *d; + gchar t[256]; + const gchar *a, *b, *c, *d; AvahiDnsPacket *p; p = avahi_dns_packet_new(0); diff --git a/avahi-core/dns.c b/avahi-core/dns.c index f5d4075..2801386 100644 --- a/avahi-core/dns.c +++ b/avahi-core/dns.c @@ -117,24 +117,25 @@ void avahi_dns_packet_free(AvahiDnsPacket *p) { g_free(p); } -void avahi_dns_packet_set_field(AvahiDnsPacket *p, guint index, guint16 v) { +void avahi_dns_packet_set_field(AvahiDnsPacket *p, guint idx, guint16 v) { g_assert(p); - g_assert(index < AVAHI_DNS_PACKET_HEADER_SIZE); + g_assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE); - ((guint16*) AVAHI_DNS_PACKET_DATA(p))[index] = g_htons(v); + ((guint16*) AVAHI_DNS_PACKET_DATA(p))[idx] = g_htons(v); } -guint16 avahi_dns_packet_get_field(AvahiDnsPacket *p, guint index) { +guint16 avahi_dns_packet_get_field(AvahiDnsPacket *p, guint idx) { g_assert(p); - g_assert(index < AVAHI_DNS_PACKET_HEADER_SIZE); + g_assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE); - return g_ntohs(((guint16*) AVAHI_DNS_PACKET_DATA(p))[index]); + return g_ntohs(((guint16*) AVAHI_DNS_PACKET_DATA(p))[idx]); } -void avahi_dns_packet_inc_field(AvahiDnsPacket *p, guint index) { +void avahi_dns_packet_inc_field(AvahiDnsPacket *p, guint idx) { g_assert(p); + g_assert(idx < AVAHI_DNS_PACKET_HEADER_SIZE); - avahi_dns_packet_set_field(p, index, avahi_dns_packet_get_field(p, index) + 1); + avahi_dns_packet_set_field(p, idx, avahi_dns_packet_get_field(p, idx) + 1); } guint8* avahi_dns_packet_append_name(AvahiDnsPacket *p, const gchar *name) { @@ -155,19 +156,19 @@ guint8* avahi_dns_packet_append_name(AvahiDnsPacket *p, const gchar *name) { /* Check whether we can compress this name. */ if (p->name_table && (prev = g_hash_table_lookup(p->name_table, name))) { - guint index; + guint idx; g_assert(prev >= AVAHI_DNS_PACKET_DATA(p)); - index = (guint) (prev - AVAHI_DNS_PACKET_DATA(p)); + idx = (guint) (prev - AVAHI_DNS_PACKET_DATA(p)); - g_assert(index < p->size); + g_assert(idx < p->size); - if (index < 0x4000) { + if (idx < 0x4000) { guint16 *t; if (!(t = (guint16*) avahi_dns_packet_extend(p, sizeof(guint16)))) return NULL; - *t = g_htons((0xC000 | index)); + *t = g_htons((0xC000 | idx)); return saved_ptr; } } @@ -290,7 +291,7 @@ gint avahi_dns_packet_is_query(AvahiDnsPacket *p) { return !(avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS) & AVAHI_DNS_FLAG_QR); } -static gint consume_labels(AvahiDnsPacket *p, guint index, gchar *ret_name, guint l) { +static gint consume_labels(AvahiDnsPacket *p, guint idx, gchar *ret_name, guint l) { gint ret = 0; int compressed = 0; int first_label = 1; @@ -299,13 +300,13 @@ static gint consume_labels(AvahiDnsPacket *p, guint index, gchar *ret_name, guin for (;;) { guint8 n; - if (index+1 > p->size) + if (idx+1 > p->size) return -1; - n = AVAHI_DNS_PACKET_DATA(p)[index]; + n = AVAHI_DNS_PACKET_DATA(p)[idx]; if (!n) { - index++; + idx++; if (!compressed) ret++; @@ -317,11 +318,11 @@ static gint consume_labels(AvahiDnsPacket *p, guint index, gchar *ret_name, guin } else if (n <= 63) { /* Uncompressed label */ - index++; + idx++; if (!compressed) ret++; - if (index + n > p->size) + if (idx + n > p->size) return -1; if ((guint) n + 1 > l) @@ -333,20 +334,20 @@ static gint consume_labels(AvahiDnsPacket *p, guint index, gchar *ret_name, guin } else first_label = 0; - if (!(avahi_escape_label(AVAHI_DNS_PACKET_DATA(p) + index, n, &ret_name, &l))) + if (!(avahi_escape_label(AVAHI_DNS_PACKET_DATA(p) + idx, n, &ret_name, &l))) return -1; - index += n; + idx += n; if (!compressed) ret += n; } else if ((n & 0xC0) == 0xC0) { /* Compressed label */ - if (index+2 > p->size) + if (idx+2 > p->size) return -1; - index = ((guint) (AVAHI_DNS_PACKET_DATA(p)[index] & ~0xC0)) << 8 | AVAHI_DNS_PACKET_DATA(p)[index+1]; + idx = ((guint) (AVAHI_DNS_PACKET_DATA(p)[idx] & ~0xC0)) << 8 | AVAHI_DNS_PACKET_DATA(p)[idx+1]; if (!compressed) ret += 2; @@ -574,7 +575,7 @@ AvahiRecord* avahi_dns_packet_consume_record(AvahiDnsPacket *p, gboolean *ret_ca /* avahi_log_debug("%i == %u ?", (guint8*) avahi_dns_packet_get_rptr(p) - (guint8*) start, rdlength); */ /* Check if we read enough data */ - if ((guint8*) avahi_dns_packet_get_rptr(p) - (guint8*) start != rdlength) + if ((const guint8*) avahi_dns_packet_get_rptr(p) - (const guint8*) start != rdlength) goto fail; return r; @@ -671,16 +672,16 @@ guint8* avahi_dns_packet_append_record(AvahiDnsPacket *p, AvahiRecord *r, gboole case AVAHI_DNS_TYPE_TXT: { guint8 *data; - guint size; + guint n; - size = avahi_string_list_serialize(r->data.txt.string_list, NULL, 0); + n = avahi_string_list_serialize(r->data.txt.string_list, NULL, 0); -/* avahi_log_debug("appending string: %u %p", size, r->data.txt.string_list); */ +/* avahi_log_debug("appending string: %u %p", n, r->data.txt.string_list); */ - if (!(data = avahi_dns_packet_extend(p, size))) + if (!(data = avahi_dns_packet_extend(p, n))) goto fail; - avahi_string_list_serialize(r->data.txt.string_list, data, size); + avahi_string_list_serialize(r->data.txt.string_list, data, n); break; } diff --git a/avahi-core/dns.h b/avahi-core/dns.h index 03d9798..bb132c1 100644 --- a/avahi-core/dns.h +++ b/avahi-core/dns.h @@ -44,9 +44,9 @@ AvahiDnsPacket* avahi_dns_packet_new_response(guint mtu, gboolean aa); AvahiDnsPacket* avahi_dns_packet_new_reply(AvahiDnsPacket* p, guint mtu, gboolean copy_queries, gboolean aa); void avahi_dns_packet_free(AvahiDnsPacket *p); -void avahi_dns_packet_set_field(AvahiDnsPacket *p, guint index, guint16 v); -guint16 avahi_dns_packet_get_field(AvahiDnsPacket *p, guint index); -void avahi_dns_packet_inc_field(AvahiDnsPacket *p, guint index); +void avahi_dns_packet_set_field(AvahiDnsPacket *p, guint idx, guint16 v); +guint16 avahi_dns_packet_get_field(AvahiDnsPacket *p, guint idx); +void avahi_dns_packet_inc_field(AvahiDnsPacket *p, guint idx); guint8 *avahi_dns_packet_extend(AvahiDnsPacket *p, guint l); diff --git a/avahi-core/iface.c b/avahi-core/iface.c index d068f28..ad26ab0 100644 --- a/avahi-core/iface.c +++ b/avahi-core/iface.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "iface.h" #include "netlink.h" @@ -39,12 +40,12 @@ #include "util.h" #include "log.h" -static void update_address_rr(AvahiInterfaceMonitor *m, AvahiInterfaceAddress *a, gboolean remove) { +static void update_address_rr(AvahiInterfaceMonitor *m, AvahiInterfaceAddress *a, gboolean remove_rrs) { g_assert(m); g_assert(a); if (avahi_interface_address_relevant(a) && - !remove && + !remove_rrs && m->server->config.publish_addresses && (m->server->state == AVAHI_SERVER_RUNNING || m->server->state == AVAHI_SERVER_REGISTERING)) { @@ -71,26 +72,26 @@ static void update_address_rr(AvahiInterfaceMonitor *m, AvahiInterfaceAddress *a } } -static void update_interface_rr(AvahiInterfaceMonitor *m, AvahiInterface *i, gboolean remove) { +static void update_interface_rr(AvahiInterfaceMonitor *m, AvahiInterface *i, gboolean remove_rrs) { AvahiInterfaceAddress *a; g_assert(m); g_assert(i); for (a = i->addresses; a; a = a->address_next) - update_address_rr(m, a, remove); + update_address_rr(m, a, remove_rrs); } -static void update_hw_interface_rr(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, gboolean remove) { +static void update_hw_interface_rr(AvahiInterfaceMonitor *m, AvahiHwInterface *hw, gboolean remove_rrs) { AvahiInterface *i; g_assert(m); g_assert(hw); for (i = hw->interfaces; i; i = i->by_hardware_next) - update_interface_rr(m, i, remove); + update_interface_rr(m, i, remove_rrs); - if (!remove && + if (!remove_rrs && m->server->config.publish_workstation && (m->server->state == AVAHI_SERVER_RUNNING || m->server->state == AVAHI_SERVER_REGISTERING)) { @@ -247,9 +248,9 @@ static void check_interface_relevant(AvahiInterfaceMonitor *m, AvahiInterface *i avahi_log_debug("New relevant interface %s.%i (#%i)", i->hardware->name, i->protocol, i->hardware->index); if (i->protocol == AVAHI_PROTO_INET) - avahi_mdns_mcast_join_ipv4(i->hardware->index, m->server->fd_ipv4); + avahi_mdns_mcast_join_ipv4(m->server->fd_ipv4, i->hardware->index); if (i->protocol == AVAHI_PROTO_INET6) - avahi_mdns_mcast_join_ipv6(i->hardware->index, m->server->fd_ipv6); + avahi_mdns_mcast_join_ipv6(m->server->fd_ipv6, i->hardware->index); i->announcing = TRUE; avahi_announce_interface(m->server, i); @@ -258,9 +259,9 @@ static void check_interface_relevant(AvahiInterfaceMonitor *m, AvahiInterface *i avahi_log_debug("Interface %s.%i no longer relevant", i->hardware->name, i->protocol); if (i->protocol == AVAHI_PROTO_INET) - avahi_mdns_mcast_leave_ipv4(i->hardware->index, m->server->fd_ipv4); + avahi_mdns_mcast_leave_ipv4(m->server->fd_ipv4, i->hardware->index); if (i->protocol == AVAHI_PROTO_INET6) - avahi_mdns_mcast_leave_ipv6(i->hardware->index, m->server->fd_ipv6); + avahi_mdns_mcast_leave_ipv6(m->server->fd_ipv6, i->hardware->index); avahi_goodbye_interface(m->server, i, FALSE); avahi_response_scheduler_clear(i->response_scheduler); @@ -282,7 +283,7 @@ static void check_hw_interface_relevant(AvahiInterfaceMonitor *m, AvahiHwInterfa check_interface_relevant(m, i); } -static void callback(AvahiNetlink *nl, struct nlmsghdr *n, gpointer userdata) { +static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, gpointer userdata) { AvahiInterfaceMonitor *m = userdata; g_assert(m); @@ -468,7 +469,7 @@ AvahiInterfaceMonitor *avahi_interface_monitor_new(AvahiServer *s) { m = g_new0(AvahiInterfaceMonitor, 1); m->server = s; - if (!(m->netlink = avahi_netlink_new(s->context, G_PRIORITY_DEFAULT-10, RTMGRP_LINK|RTMGRP_IPV4_IFADDR|RTMGRP_IPV6_IFADDR, callback, m))) + if (!(m->netlink = avahi_netlink_new(s->context, G_PRIORITY_DEFAULT-10, RTMGRP_LINK|RTMGRP_IPV4_IFADDR|RTMGRP_IPV6_IFADDR, netlink_callback, m))) goto fail; m->hash_table = g_hash_table_new(g_int_hash, g_int_equal); @@ -516,15 +517,15 @@ void avahi_interface_monitor_free(AvahiInterfaceMonitor *m) { } -AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex index, AvahiProtocol protocol) { +AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol) { AvahiHwInterface *hw; AvahiInterface *i; g_assert(m); - g_assert(index > 0); + g_assert(idx > 0); g_assert(protocol != AVAHI_PROTO_UNSPEC); - if (!(hw = avahi_interface_monitor_get_hw_interface(m, index))) + if (!(hw = avahi_interface_monitor_get_hw_interface(m, idx))) return NULL; for (i = hw->interfaces; i; i = i->by_hardware_next) @@ -534,11 +535,11 @@ AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, return NULL; } -AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, AvahiIfIndex index) { +AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx) { g_assert(m); - g_assert(index > 0); + g_assert(idx > 0); - return g_hash_table_lookup(m->hash_table, &index); + return g_hash_table_lookup(m->hash_table, &idx); } @@ -651,10 +652,10 @@ gboolean avahi_interface_address_relevant(AvahiInterfaceAddress *a) { } -gboolean avahi_interface_match(AvahiInterface *i, AvahiIfIndex index, AvahiProtocol protocol) { +gboolean avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol) { g_assert(i); - if (index > 0 && index != i->hardware->index) + if (idx > 0 && idx != i->hardware->index) return FALSE; if (protocol != AVAHI_PROTO_UNSPEC && protocol != i->protocol) @@ -693,13 +694,13 @@ void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex interfa } } -void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove) { +void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove_rrs) { AvahiHwInterface *hw; g_assert(m); for (hw = m->hw_interfaces; hw; hw = hw->hardware_next) - update_hw_interface_rr(m, hw, remove); + update_hw_interface_rr(m, hw, remove_rrs); } gboolean avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a) { @@ -735,13 +736,13 @@ gboolean avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress * if ((g_ntohl(a->data.ipv4.address) & m) == (g_ntohl(ia->address.data.ipv4.address) & m)) return TRUE; } else { - guint i; + guint j; guchar pl; g_assert(a->family == AVAHI_PROTO_INET6); pl = ia->prefix_len; - for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { guint8 m; if (pl == 0) @@ -755,7 +756,7 @@ gboolean avahi_interface_address_on_link(AvahiInterface *i, const AvahiAddress * pl = 0; } - if ((a->data.ipv6.address[i] & m) != (ia->address.data.ipv6.address[i] & m)) + if ((a->data.ipv6.address[j] & m) != (ia->address.data.ipv6.address[j] & m)) break; } } diff --git a/avahi-core/iface.h b/avahi-core/iface.h index 33d20f0..c5c3c61 100644 --- a/avahi-core/iface.h +++ b/avahi-core/iface.h @@ -112,8 +112,8 @@ void avahi_interface_monitor_free(AvahiInterfaceMonitor *m); void avahi_interface_monitor_sync(AvahiInterfaceMonitor *m); -AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex index, AvahiProtocol protocol); -AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, gint index); +AvahiInterface* avahi_interface_monitor_get_interface(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol); +AvahiHwInterface* avahi_interface_monitor_get_hw_interface(AvahiInterfaceMonitor *m, gint idx); void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p); void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port); @@ -127,13 +127,13 @@ void avahi_dump_caches(AvahiInterfaceMonitor *m, AvahiDumpCallback callback, gpo gboolean avahi_interface_relevant(AvahiInterface *i); gboolean avahi_interface_address_relevant(AvahiInterfaceAddress *a); -gboolean avahi_interface_match(AvahiInterface *i, AvahiIfIndex index, AvahiProtocol protocol); +gboolean avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol); typedef void (*AvahiInterfaceMonitorWalkCallback)(AvahiInterfaceMonitor *m, AvahiInterface *i, gpointer userdata); -void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex index, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, gpointer userdata); +void avahi_interface_monitor_walk(AvahiInterfaceMonitor *m, AvahiIfIndex idx, AvahiProtocol protocol, AvahiInterfaceMonitorWalkCallback callback, gpointer userdata); -void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove); +void avahi_update_host_rrs(AvahiInterfaceMonitor *m, gboolean remove_rrs); gboolean avahi_address_is_local(AvahiInterfaceMonitor *m, const AvahiAddress *a); diff --git a/avahi-core/netlink.c b/avahi-core/netlink.c index ff88b91..119e195 100644 --- a/avahi-core/netlink.c +++ b/avahi-core/netlink.c @@ -39,6 +39,8 @@ struct AvahiNetlink { GSource *source; void (*callback) (AvahiNetlink *nl, struct nlmsghdr *n, gpointer userdata); gpointer userdata; + guint8* buffer; + guint buffer_length; }; gboolean avahi_netlink_work(AvahiNetlink *nl, gboolean block) { @@ -47,19 +49,22 @@ gboolean avahi_netlink_work(AvahiNetlink *nl, gboolean block) { for (;;) { ssize_t bytes; struct nlmsghdr *p; - guint8 buffer[64*1024]; - p = (struct nlmsghdr *) buffer; + for (;;) { + if ((bytes = recv(nl->fd, nl->buffer, nl->buffer_length, block ? 0 : MSG_DONTWAIT)) < 0) { - if ((bytes = recv(nl->fd, buffer, sizeof(buffer), block ? 0 : MSG_DONTWAIT)) < 0) { - - if (errno == EAGAIN || errno == EINTR) - break; + if (errno == EAGAIN || errno == EINTR) + return TRUE; + + avahi_log_warn("NETLINK: recv() failed: %s", strerror(errno)); + return FALSE; + } - avahi_log_warn("NETLINK: recv() failed: %s", strerror(errno)); - return FALSE; + break; } + p = (struct nlmsghdr *) nl->buffer; + if (nl->callback) { for (; bytes > 0; p = NLMSG_NEXT(p, bytes)) { if (!NLMSG_OK(p, (size_t) bytes)) { @@ -72,10 +77,8 @@ gboolean avahi_netlink_work(AvahiNetlink *nl, gboolean block) { } if (block) - break; + return TRUE; } - - return TRUE; } static gboolean prepare_func(GSource *source, gint *timeout) { @@ -144,6 +147,7 @@ AvahiNetlink *avahi_netlink_new(GMainContext *context, gint priority, guint32 gr nl->seq = 0; nl->callback = cb; nl->userdata = userdata; + nl->buffer = g_new(guint8, nl->buffer_length = 64*1024); nl->source = g_source_new(&source_funcs, sizeof(GSource) + sizeof(AvahiNetlink*)); *((AvahiNetlink**) (((guint8*) nl->source) + sizeof(GSource))) = nl; @@ -167,6 +171,7 @@ void avahi_netlink_free(AvahiNetlink *nl) { g_source_unref(nl->source); g_main_context_unref(nl->context); close(nl->fd); + g_free(nl->buffer); g_free(nl); } diff --git a/avahi-core/resolve-service.c b/avahi-core/resolve-service.c index 6567d37..cf07d91 100644 --- a/avahi-core/resolve-service.c +++ b/avahi-core/resolve-service.c @@ -107,8 +107,8 @@ static void finish(AvahiServiceResolver *r, AvahiResolverEvent event) { g_assert(FALSE); } - snprintf(sn, sizeof(sn), r->service_name); - snprintf(st, sizeof(st), r->service_type); + g_snprintf(sn, sizeof(sn), r->service_name); + g_snprintf(st, sizeof(st), r->service_type); if ((i = strlen(sn)) > 0 && sn[i-1] == '.') sn[i-1] = 0; @@ -220,8 +220,8 @@ AvahiServiceResolver *avahi_service_resolver_new(AvahiServer *server, gint inter n = t; l = sizeof(t); - avahi_escape_label((guint8*) name, strlen(name), &n, &l); - snprintf(n, l, ".%s.%s", r->service_type, r->domain_name); + avahi_escape_label((const guint8*) name, strlen(name), &n, &l); + g_snprintf(n, l, ".%s.%s", r->service_type, r->domain_name); avahi_elapse_time(&tv, 1000, 0); r->time_event = avahi_time_event_queue_add(server->time_event_queue, &tv, time_event_callback, r); diff --git a/avahi-core/server.c b/avahi-core/server.c index d63f5ec..bd4f536 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "server.h" #include "util.h" @@ -667,7 +668,7 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter } static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) { - guint n, index = (guint) -1; + guint n, idx = (guint) -1; AvahiLegacyUnicastReflectSlot *slot; g_assert(s); @@ -676,66 +677,66 @@ static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) { s->legacy_unicast_reflect_slots = g_new0(AvahiLegacyUnicastReflectSlot*, AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS); for (n = 0; n < AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; n++, s->legacy_unicast_reflect_id++) { - index = s->legacy_unicast_reflect_id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; + idx = s->legacy_unicast_reflect_id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; - if (!s->legacy_unicast_reflect_slots[index]) + if (!s->legacy_unicast_reflect_slots[idx]) break; } - if (index == (guint) -1 || s->legacy_unicast_reflect_slots[index]) + if (idx == (guint) -1 || s->legacy_unicast_reflect_slots[idx]) return NULL; - slot = s->legacy_unicast_reflect_slots[index] = g_new(AvahiLegacyUnicastReflectSlot, 1); + slot = s->legacy_unicast_reflect_slots[idx] = g_new(AvahiLegacyUnicastReflectSlot, 1); slot->id = s->legacy_unicast_reflect_id++; slot->server = s; return slot; } static void deallocate_slot(AvahiServer *s, AvahiLegacyUnicastReflectSlot *slot) { - guint index; + guint idx; g_assert(s); g_assert(slot); - index = slot->id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; + idx = slot->id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; - g_assert(s->legacy_unicast_reflect_slots[index] == slot); + g_assert(s->legacy_unicast_reflect_slots[idx] == slot); avahi_time_event_queue_remove(s->time_event_queue, slot->time_event); g_free(slot); - s->legacy_unicast_reflect_slots[index] = NULL; + s->legacy_unicast_reflect_slots[idx] = NULL; } static void free_slots(AvahiServer *s) { - guint index; + guint idx; g_assert(s); if (!s->legacy_unicast_reflect_slots) return; - for (index = 0; index < AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; index ++) - if (s->legacy_unicast_reflect_slots[index]) - deallocate_slot(s, s->legacy_unicast_reflect_slots[index]); + for (idx = 0; idx < AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; idx ++) + if (s->legacy_unicast_reflect_slots[idx]) + deallocate_slot(s, s->legacy_unicast_reflect_slots[idx]); g_free(s->legacy_unicast_reflect_slots); s->legacy_unicast_reflect_slots = NULL; } static AvahiLegacyUnicastReflectSlot* find_slot(AvahiServer *s, guint16 id) { - guint index; + guint idx; g_assert(s); if (!s->legacy_unicast_reflect_slots) return NULL; - index = id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; + idx = id % AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS; - if (!s->legacy_unicast_reflect_slots[index] || s->legacy_unicast_reflect_slots[index]->id != id) + if (!s->legacy_unicast_reflect_slots[idx] || s->legacy_unicast_reflect_slots[idx]->id != id) return NULL; - return s->legacy_unicast_reflect_slots[index]; + return s->legacy_unicast_reflect_slots[idx]; } static void legacy_unicast_reflect_slot_timeout(AvahiTimeEvent *e, void *userdata) { @@ -824,7 +825,7 @@ static gboolean originates_from_local_legacy_unicast_socket(AvahiServer *s, cons if (getsockname(s->fd_legacy_unicast_ipv4, &lsa, &l) != 0) avahi_log_warn("getsockname(): %s", strerror(errno)); else - return lsa.sin_port == ((struct sockaddr_in*) sa)->sin_port; + return lsa.sin_port == ((const struct sockaddr_in*) sa)->sin_port; } @@ -835,7 +836,7 @@ static gboolean originates_from_local_legacy_unicast_socket(AvahiServer *s, cons if (getsockname(s->fd_legacy_unicast_ipv6, &lsa, &l) != 0) avahi_log_warn("getsockname(): %s", strerror(errno)); else - return lsa.sin6_port == ((struct sockaddr_in6*) sa)->sin6_port; + return lsa.sin6_port == ((const struct sockaddr_in6*) sa)->sin6_port; } return FALSE; @@ -1546,7 +1547,7 @@ void avahi_server_dump(AvahiServer *s, AvahiDumpCallback callback, gpointer user continue; t = avahi_record_to_string(e->record); - snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol); + g_snprintf(ln, sizeof(ln), "%s ; iface=%i proto=%i", t, e->interface, e->protocol); g_free(t); callback(ln, userdata); @@ -1746,8 +1747,8 @@ gint avahi_server_add_service_strlst( d = avahi_normalize_name(domain); t = avahi_normalize_name(type); - snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d); - snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d); + g_snprintf(ptr_name, sizeof(ptr_name), "%s.%s", t, d); + g_snprintf(svc_name, sizeof(svc_name), "%s.%s.%s", ename, t, d); ret = avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, ptr_name, svc_name); @@ -1761,7 +1762,7 @@ gint avahi_server_add_service_strlst( ret |= avahi_server_add_txt_strlst(s, g, interface, protocol, AVAHI_ENTRY_UNIQUE, AVAHI_DEFAULT_TTL, svc_name, strlst); - snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d); + g_snprintf(enum_ptr, sizeof(enum_ptr), "_services._dns-sd._udp.%s", d); ret |=avahi_server_add_ptr(s, g, interface, protocol, AVAHI_ENTRY_NULL, AVAHI_DEFAULT_TTL, enum_ptr, ptr_name); g_free(d); @@ -1898,7 +1899,7 @@ gint avahi_server_add_dns_server_name( domain = s->domain_name; d = avahi_normalize_name(domain); - snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", d); + g_snprintf(t, sizeof(t), "%s.%s", type == AVAHI_DNS_SERVER_RESOLVE ? "_domain._udp" : "_dns-update._udp", d); g_free(d); r = avahi_record_new_full(t, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_SRV, AVAHI_DEFAULT_TTL_HOST_NAME); diff --git a/avahi-core/socket.c b/avahi-core/socket.c index 1b1f2fd..47ffbd3 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -84,7 +84,7 @@ static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const AvahiIPv memcpy(&ret_sa->sin6_addr, a, sizeof(AvahiIPv6Address)); } -int avahi_mdns_mcast_join_ipv4 (int index, int fd) { +int avahi_mdns_mcast_join_ipv4(gint fd, gint idx) { struct ip_mreqn mreq; struct sockaddr_in sa; @@ -92,7 +92,7 @@ int avahi_mdns_mcast_join_ipv4 (int index, int fd) { memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr = sa.sin_addr; - mreq.imr_ifindex = index; + mreq.imr_ifindex = idx; if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { avahi_log_warn("IP_ADD_MEMBERSHIP failed: %s\n", strerror(errno)); @@ -102,7 +102,7 @@ int avahi_mdns_mcast_join_ipv4 (int index, int fd) { return 0; } -int avahi_mdns_mcast_join_ipv6 (int index, int fd) { +int avahi_mdns_mcast_join_ipv6(gint fd, gint idx) { struct ipv6_mreq mreq6; struct sockaddr_in6 sa6; @@ -110,7 +110,7 @@ int avahi_mdns_mcast_join_ipv6 (int index, int fd) { memset(&mreq6, 0, sizeof(mreq6)); mreq6.ipv6mr_multiaddr = sa6.sin6_addr; - mreq6.ipv6mr_interface = index; + mreq6.ipv6mr_interface = idx; if (setsockopt(fd, SOL_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { avahi_log_warn("IPV6_ADD_MEMBERSHIP failed: %s\n", strerror(errno)); @@ -120,7 +120,7 @@ int avahi_mdns_mcast_join_ipv6 (int index, int fd) { return 0; } -int avahi_mdns_mcast_leave_ipv4 (int index, int fd) { +int avahi_mdns_mcast_leave_ipv4(gint fd, gint idx) { struct ip_mreqn mreq; struct sockaddr_in sa; @@ -128,7 +128,7 @@ int avahi_mdns_mcast_leave_ipv4 (int index, int fd) { memset(&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr = sa.sin_addr; - mreq.imr_ifindex = index; + mreq.imr_ifindex = idx; if (setsockopt(fd, SOL_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { avahi_log_warn("IP_DROP_MEMBERSHIP failed: %s\n", strerror(errno)); @@ -138,7 +138,7 @@ int avahi_mdns_mcast_leave_ipv4 (int index, int fd) { return 0; } -int avahi_mdns_mcast_leave_ipv6 (int index, int fd) { +int avahi_mdns_mcast_leave_ipv6(gint fd, gint idx) { struct ipv6_mreq mreq6; struct sockaddr_in6 sa6; @@ -146,7 +146,7 @@ int avahi_mdns_mcast_leave_ipv6 (int index, int fd) { memset(&mreq6, 0, sizeof(mreq6)); mreq6.ipv6mr_multiaddr = sa6.sin6_addr; - mreq6.ipv6mr_interface = index; + mreq6.ipv6mr_interface = idx; if (setsockopt(fd, SOL_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { avahi_log_warn("IPV6_DROP_MEMBERSHIP failed: %s\n", strerror(errno)); diff --git a/avahi-core/socket.h b/avahi-core/socket.h index dc0bbdd..0643d79 100644 --- a/avahi-core/socket.h +++ b/avahi-core/socket.h @@ -42,10 +42,10 @@ gint avahi_send_dns_packet_ipv6(gint fd, gint iface, AvahiDnsPacket *p, const Av AvahiDnsPacket *avahi_recv_dns_packet_ipv4(gint fd, struct sockaddr_in*ret_sa, AvahiIPv4Address *ret_dest_address, gint *ret_iface, guint8 *ret_ttl); AvahiDnsPacket *avahi_recv_dns_packet_ipv6(gint fd, struct sockaddr_in6*ret_sa, AvahiIPv6Address *ret_dest_address, gint *ret_iface, guint8 *ret_ttl); -int avahi_mdns_mcast_join_ipv4(int index, int fd); -int avahi_mdns_mcast_join_ipv6(int index, int fd); +int avahi_mdns_mcast_join_ipv4(gint fd, gint idx); +int avahi_mdns_mcast_join_ipv6(gint fd, gint idx); -int avahi_mdns_mcast_leave_ipv4(int index, int fd); -int avahi_mdns_mcast_leave_ipv6(int index, int fd); +int avahi_mdns_mcast_leave_ipv4(gint fd, gint idx); +int avahi_mdns_mcast_leave_ipv6(gint fd, gint idx); #endif diff --git a/avahi-core/timeeventq-test.c b/avahi-core/timeeventq-test.c index 213488e..33cd2b1 100644 --- a/avahi-core/timeeventq-test.c +++ b/avahi-core/timeeventq-test.c @@ -30,7 +30,7 @@ static AvahiTimeEventQueue *q = NULL; -void callback(AvahiTimeEvent*e, gpointer userdata) { +static void callback(AvahiTimeEvent*e, gpointer userdata) { GTimeVal tv = {0, 0}; g_assert(e); g_message("callback(%i)", GPOINTER_TO_INT(userdata)); diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index e5f3070..4891d10 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -80,7 +80,7 @@ static DaemonConfig config; #define MAX_NAME_SERVERS 10 -static gint load_resolv_conf(const DaemonConfig *config) { +static gint load_resolv_conf(const DaemonConfig *c) { gint ret = -1; FILE *f; gint i = 0; @@ -88,7 +88,7 @@ static gint load_resolv_conf(const DaemonConfig *config) { g_strfreev(resolv_conf); resolv_conf = NULL; - if (!config->publish_resolv_conf) + if (!c->publish_resolv_conf) return 0; if (!(f = fopen(RESOLV_CONF, "r"))) { @@ -171,13 +171,13 @@ static void remove_dns_server_entry_groups(void) { } static void server_callback(AvahiServer *s, AvahiServerState state, gpointer userdata) { - DaemonConfig *config = userdata; + DaemonConfig *c = userdata; g_assert(s); - g_assert(config); + g_assert(c); #ifdef ENABLE_DBUS - if (config->enable_dbus) + if (c->enable_dbus) dbus_protocol_server_state_changed(state); #endif @@ -190,8 +190,8 @@ static void server_callback(AvahiServer *s, AvahiServerState state, gpointer use if (resolv_conf && resolv_conf[0]) resolv_conf_entry_group = add_dns_servers(s, resolv_conf); - if (config->publish_dns_servers && config->publish_dns_servers[0]) - dns_servers_entry_group = add_dns_servers(s, config->publish_dns_servers); + if (c->publish_dns_servers && c->publish_dns_servers[0]) + dns_servers_entry_group = add_dns_servers(s, c->publish_dns_servers); simple_protocol_restart_queries(); @@ -225,8 +225,8 @@ static void help(FILE *f, const gchar *argv0) { argv0); } -static gint parse_command_line(DaemonConfig *config, int argc, char *argv[]) { - gint c; +static gint parse_command_line(DaemonConfig *c, int argc, char *argv[]) { + gint o; static const struct option const long_options[] = { { "help", no_argument, NULL, 'h' }, @@ -238,36 +238,36 @@ static gint parse_command_line(DaemonConfig *config, int argc, char *argv[]) { { "check", no_argument, NULL, 'c' }, }; - g_assert(config); + g_assert(c); opterr = 0; - while ((c = getopt_long(argc, argv, "hDkVf:rc", long_options, NULL)) >= 0) { + while ((o = getopt_long(argc, argv, "hDkVf:rc", long_options, NULL)) >= 0) { - switch(c) { + switch(o) { case 'h': - config->command = DAEMON_HELP; + c->command = DAEMON_HELP; break; case 'D': - config->daemonize = TRUE; + c->daemonize = TRUE; break; case 'k': - config->command = DAEMON_KILL; + c->command = DAEMON_KILL; break; case 'V': - config->command = DAEMON_VERSION; + c->command = DAEMON_VERSION; break; case 'f': - g_free(config->config_file); - config->config_file = g_strdup(optarg); + g_free(c->config_file); + c->config_file = g_strdup(optarg); break; case 'r': - config->command = DAEMON_RELOAD; + c->command = DAEMON_RELOAD; break; case 'c': - config->command = DAEMON_CHECK; + c->command = DAEMON_CHECK; break; default: - fprintf(stderr, "Invalid command line argument: %c\n", c); + fprintf(stderr, "Invalid command line argument: %c\n", o); return -1; } } @@ -286,18 +286,18 @@ static gboolean is_yes(const gchar *s) { return *s == 'y' || *s == 'Y'; } -static gint load_config_file(DaemonConfig *config) { +static gint load_config_file(DaemonConfig *c) { int r = -1; GKeyFile *f = NULL; GError *err = NULL; gchar **groups = NULL, **g, **keys = NULL, *v = NULL; - g_assert(config); + g_assert(c); f = g_key_file_new(); g_key_file_set_list_separator(f, ','); - if (!g_key_file_load_from_file(f, config->config_file ? config->config_file : AVAHI_CONFIG_FILE, G_KEY_FILE_NONE, &err)) { + if (!g_key_file_load_from_file(f, c->config_file ? c->config_file : AVAHI_CONFIG_FILE, G_KEY_FILE_NONE, &err)) { fprintf(stderr, "Unable to read config file: %s\n", err->message); goto finish; } @@ -315,25 +315,25 @@ static gint load_config_file(DaemonConfig *config) { v = g_key_file_get_value(f, *g, *k, NULL); if (g_strcasecmp(*k, "host-name") == 0) { - g_free(config->server_config.host_name); - config->server_config.host_name = v; + g_free(c->server_config.host_name); + c->server_config.host_name = v; v = NULL; } else if (g_strcasecmp(*k, "domain-name") == 0) { - g_free(config->server_config.domain_name); - config->server_config.domain_name = v; + g_free(c->server_config.domain_name); + c->server_config.domain_name = v; v = NULL; } else if (g_strcasecmp(*k, "use-ipv4") == 0) - config->server_config.use_ipv4 = is_yes(v); + c->server_config.use_ipv4 = is_yes(v); else if (g_strcasecmp(*k, "use-ipv6") == 0) - config->server_config.use_ipv6 = is_yes(v); + c->server_config.use_ipv6 = is_yes(v); else if (g_strcasecmp(*k, "check-response-ttl") == 0) - config->server_config.check_response_ttl = is_yes(v); + c->server_config.check_response_ttl = is_yes(v); else if (g_strcasecmp(*k, "use-iff-running") == 0) - config->server_config.use_iff_running = is_yes(v); + c->server_config.use_iff_running = is_yes(v); else if (g_strcasecmp(*k, "enable-dbus") == 0) - config->enable_dbus = is_yes(v); + c->enable_dbus = is_yes(v); else if (g_strcasecmp(*k, "drop-root") == 0) - config->drop_root = is_yes(v); + c->drop_root = is_yes(v); else { fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g); goto finish; @@ -356,18 +356,18 @@ static gint load_config_file(DaemonConfig *config) { v = g_key_file_get_string(f, *g, *k, NULL); if (g_strcasecmp(*k, "publish-addresses") == 0) - config->server_config.publish_addresses = is_yes(v); + c->server_config.publish_addresses = is_yes(v); else if (g_strcasecmp(*k, "publish-hinfo") == 0) - config->server_config.publish_hinfo = is_yes(v); + c->server_config.publish_hinfo = is_yes(v); else if (g_strcasecmp(*k, "publish-workstation") == 0) - config->server_config.publish_workstation = is_yes(v); + c->server_config.publish_workstation = is_yes(v); else if (g_strcasecmp(*k, "publish-domain") == 0) - config->server_config.publish_domain = is_yes(v); + c->server_config.publish_domain = is_yes(v); else if (g_strcasecmp(*k, "publish-resolv-conf-dns-servers") == 0) - config->publish_resolv_conf = is_yes(v); + c->publish_resolv_conf = is_yes(v); else if (g_strcasecmp(*k, "publish-dns-servers") == 0) { - g_strfreev(config->publish_dns_servers); - config->publish_dns_servers = g_key_file_get_string_list(f, *g, *k, NULL, NULL); + g_strfreev(c->publish_dns_servers); + c->publish_dns_servers = g_key_file_get_string_list(f, *g, *k, NULL, NULL); } else { fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g); goto finish; @@ -390,9 +390,9 @@ static gint load_config_file(DaemonConfig *config) { v = g_key_file_get_string(f, *g, *k, NULL); if (g_strcasecmp(*k, "enable-reflector") == 0) - config->server_config.enable_reflector = is_yes(v); + c->server_config.enable_reflector = is_yes(v); else if (g_strcasecmp(*k, "reflect-ipv") == 0) - config->server_config.reflect_ipv = is_yes(v); + c->server_config.reflect_ipv = is_yes(v); else { fprintf(stderr, "Invalid configuration key \"%s\" in group \"%s\"\n", *k, *g); goto finish; @@ -501,13 +501,13 @@ static gboolean signal_callback(GIOChannel *source, GIOCondition condition, gpoi return TRUE; } -static gint run_server(DaemonConfig *config) { +static gint run_server(DaemonConfig *c) { GMainLoop *loop = NULL; gint r = -1; GIOChannel *io = NULL; guint watch_id = (guint) -1; - g_assert(config); + g_assert(c); loop = g_main_loop_new(NULL, FALSE); @@ -528,19 +528,19 @@ static gint run_server(DaemonConfig *config) { goto finish; #ifdef ENABLE_DBUS - if (config->enable_dbus) + if (c->enable_dbus) if (dbus_protocol_setup(loop) < 0) goto finish; #endif - if (!(avahi_server = avahi_server_new(NULL, &config->server_config, server_callback, config))) + if (!(avahi_server = avahi_server_new(NULL, &c->server_config, server_callback, c))) goto finish; - load_resolv_conf(config); + load_resolv_conf(c); static_service_load(); - if (config->daemonize) { + if (c->daemonize) { daemon_retval_send(0); r = 0; } @@ -556,7 +556,7 @@ finish: simple_protocol_shutdown(); #ifdef ENABLE_DBUS - if (config->enable_dbus) + if (c->enable_dbus) dbus_protocol_shutdown(); #endif @@ -576,7 +576,7 @@ finish: if (loop) g_main_loop_unref(loop); - if (r != 0 && config->daemonize) + if (r != 0 && c->daemonize) daemon_retval_send(1); return r; @@ -713,7 +713,8 @@ int main(int argc, char *argv[]) { else argv0 = argv[0]; - daemon_pid_file_ident = daemon_log_ident = (char *) argv0; + daemon_pid_file_ident = (const char *) argv0; + daemon_log_ident = argv0; daemon_pid_file_proc = pid_file_proc; if (parse_command_line(&config, argc, argv) < 0) diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c index 87c9ee6..9a1b1e2 100644 --- a/avahi-daemon/simple-protocol.c +++ b/avahi-daemon/simple-protocol.c @@ -151,7 +151,7 @@ static void client_output(Client *c, const guint8*data, guint size) { c->poll_fd.events |= G_IO_OUT; } -static void client_output_printf(Client *c, gchar *format, ...) { +static void client_output_printf(Client *c, const gchar *format, ...) { gchar *t; va_list ap; diff --git a/avahi-daemon/static-services.c b/avahi-daemon/static-services.c index 56345fd..0ac6326 100644 --- a/avahi-daemon/static-services.c +++ b/avahi-daemon/static-services.c @@ -38,6 +38,7 @@ #include #include "main.h" +#include "static-services.h" typedef struct StaticService StaticService; typedef struct StaticServiceGroup StaticServiceGroup; diff --git a/avahi-dnsconfd/main.c b/avahi-dnsconfd/main.c index dc867d8..959f177 100644 --- a/avahi-dnsconfd/main.c +++ b/avahi-dnsconfd/main.c @@ -164,7 +164,7 @@ static ssize_t loop_write(int fd, const void*data, size_t size) { break; ret += r; - data = (guint8*) data + r; + data = (const guint8*) data + r; size -= r; } diff --git a/bootstrap.sh b/bootstrap.sh index 6fe0f86..c5fb4f2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -42,7 +42,7 @@ else run_versioned automake 1.7 -a -c --foreign autoconf -Wall - CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var "$@" + CFLAGS="$CFLAGS -g -O0" ./configure --sysconfdir=/etc --localstatedir=/var "$@" make clean fi -- 2.39.5