Changeset 2add48902670c9b3885b4450d8d0f6a375731956

Show
Ignore:
Timestamp:
05/08/08 19:16:40 (2 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1210267000 +0300
git-parent:

[061224eb63c7f2566e470510bd2b2edbba0d536a]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1210267000 +0300
Message:

Fix a bunch of warnings (error handling)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/input/vlm.c

    r061224e r2add489  
    154154 
    155155        msg_Dbg( p_this, "loading VLM configuration" ); 
    156         asprintf(&psz_buffer, "load %s", psz_vlmconf ); 
     156        if( asprintf(&psz_buffer, "load %s", psz_vlmconf ) == -1 ) 
     157            psz_buffer = NULL; 
    157158        if( psz_buffer ) 
    158159        { 
     
    677678    psz_save = Save( p_vlm ); 
    678679    if( psz_save == NULL ) 
    679     { 
    680         fclose( f ); 
    681680        goto error; 
    682     } 
    683     fwrite( psz_save, strlen( psz_save ), 1, f ); 
     681    if( fputs( psz_save, f ) == EOF ) 
     682        goto error;; 
     683    if( fclose( f ) ) 
     684    { 
     685        f = NULL; 
     686        goto error; 
     687    } 
     688 
    684689    free( psz_save ); 
    685     fclose( f ); 
    686690 
    687691    *pp_status = vlm_MessageNew( "save", vlm_NULL ); 
     
    689693 
    690694error: 
    691     *pp_status = vlm_MessageNew( "save", "Unable to save to file" ); 
     695    free( psz_save ); 
     696    if( f ) 
     697         fclose( f ); 
     698    *pp_status = vlm_MessageNew( "save", "Unable to save to file"); 
    692699    return VLC_EGENERIC; 
    693700} 
     
    14521459    { 
    14531460        char *psz_tmp; 
    1454         asprintf( &psz_tmp, "%d", i+1 ); 
    1455         vlm_MessageAdd( p_msg_sub, 
    1456                         vlm_MessageNew( psz_tmp, p_cfg->ppsz_input[i] ) ); 
    1457         free( psz_tmp ); 
     1461        if( asprintf( &psz_tmp, "%d", i+1 ) != -1 ) 
     1462        { 
     1463            vlm_MessageAdd( p_msg_sub, 
     1464                            vlm_MessageNew( psz_tmp, p_cfg->ppsz_input[i] ) ); 
     1465            free( psz_tmp ); 
     1466        } 
    14581467    } 
    14591468 
     
    14911500        { 
    14921501#define APPEND_INPUT_INFO( a, format, type ) \ 
    1493             asprintf( &psz_tmp, format, \ 
    1494                       var_Get ## type( p_instance->p_input, a ) ); \ 
    1495             vlm_MessageAdd( p_msg_instance, vlm_MessageNew( a, psz_tmp ) ); \ 
    1496             free( psz_tmp ); 
     1502            if( asprintf( &psz_tmp, format, \ 
     1503                      var_Get ## type( p_instance->p_input, a ) ) != -1 ) \ 
     1504            { \ 
     1505                vlm_MessageAdd( p_msg_instance, vlm_MessageNew( a, \ 
     1506                                psz_tmp ) ); \ 
     1507                free( psz_tmp ); \ 
     1508            } 
    14971509            APPEND_INPUT_INFO( "position", "%f", Float ); 
    14981510            APPEND_INPUT_INFO( "time", "%"PRIi64, Time ); 
     
    15041516        } 
    15051517#undef APPEND_INPUT_INFO 
    1506         asprintf( &psz_tmp, "%d", p_instance->i_index + 1 ); 
    1507         vlm_MessageAdd( p_msg_instance, vlm_MessageNew( "playlistindex", psz_tmp ) ); 
    1508         free( psz_tmp ); 
     1518        if( asprintf( &psz_tmp, "%d", p_instance->i_index + 1 ) != -1 ) 
     1519        { 
     1520            vlm_MessageAdd( p_msg_instance, vlm_MessageNew( "playlistindex", 
     1521                            psz_tmp ) ); 
     1522            free( psz_tmp ); 
     1523        } 
    15091524    } 
    15101525    return p_msg; 
     
    15491564 
    15501565            localtime_r( &i_time, &date); 
    1551             asprintf( &psz_date, "%d/%d/%d-%d:%d:%d", 
    1552                       date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, 
    1553                       date.tm_hour, date.tm_min, date.tm_sec ); 
    1554  
    1555             vlm_MessageAdd( msg_schedule, 
    1556                             vlm_MessageNew( "date", psz_date ) ); 
    1557             free( psz_date ); 
     1566            if( asprintf( &psz_date, "%d/%d/%d-%d:%d:%d", 
     1567                          date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, 
     1568                          date.tm_hour, date.tm_min, date.tm_sec ) != -1 ) 
     1569            { 
     1570                 vlm_MessageAdd( msg_schedule, 
     1571                                 vlm_MessageNew( "date", psz_date ) ); 
     1572                 free( psz_date ); 
     1573            } 
    15581574        } 
    15591575        else 
     
    16231639        } 
    16241640 
    1625         asprintf( &psz_count, "( %d broadcast - %d vod )", i_broadcast, i_vod); 
    1626  
     1641        if( asprintf( &psz_count, "( %d broadcast - %d vod )", i_broadcast, 
     1642                      i_vod) == -1 ) 
     1643            return NULL; 
    16271644        p_msg = vlm_MessageNew( "show", vlm_NULL ); 
    16281645        p_msg_child = vlm_MessageAdd( p_msg, vlm_MessageNew( "media", psz_count ) );