Commit 96b7100a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

var_CreateGetNEString simplications

parent 528f0214
...@@ -321,17 +321,15 @@ net_IPv4Join (vlc_object_t *obj, int fd, ...@@ -321,17 +321,15 @@ net_IPv4Join (vlc_object_t *obj, int fd,
socklen_t optlen; socklen_t optlen;
/* Multicast interface IPv4 address */ /* Multicast interface IPv4 address */
char *iface = var_CreateGetString (obj, "miface-addr"); char *iface = var_CreateGetNonEmptyString (obj, "miface-addr");
if (iface != NULL) if ((iface != NULL)
&& (inet_pton (AF_INET, iface, &id) <= 0))
{ {
if ((*iface) msg_Err (obj, "invalid multicast interface address %s", iface);
&& (inet_pton (AF_INET, iface, &id) <= 0)) free (iface);
{ goto error;
msg_Err (obj, "invalid multicast interface address %s", iface);
free (iface);
goto error;
}
} }
free (iface);
memset (&opt, 0, sizeof (opt)); memset (&opt, 0, sizeof (opt));
if (src != NULL) if (src != NULL)
...@@ -428,18 +426,15 @@ net_SourceSubscribe (vlc_object_t *obj, int fd, ...@@ -428,18 +426,15 @@ net_SourceSubscribe (vlc_object_t *obj, int fd,
{ {
int level, iid = 0; int level, iid = 0;
char *iface = var_CreateGetString (obj, "miface"); char *iface = var_CreateGetNonEmptyString (obj, "miface");
if (iface != NULL) if (iface != NULL)
{ {
if (*iface) iid = if_nametoindex (iface);
if (iid == 0)
{ {
iid = if_nametoindex (iface); msg_Err (obj, "invalid multicast interface: %s", iface);
if (iid == 0) free (iface);
{ return -1;
msg_Err (obj, "invalid multicast interface: %s", iface);
free (iface);
return -1;
}
} }
free (iface); free (iface);
} }
...@@ -661,19 +656,17 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -661,19 +656,17 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
if( i_hlim > 0 ) if( i_hlim > 0 )
net_SetMcastHopLimit( p_this, fd, ptr->ai_family, i_hlim ); net_SetMcastHopLimit( p_this, fd, ptr->ai_family, i_hlim );
str = var_CreateGetString (p_this, "miface"); str = var_CreateGetNonEmptyString (p_this, "miface");
if (str != NULL) if (str != NULL)
{ {
if (*str) net_SetMcastOut (p_this, fd, ptr->ai_family, str, NULL);
net_SetMcastOut (p_this, fd, ptr->ai_family, str, NULL);
free (str); free (str);
} }
str = var_CreateGetString (p_this, "miface-addr"); str = var_CreateGetNonEmptyString (p_this, "miface-addr");
if (str != NULL) if (str != NULL)
{ {
if (*str) net_SetMcastOut (p_this, fd, ptr->ai_family, NULL, str);
net_SetMcastOut (p_this, fd, ptr->ai_family, NULL, str);
free (str); free (str);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment