From: RĂ©mi Denis-Courmont Date: Sun, 16 Sep 2007 08:29:09 +0000 (+0000) Subject: GetNonEmptyString simplification X-Git-Tag: 0.9.0-test0~5566 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=00aa3ff1c3da442f986b51f2277936d6629b1666;p=vlc GetNonEmptyString simplification --- diff --git a/modules/access/dvb/http.c b/modules/access/dvb/http.c index 52998011be..cf84027c50 100644 --- a/modules/access/dvb/http.c +++ b/modules/access/dvb/http.c @@ -91,8 +91,8 @@ int E_(HTTPOpen)( access_t *p_access ) p_sys->b_request_frontend_info = p_sys->b_request_mmi_info = VLC_FALSE; p_sys->i_httpd_timeout = 0; - psz_address = var_GetString( p_access, "dvb-http-host" ); - if( psz_address != NULL && *psz_address ) + psz_address = var_GetNonEmptyString( p_access, "dvb-http-host" ); + if( psz_address != NULL ) { char *psz_parser = strchr( psz_address, ':' ); if( psz_parser ) @@ -102,14 +102,11 @@ int E_(HTTPOpen)( access_t *p_access ) } } else - { - if ( psz_address != NULL ) free( psz_address ); return VLC_SUCCESS; - } /* determine SSL configuration */ - psz_cert = var_GetString( p_access, "dvb-http-intf-cert" ); - if ( psz_cert != NULL && *psz_cert ) + psz_cert = var_GetNonEmptyString( p_access, "dvb-http-intf-cert" ); + if ( psz_cert != NULL ) { msg_Dbg( p_access, "enabling TLS for HTTP interface (cert file: %s)", psz_cert ); @@ -122,11 +119,6 @@ int E_(HTTPOpen)( access_t *p_access ) } else { - if ( !*psz_cert ) - { - free( psz_cert ); - psz_cert = NULL; - } if ( i_port <= 0 ) i_port= 8082; } @@ -140,10 +132,10 @@ int E_(HTTPOpen)( access_t *p_access ) p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_access), psz_address, i_port, psz_cert, psz_key, psz_ca, psz_crl ); - FREE( psz_cert ); - FREE( psz_key ); - FREE( psz_ca ); - FREE( psz_crl ); + free( psz_cert ); + free( psz_key ); + free( psz_ca ); + free( psz_crl ); if ( p_sys->p_httpd_host == NULL ) { @@ -175,9 +167,9 @@ int E_(HTTPOpen)( access_t *p_access ) psz_user, psz_password, p_acl, HttpCallback, f ); - FREE( psz_user ); - FREE( psz_password ); - FREE( psz_acl ); + free( psz_user ); + free( psz_password ); + free( psz_acl ); if ( p_acl != NULL ) ACL_Destroy( p_acl ); diff --git a/modules/access_filter/timeshift.c b/modules/access_filter/timeshift.c index cd605de7de..49c49a353d 100644 --- a/modules/access_filter/timeshift.c +++ b/modules/access_filter/timeshift.c @@ -555,15 +555,9 @@ static int Control( access_t *p_access, int i_query, va_list args ) #endif static char *GetTmpFilePath( access_t *p_access ) { - char *psz_dir = var_GetString( p_access, "timeshift-dir" ); + char *psz_dir = var_GetNonEmptyString( p_access, "timeshift-dir" ); char *psz_filename_base; - if( ( psz_dir != NULL ) && ( psz_dir[0] == '\0' ) ) - { - free( psz_dir ); - psz_dir = NULL; - } - if( psz_dir == NULL ) { #ifdef WIN32 diff --git a/modules/control/http/http.c b/modules/control/http/http.c index 1f78b66a6a..d4c780c63e 100644 --- a/modules/control/http/http.c +++ b/modules/control/http/http.c @@ -136,12 +136,7 @@ static int Open( vlc_object_t *p_this ) int i_port = 0; char *psz_src; - var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING ); - psz_address = var_GetString(p_intf->p_libvlc, "http-host"); - if( !psz_address || !*psz_address ) - { - psz_address = config_GetPsz( p_intf, "http-host" ); - } + psz_address = var_GetNonEmptyString(p_intf->p_libvlc, "http-host"); if( psz_address != NULL ) { char *psz_parser = strchr( psz_address, ':' ); @@ -260,9 +255,9 @@ static int Open( vlc_object_t *p_this ) { msg_Dbg( p_intf, "enabling TLS for HTTP interface (cert file: %s)", psz_cert ); - psz_key = config_GetPsz( p_intf, "http-intf-key" ); - psz_ca = config_GetPsz( p_intf, "http-intf-ca" ); - psz_crl = config_GetPsz( p_intf, "http-intf-crl" ); + psz_key = var_GetNonEmptyString( p_intf, "http-intf-key" ); + psz_ca = var_GetNonEmptyString( p_intf, "http-intf-ca" ); + psz_crl = var_GetNonEmptyString( p_intf, "http-intf-crl" ); if( i_port <= 0 ) i_port = 8443; @@ -292,6 +287,7 @@ static int Open( vlc_object_t *p_this ) /* Ugly hack to run several HTTP servers on different ports */ snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 ); + var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING ); var_SetString( p_intf->p_libvlc, "http-host", psz_tmp ); } @@ -379,11 +375,8 @@ static int Open( vlc_object_t *p_this ) return VLC_SUCCESS; failed: - if( psz_src ) free( psz_src ); - if( p_sys->pp_files ) - { - free( p_sys->pp_files ); - } + free( psz_src ); + free( p_sys->pp_files ); httpd_HostDelete( p_sys->p_httpd_host ); free( p_sys->psz_address ); free( p_sys->psz_html_type );