diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2013-11-03 22:28:17 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2013-11-03 22:46:45 +0100 |
commit | 465f876f35fcdbf773523a216c0025a29b784c0c (patch) | |
tree | 0014c10e07c4f6d08c554e7af8bc6846a7bdc719 /sd | |
parent | 8378d3a7da3de3459870f10612e75f11915aa023 (diff) |
cppcheck: reduce scope in AvahiNetworkService
Change-Id: Ida14cc278187fdc7519137829a920273ed4910b3
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/remotecontrol/AvahiNetworkService.cxx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx index 34b94a364c0e..04d8e572a132 100644 --- a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx +++ b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx @@ -79,8 +79,6 @@ static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, } static void create_services(AvahiClient *c) { - char *n, r[128]; - int ret; assert(c); /* If this is the first time we're called, let's create a new @@ -97,13 +95,18 @@ static void create_services(AvahiClient *c) { if (avahi_entry_group_is_empty(group)) { fprintf(stderr, "Adding service '%s'\n", avahiService->getName().c_str()); + char r[128]; snprintf(r, sizeof(r), "random=%i", rand()); - if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), avahiService->getName().c_str(), kREG_TYPE, NULL, NULL, 1599, "local", r, NULL)) < 0) { + int ret = avahi_entry_group_add_service( + group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), + avahiService->getName().c_str(), kREG_TYPE, NULL, NULL, 1599, "local", r, NULL + ); + if (ret < 0) { if (ret == AVAHI_ERR_COLLISION){ /* A service name collision with a local service happened. Let's * pick a new name */ - n = avahi_alternative_service_name(avahiService->getName().c_str()); + char *n = avahi_alternative_service_name(avahiService->getName().c_str()); avahiService->setName(n); fprintf(stderr, "Service name collision, renaming service to '%s'\n", avahiService->getName().c_str()); |