[vlc-devel] commit: Fix warning (asprintf return value and some others) ( Rémi Duraffort )

git version control git at videolan.org
Wed Aug 13 22:15:24 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 13 22:07:56 2008 +0200| [c0ab9ac334f0dd03c47846b6bcc50f27efed647a] | committer: Rémi Duraffort 

Fix warning (asprintf return value and some others)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c0ab9ac334f0dd03c47846b6bcc50f27efed647a
---

 modules/access/mms/mmsh.c   |    5 +++--
 modules/audio_output/alsa.c |   31 +++++++++++++++++++------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c
index 0acb5c2..6c1b4cc 100644
--- a/modules/access/mms/mmsh.c
+++ b/modules/access/mms/mmsh.c
@@ -539,8 +539,9 @@ static int OpenConnection( access_t *p_access )
             char *buf;
             char *b64;
 
-            asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
-                       p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" );
+            if( asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
+                       p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" ) == -1 )
+                return VLC_ENOMEM;
 
             b64 = vlc_b64_encode( buf );
             free( buf );
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 325fa5f..6c020d8 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -186,26 +186,26 @@ static void Probe( aout_instance_t * p_aout,
                 {
                 case 1:
                     val.i_int = AOUT_VAR_MONO;
-                    text.psz_string = N_("Mono");
+                    text.psz_string = (char*)N_("Mono");
                     var_Change( p_aout, "audio-device",
                                 VLC_VAR_ADDCHOICE, &val, &text );
                     break;
                 case 2:
                     val.i_int = AOUT_VAR_STEREO;
-                    text.psz_string = N_("Stereo");
+                    text.psz_string = (char*)N_("Stereo");
                     var_Change( p_aout, "audio-device",
                                 VLC_VAR_ADDCHOICE, &val, &text );
                     var_Set( p_aout, "audio-device", val );
                     break;
                 case 4:
                     val.i_int = AOUT_VAR_2F2R;
-                    text.psz_string = N_("2 Front 2 Rear");
+                    text.psz_string = (char*)N_("2 Front 2 Rear");
                     var_Change( p_aout, "audio-device",
                                 VLC_VAR_ADDCHOICE, &val, &text );
                     break;
                 case 6:
                     val.i_int = AOUT_VAR_5_1;
-                    text.psz_string = "5.1";
+                    text.psz_string = (char*)"5.1";
                     var_Change( p_aout, "audio-device",
                                 VLC_VAR_ADDCHOICE, &val, &text );
                     break;
@@ -223,7 +223,7 @@ static void Probe( aout_instance_t * p_aout,
             if ( !snd_pcm_hw_params_test_channels( p_sys->p_snd_pcm, p_hw, 2 ))
             {
                 val.i_int = AOUT_VAR_STEREO;
-                text.psz_string = N_("Stereo");
+                text.psz_string = (char*)N_("Stereo");
                 var_Change( p_aout, "audio-device",
                             VLC_VAR_ADDCHOICE, &val, &text );
                 var_Set( p_aout, "audio-device", val );
@@ -247,7 +247,7 @@ static void Probe( aout_instance_t * p_aout,
                                      SND_PCM_NONBLOCK ) ) )
         {
             val.i_int = AOUT_VAR_SPDIF;
-            text.psz_string = N_("A/52 over S/PDIF");
+            text.psz_string = (char*)N_("A/52 over S/PDIF");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
             if( config_GetInt( p_aout, "spdif" ) )
@@ -915,6 +915,9 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
 {
     module_config_t *p_item;
     int i;
+    (void)newval;
+    (void)oldval;
+    (void)p_unused;
 
     p_item = config_FindConfig( p_this, psz_name );
     if( !p_item ) return VLC_SUCCESS;
@@ -940,7 +943,6 @@ static int FindDevicesCallback( vlc_object_t *p_this, char const *psz_name,
     p_item->b_dirty = true;
 
     return VLC_SUCCESS;
-
 }
 
 
@@ -987,15 +989,20 @@ static void GetDevicesForCard( module_config_t *p_item, int i_card )
             continue;
         }
 
-        asprintf( &psz_device, "hw:%d,%d", i_card, i_pcm_device );
-        asprintf( &psz_descr, "%s: %s (%s)", psz_card_name,
-                  snd_pcm_info_get_name(p_pcm_info), psz_device );
+        if( asprintf( &psz_device, "hw:%d,%d", i_card, i_pcm_device ) == -1 )
+            break;
+        if( asprintf( &psz_descr, "%s: %s (%s)", psz_card_name,
+                  snd_pcm_info_get_name(p_pcm_info), psz_device ) == -1 )
+        {
+            free( psz_device );
+            break;
+        }
 
         p_item->ppsz_list =
-            (const char **)realloc( p_item->ppsz_list,
+            (char **)realloc( p_item->ppsz_list,
                               (p_item->i_list + 2) * sizeof(char *) );
         p_item->ppsz_list_text =
-            (const char **)realloc( p_item->ppsz_list_text,
+            (char **)realloc( p_item->ppsz_list_text,
                               (p_item->i_list + 2) * sizeof(char *) );
         p_item->ppsz_list[ p_item->i_list ] = psz_device;
         p_item->ppsz_list_text[ p_item->i_list ] = psz_descr;




More information about the vlc-devel mailing list