vfs_fruit: Time Machine/FULLSYNC: add mDNS/DNS-SD advertisement

Ralph Böhme slow at samba.org
Mon Jul 24 14:25:17 UTC 2017


On Sun, Jul 23, 2017 at 05:14:13PM -0700, Omri Mor wrote:
> >> +	int num_services;
> >> +	int snum;
> >> +	int dk;
> >> +	AvahiStringList *adisk = NULL;
> > 
> > Please move the variables down into the switch block where they're used.
> 
> Where should they go? At the beginning of 'case AVAHI_CLIENT_S_RUNNING’?
>
> ...
>
> If the entire case is enclosed in a new scope, then the variables can be
> declared without any problems.
> 
> switch (status) {
> case AVAHI_CLIENT_S_RUNNING: {
> 	int num_services;
> 	int snum;
> 	int dk;
> 	AvahiStringList *adisk = NULL;
> 
> 	/* do stuff */
> 	break;
> }

yep, that's what I wanted. Sorry for the unclear wording.

> >> +			}
> >> +		}
> >> +		if (dk > 0 && avahi_entry_group_add_service_strlst(
> >> +			    state->entry_group, AVAHI_IF_UNSPEC,
> >> +			    AVAHI_PROTO_UNSPEC, 0, lp_netbios_name(),
> >> +			    "_adisk._tcp", NULL, NULL, 0, adisk) < 0) {
> > 
> > Please split this into:
> > 
> > int ret;
> > 
> > ...
> > 
> > if (dk > 0) {
> >        ret = avahi_entry_group_add_service_strlst(...);
> >        if (ret < 0) {
> > 	        ...error handling...
> >        }
> > }
> 
> I was following the same style as the code above used:
> 
> if (avahi_entry_group_add_service(
> 	    state->entry_group, AVAHI_IF_UNSPEC,
> 	    AVAHI_PROTO_UNSPEC, 0, lp_netbios_name(),
> 	    "_smb._tcp", NULL, NULL, state->port, NULL) < 0) {
> 	error = avahi_client_errno(c);
> 	DEBUG(10, ("avahi_entry_group_add_service failed: "
> 		   "%s\n", avahi_strerror(error)));
> 	avahi_entry_group_free(state->entry_group);
> 	state->entry_group = NULL;
> 	break;
> }
> 
> Should I change that as well?

No, just don't repeat that horror in new code. :)

-slow



More information about the samba-technical mailing list