Changeset 4ff9961862088bf74ca36f04ae3e34094ec9778f

Show
Ignore:
Timestamp:
09/18/07 17:44:47 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1190130287 +0000
git-parent:

[357771f9fee9241d5d9fa0262c4558c3fd57948c]

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

Fix the most common strerror() usages (threads, network, input) - refs #1297

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r2f2ec59 r4ff9961  
    6565#include <stdarg.h> 
    6666 
    67 #include <string.h>                                         /* strerror() */ 
     67#include <string.h> 
    6868#include <stdio.h> 
    6969 
  • include/vlc_network.h

    rf464bb3 r4ff9961  
    6464#   include <netdb.h> 
    6565#   define net_errno errno 
    66 #   define net_strerror strerror 
    6766#endif 
    6867 
  • include/vlc_threads_funcs.h

    r8440f6c r4ff9961  
    8282    /* In case of error : */ 
    8383    unsigned long int i_thread = 0; 
    84     const char * psz_error = ""; 
    8584 
    8685#if defined( PTH_INIT_IN_PTH_H ) 
     
    127126    { 
    128127        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    129         psz_error = strerror(i_result)
     128        errno = i_result
    130129    } 
    131130 
     
    139138    { 
    140139        msg_Err( p_mutex->p_this, 
    141                  "thread %li: mutex_lock failed at %s:%d (%d:%s)", 
    142                  i_thread, psz_file, i_line, i_result, psz_error ); 
     140                 "thread %li: mutex_lock failed at %s:%d (%d:%m)", 
     141                 i_thread, psz_file, i_line, i_result ); 
    143142    } 
    144143    return i_result; 
     
    161160    /* In case of error : */ 
    162161    unsigned long int i_thread = 0; 
    163     const char * psz_error = ""; 
    164162 
    165163#if defined( PTH_INIT_IN_PTH_H ) 
     
    204202    { 
    205203        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    206         psz_error = strerror(i_result)
     204        errno = i_result
    207205    } 
    208206 
     
    216214    { 
    217215        msg_Err( p_mutex->p_this, 
    218                  "thread %li: mutex_unlock failed at %s:%d (%d:%s)", 
    219                  i_thread, psz_file, i_line, i_result, psz_error ); 
     216                 "thread %li: mutex_unlock failed at %s:%d (%d:%m)", 
     217                 i_thread, psz_file, i_line, i_result ); 
    220218    } 
    221219 
     
    247245    /* In case of error : */ 
    248246    unsigned long int i_thread = 0; 
    249     const char * psz_error = ""; 
    250247 
    251248#if defined( PTH_INIT_IN_PTH_H ) 
     
    342339    { 
    343340        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    344         psz_error = strerror(i_result)
     341        errno = i_result
    345342    } 
    346343 
     
    358355    { 
    359356        msg_Err( p_condvar->p_this, 
    360                  "thread %li: cond_signal failed at %s:%d (%d:%s)", 
    361                  i_thread, psz_file, i_line, i_result, psz_error ); 
     357                 "thread %li: cond_signal failed at %s:%d (%d:%m)", 
     358                 i_thread, psz_file, i_line, i_result ); 
    362359    } 
    363360 
     
    377374    /* In case of error : */ 
    378375    unsigned long int i_thread = 0; 
    379     const char * psz_error = ""; 
    380376 
    381377#if defined( PTH_INIT_IN_PTH_H ) 
     
    514510    if( i_result == ETIMEDOUT ) 
    515511    { 
     512        errno = ETIMEDOUT; 
    516513        msg_Dbg( p_condvar->p_this, 
    517514                  "thread %li: possible condition deadlock " 
    518                   "at %s:%d (%s)", CAST_PTHREAD_TO_INT(pthread_self()), 
    519                   psz_file, i_line, strerror(i_result) ); 
     515                  "at %s:%d (%m)", CAST_PTHREAD_TO_INT(pthread_self()), 
     516                  psz_file, i_line ); 
    520517 
    521518        i_result = pthread_cond_wait( &p_condvar->cond, &p_mutex->mutex ); 
     
    529526    { 
    530527        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    531         psz_error = strerror(i_result)
     528        errno = i_result
    532529    } 
    533530 
     
    541538    { 
    542539        msg_Err( p_condvar->p_this, 
    543                  "thread %li: cond_wait failed at %s:%d (%d:%s)", 
    544                  i_thread, psz_file, i_line, i_result, psz_error ); 
     540                 "thread %li: cond_wait failed at %s:%d (%d:%m)", 
     541                 i_thread, psz_file, i_line, i_result ); 
    545542    } 
    546543 
     
    564561    int i_res; 
    565562    unsigned long int i_thread = 0; 
    566     const char * psz_error = ""; 
    567563 
    568564#if defined( PTH_INIT_IN_PTH_H ) 
     
    589585    { 
    590586        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    591         psz_error = strerror(i_res)
     587        errno = i_res
    592588    } 
    593589 
     
    599595    { 
    600596        msg_Err( p_condvar->p_this, 
    601                  "thread %li: cond_wait failed at %s:%d (%d:%s)", 
    602                  i_thread, psz_file, i_line, i_res, psz_error ); 
     597                 "thread %li: cond_wait failed at %s:%d (%d:%m)", 
     598                 i_thread, psz_file, i_line, i_res ); 
    603599    } 
    604600 
  • src/input/meta.c

    r6144922 r4ff9961  
    459459 
    460460        if( err ) 
    461             msg_Err( p_playlist, "%s: %s", psz_filename, strerror( err ) ); 
     461        { 
     462            errno = err; 
     463            msg_Err( p_playlist, "%s: %m", psz_filename ); 
     464        } 
    462465        else 
    463466            msg_Dbg( p_playlist, "album art saved to %s\n", psz_filename ); 
     
    546549    { 
    547550        if( fwrite( p_attachment->p_data, p_attachment->i_data, 1, f ) != 1 ) 
    548             msg_Err( p_input, "%s: %s", psz_filename, strerror( errno ) ); 
     551            msg_Err( p_input, "%s: %m", psz_filename ); 
    549552        else 
    550553            msg_Dbg( p_input, "album art saved to %s\n", psz_filename ); 
  • src/misc/threads.c

    rb0c5b0a r4ff9961  
    331331    /* In case of error : */ 
    332332    int i_thread = -1; 
    333     const char * psz_error = ""; 
    334333 
    335334#if defined( PTH_INIT_IN_PTH_H ) 
     
    368367    { 
    369368        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    370         psz_error = strerror(i_result)
     369        errno = i_result
    371370    } 
    372371 
     
    379378    { 
    380379        msg_Err( p_mutex->p_this, 
    381                  "thread %d: mutex_destroy failed at %s:%d (%d:%s)", 
    382                  i_thread, psz_file, i_line, i_result, psz_error ); 
     380                 "thread %d: mutex_destroy failed at %s:%d (%d:%m)", 
     381                 i_thread, psz_file, i_line, i_result ); 
    383382    } 
    384383    return i_result; 
     
    501500    /* In case of error : */ 
    502501    int i_thread = -1; 
    503     const char * psz_error = ""; 
    504502 
    505503#if defined( PTH_INIT_IN_PTH_H ) 
     
    531529    { 
    532530        i_thread = CAST_PTHREAD_TO_INT(pthread_self()); 
    533         psz_error = strerror(i_result)
     531        errno = i_result
    534532    } 
    535533 
     
    542540    { 
    543541        msg_Err( p_condvar->p_this, 
    544                  "thread %d: cond_destroy failed at %s:%d (%d:%s)", 
    545                  i_thread, psz_file, i_line, i_result, psz_error ); 
     542                 "thread %d: cond_destroy failed at %s:%d (%d:%m)", 
     543                 i_thread, psz_file, i_line, i_result ); 
    546544    } 
    547545    return i_result; 
     
    666664                                               i_policy, &param )) ) 
    667665        { 
    668             msg_Warn( p_this, "couldn't set thread priority (%s:%d): %s", 
    669                       psz_file, i_line, strerror(i_error) ); 
     666            errno = i_error; 
     667            msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m", 
     668                      psz_file, i_line ); 
    670669            i_priority = 0; 
    671670        } 
     
    709708    else 
    710709    { 
    711         msg_Err( p_this, "%s thread could not be created at %s:%d (%s)", 
    712                          psz_name, psz_file, i_line, strerror(i_ret) ); 
     710        errno = i_ret; 
     711        msg_Err( p_this, "%s thread could not be created at %s:%d (%m)", 
     712                         psz_name, psz_file, i_line ); 
    713713        vlc_mutex_unlock( &p_this->object_lock ); 
    714714    } 
     
    763763                                               i_policy, &param )) ) 
    764764        { 
    765             msg_Warn( p_this, "couldn't set thread priority (%s:%d): %s", 
    766                       psz_file, i_line, strerror(i_error) ); 
     765            errno = i_error; 
     766            msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m", 
     767                      psz_file, i_line ); 
    767768            i_priority = 0; 
    768769        } 
     
    882883    if( i_ret ) 
    883884    { 
    884         msg_Err( p_this, "thread_join(%u) failed at %s:%d (%s)", 
    885                          (unsigned int)p_priv->thread_id, psz_file, i_line
    886                          strerror(i_ret) ); 
     885        errno = i_ret; 
     886        msg_Err( p_this, "thread_join(%u) failed at %s:%d (%m)"
     887                         (unsigned int)p_priv->thread_id, psz_file, i_line ); 
    887888    } 
    888889    else 
  • src/network/acl.c

    r6ee1e19 r4ff9961  
    318318            if( ferror( file ) ) 
    319319            { 
    320                 msg_Err( p_acl->p_owner, "error reading %s : %s\n", psz_path, 
    321                         strerror( errno ) ); 
     320                msg_Err( p_acl->p_owner, "error reading %s : %m", psz_path ); 
    322321                goto error; 
    323322            } 
     
    338337        if( ptr == NULL ) 
    339338        { 
    340             msg_Warn( p_acl->p_owner, "skipping overly long line in %s\n", 
     339            msg_Warn( p_acl->p_owner, "skipping overly long line in %s", 
    341340                      psz_path); 
    342341            do 
     
    346345                     if( ferror( file ) ) 
    347346                     { 
    348                          msg_Err( p_acl->p_owner, "error reading %s : %s\n", 
    349                                   psz_path, strerror( errno ) ); 
     347                         msg_Err( p_acl->p_owner, "error reading %s : %m", 
     348                                  psz_path ); 
    350349                     } 
    351350                     goto error; 
  • src/network/httpd.c

    r44cc227 r4ff9961  
    23632363                { 
    23642364                    /* This is most likely a bug */ 
    2365                     msg_Err( host, "polling error: %s", strerror (errno)); 
     2365                    msg_Err( host, "polling error: %m" ); 
    23662366                    msleep( 1000 ); 
    23672367                } 
  • src/network/io.c

    r6ee1e19 r4ff9961  
    8989    { 
    9090        if (net_errno != EAFNOSUPPORT) 
    91             msg_Err (p_this, "cannot create socket: %s", 
    92                      net_strerror (net_errno)); 
     91            msg_Err (p_this, "cannot create socket: %m"); 
    9392        return -1; 
    9493    } 
     
    149148        if (fd == -1) 
    150149        { 
    151             msg_Dbg (p_this, "socket error: %s", net_strerror (net_errno)); 
     150            msg_Dbg (p_this, "socket error: %m"); 
    152151            continue; 
    153152        } 
     
    177176        if (bind (fd, ptr->ai_addr, ptr->ai_addrlen)) 
    178177        { 
    179             int saved_errno = net_errno; 
    180  
    181178            net_Close (fd); 
    182179#if !defined(WIN32) && !defined(UNDER_CE) 
     
    191188#endif 
    192189            { 
    193                 msg_Err (p_this, "socket bind error (%s)", 
    194                          net_strerror( saved_errno ) ); 
     190                msg_Err (p_this, "socket bind error (%m)"); 
    195191                continue; 
    196192            } 
     
    217213                if (listen (fd, INT_MAX)) 
    218214                { 
    219                     msg_Err (p_this, "socket listen error (%s)", 
    220                             net_strerror (net_errno)); 
     215                    msg_Err (p_this, "socket listen error (%m)"); 
    221216                    net_Close (fd); 
    222217                    continue; 
     
    363358 
    364359error: 
    365     msg_Err (p_this, "Read error: %s", net_strerror (net_errno)); 
     360    msg_Err (p_this, "Read error: %m"); 
    366361    return i_total ? (ssize_t)i_total : -1; 
    367362} 
     
    422417        { 
    423418            case -1: 
    424                msg_Err (p_this, "Write error: %s", net_strerror (net_errno)); 
     419               msg_Err (p_this, "Write error: %m"); 
    425420               goto out; 
    426421 
     
    443438        if (val == -1) 
    444439        { 
    445             msg_Err (p_this, "Write error: %s", net_strerror (net_errno)); 
     440            msg_Err (p_this, "Write error: %m"); 
    446441            break; 
    447442        } 
  • src/network/tcp.c

    re3c88d5 r4ff9961  
    148148        if( fd == -1 ) 
    149149        { 
    150             msg_Dbg( p_this, "socket error: %s", strerror( net_errno ) ); 
     150            msg_Dbg( p_this, "socket error: %m" ); 
    151151            continue; 
    152152        } 
     
    160160            if( net_errno != EINPROGRESS ) 
    161161            { 
    162                 msg_Err( p_this, "connection failed: %s", 
    163                          strerror( net_errno ) ); 
     162                msg_Err( p_this, "connection failed: %m" ); 
    164163                goto next_ai; 
    165164            } 
     
    200199                if( ( i_ret == -1 ) && ( net_errno != EINTR ) ) 
    201200                { 
    202                     msg_Err( p_this, "connection polling error: %s", 
    203                               strerror( net_errno ) ); 
     201                    msg_Err( p_this, "connection polling error: %m" ); 
    204202                    goto next_ai; 
    205203                } 
     
    218216                            &i_val_size ) == -1 || i_val != 0 ) 
    219217            { 
    220                 msg_Err( p_this, "connection failed: %s", 
    221                          net_strerror( i_val ) ); 
     218                msg_Err( p_this, "connection failed: %m" ); 
    222219                goto next_ai; 
    223220            } 
     
    289286                if (net_errno != EINTR) 
    290287                { 
    291                     msg_Err (p_this, "poll error: %s", 
    292                              net_strerror (net_errno)); 
     288                    msg_Err (p_this, "poll error: %m"); 
    293289                } 
    294290                return -1; 
     
    309305            if (fd == -1) 
    310306            { 
    311                 msg_Err (p_this, "accept failed (%s)", 
    312                          net_strerror (net_errno)); 
     307                msg_Err (p_this, "accept failed (%m)"); 
    313308                continue; 
    314309            } 
  • src/network/udp.c

    r96b7100 r4ff9961  
    125125        if (fd == -1) 
    126126        { 
    127             msg_Dbg (obj, "socket error: %s", net_strerror (net_errno)); 
     127            msg_Dbg (obj, "socket error: %m"); 
    128128            continue; 
    129129        } 
     
    158158        if (bind (fd, ptr->ai_addr, ptr->ai_addrlen)) 
    159159        { 
    160             msg_Err (obj, "socket bind error (%s)", net_strerror (net_errno)); 
     160            msg_Err (obj, "socket bind error (%m)"); 
    161161            net_Close (fd); 
    162162            continue; 
     
    205205 
    206206        default: 
    207             msg_Warn( p_this, "%s", strerror( EAFNOSUPPORT ) ); 
     207            errno = EAFNOSUPPORT; 
     208            msg_Warn( p_this, "%m" ); 
    208209            return VLC_EGENERIC; 
    209210    } 
     
    275276            return 0; 
    276277 
    277         msg_Err (p_this, "%s: %s", iface, net_strerror (net_errno)); 
     278        msg_Err (p_this, "%s: %m", iface); 
    278279    } 
    279280 
     
    293294                return 0; 
    294295 
    295             msg_Err (p_this, "%s: %s", addr, net_strerror (net_errno)); 
     296            msg_Err (p_this, "%s: %m", addr); 
    296297        } 
    297298    } 
     
    363364#endif 
    364365 
    365     msg_Err (obj, "cannot join IPv4 multicast group (%s)", 
    366              net_strerror (net_errno)); 
     366    msg_Err (obj, "cannot join IPv4 multicast group (%m)"); 
    367367    return -1; 
    368368} 
     
    386386#endif 
    387387 
    388     msg_Err (obj, "cannot join IPv6 any-source multicast group (%s)", 
    389              net_strerror (net_errno)); 
     388    msg_Err (obj, "cannot join IPv6 any-source multicast group (%m)"); 
    390389    return -1; 
    391390} 
     
    550549    } 
    551550 
    552     msg_Err (obj, "Multicast group join error (%s)", 
    553              net_strerror (net_errno)); 
     551    msg_Err (obj, "Multicast group join error (%m)"); 
    554552 
    555553    if (src != NULL) 
     
    688686        else 
    689687        { 
    690             msg_Warn( p_this, "%s port %d : %s", psz_host, i_port, 
    691                       strerror( errno ) ); 
     688            msg_Warn( p_this, "%s port %d : %m", psz_host, i_port); 
    692689            net_Close( fd ); 
    693690            continue; 
     
    804801              : connect (fd, ptr2->ai_addr, ptr2->ai_addrlen)) 
    805802            { 
    806                 msg_Err (obj, "cannot connect to %s port %d: %s", 
    807                          psz_server, i_server, net_strerror (net_errno)); 
     803                msg_Err (obj, "cannot connect to %s port %d: %m", 
     804                         psz_server, i_server); 
    808805                continue; 
    809806            } 
  • src/stream_output/sap.c

    rd212179 r4ff9961  
    3131#include <stdlib.h>                                                /* free() */ 
    3232#include <stdio.h>                                              /* sprintf() */ 
    33 #include <string.h>                                            /* strerror() */ 
     33#include <string.h> 
    3434#include <ctype.h>                                  /* tolower(), isxdigit() */ 
    3535 
  • src/stream_output/stream_output.c

    r7dd2f15 r4ff9961  
    3232#include <stdlib.h>                                                /* free() */ 
    3333#include <stdio.h>                                              /* sprintf() */ 
    34 #include <string.h>                                            /* strerror() */ 
     34#include <string.h> 
    3535 
    3636#include <vlc_sout.h>