Ticket #3430: mc-indroduct-wundef-check-02_v2.patch

File mc-indroduct-wundef-check-02_v2.patch, 3.1 KB (added by and, 9 years ago)

v2 of patch 02: respect macro logic

  • lib/fs.h

    introduce -Wundef check to catch macro typos
    more infos about motivation at https://sourceware.org/glibc/wiki/Wundef
    
    patch 02/04: replace with existing helper macros
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    
    a b  
    1414 
    1515/*** typedefs(not structures) and defined constants **********************************************/ 
    1616 
     17#ifdef S_ISREG 
     18#define HAVE_S_ISREG 1 
     19#else 
     20#define HAVE_S_ISREG 0 
     21#define S_ISREG(x) 0 
     22#endif 
     23 
     24#ifdef S_ISDIR 
     25#define HAVE_S_ISDIR 1 
     26#else 
     27#define HAVE_S_ISDIR 0 
     28#define S_ISDIR(x) 0 
     29#endif 
     30 
    1731/* Replacement for permission bits missing in sys/stat.h */ 
    18 #ifndef S_ISLNK 
     32#ifdef S_ISLNK 
     33#define HAVE_S_ISLNK 1 
     34#else 
     35#define HAVE_S_ISLNK 0 
    1936#define S_ISLNK(x) 0 
    2037#endif 
    2138 
    22 #ifndef S_ISSOCK 
     39#ifdef S_ISSOCK 
     40#define HAVE_S_ISSOCK 1 
     41#else 
     42#define HAVE_S_ISSOCK 0 
    2343#define S_ISSOCK(x) 0 
    2444#endif 
    2545 
    26 #ifndef S_ISFIFO 
     46#ifdef S_ISFIFO 
     47#define HAVE_S_ISFIFO 1 
     48#else 
     49#define HAVE_S_ISFIFO 0 
    2750#define S_ISFIFO(x) 0 
    2851#endif 
    2952 
    30 #ifndef S_ISCHR 
     53#ifdef S_ISCHR 
     54#define HAVE_S_ISCHR 1 
     55#else 
     56#define HAVE_S_ISCHR 0 
    3157#define S_ISCHR(x) 0 
    3258#endif 
    3359 
    34 #ifndef S_ISBLK 
     60#ifdef S_ISBLK 
     61#define HAVE_S_ISBLK 1 
     62#else 
     63#define HAVE_S_ISBLK 0 
    3564#define S_ISBLK(x) 0 
    3665#endif 
    3766 
    3867/* Door is something that only exists on Solaris */ 
    39 #ifndef S_ISDOOR 
     68#ifdef S_ISDOOR 
     69#define HAVE_S_ISDOOR 1 
     70#else 
     71#define HAVE_S_ISDOOR 0 
    4072#define S_ISDOOR(x) 0 
    4173#endif 
    4274 
    4375/* Special named files are widely used in QNX6 */ 
    44 #ifndef S_ISNAM 
     76#ifdef S_ISNAM 
     77#define HAVE_S_ISNAM 1 
     78#else 
     79#define HAVE_S_ISNAM 0 
    4580#define S_ISNAM(x) 0 
    4681#endif 
    4782 
  • lib/filehighlight/get-color.c

    a b  
    4949inline static gboolean 
    5050mc_fhl_is_file (file_entry_t * fe) 
    5151{ 
    52 #if S_ISREG == 0 
     52#if HAVE_S_ISREG == 0 
    5353    (void) fe; 
    5454#endif 
    5555    return S_ISREG (fe->st.st_mode); 
     
    6464inline static gboolean 
    6565mc_fhl_is_dir (file_entry_t * fe) 
    6666{ 
    67 #if S_ISDIR == 0 
     67#if HAVE_S_ISDIR == 0 
    6868    (void) fe; 
    6969#endif 
    7070    return S_ISDIR (fe->st.st_mode); 
     
    7373inline static gboolean 
    7474mc_fhl_is_link (file_entry_t * fe) 
    7575{ 
    76 #if S_ISLNK == 0 
     76#if HAVE_S_ISLNK == 0 
    7777    (void) fe; 
    7878#endif 
    7979    return S_ISLNK (fe->st.st_mode); 
     
    100100inline static gboolean 
    101101mc_fhl_is_device_char (file_entry_t * fe) 
    102102{ 
    103 #if S_ISCHR == 0 
     103#if HAVE_S_ISCHR == 0 
    104104    (void) fe; 
    105105#endif 
    106106    return S_ISCHR (fe->st.st_mode); 
     
    109109inline static gboolean 
    110110mc_fhl_is_device_block (file_entry_t * fe) 
    111111{ 
    112 #if S_ISBLK == 0 
     112#if HAVE_S_ISBLK == 0 
    113113    (void) fe; 
    114114#endif 
    115115    return S_ISBLK (fe->st.st_mode); 
     
    118118inline static gboolean 
    119119mc_fhl_is_special_socket (file_entry_t * fe) 
    120120{ 
    121 #if S_ISSOCK == 0 
     121#if HAVE_S_ISSOCK == 0 
    122122    (void) fe; 
    123123#endif 
    124124    return S_ISSOCK (fe->st.st_mode); 
     
    127127inline static gboolean 
    128128mc_fhl_is_special_fifo (file_entry_t * fe) 
    129129{ 
    130 #if S_ISFIFO == 0 
     130#if HAVE_S_ISFIFO == 0 
    131131    (void) fe; 
    132132#endif 
    133133    return S_ISFIFO (fe->st.st_mode); 
     
    136136inline static gboolean 
    137137mc_fhl_is_special_door (file_entry_t * fe) 
    138138{ 
    139 #if S_ISDOOR == 0 
     139#if HAVE_S_ISDOOR == 0 
    140140    (void) fe; 
    141141#endif 
    142142