Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-16123

checkpatch: comparisons with a constant or upper case identifier on the left

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Trivial
    • Lustre 2.16.0
    • None
    • None
    • Master
    • 9223372036854775807

    Description

      checkpatch trows a warning if it finds an "UPPERCASE" on the left and side.  According to the script/code it is to avoid cases like "foo + BAR < baz".

      However for our case  "#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)" this warning is false positive.

      This could be recreated as:

       

      /* Fake values. For demo purpose */
      #define SUM(a, b) (a + b)                                                       
      #define LUSTRE_VERSION_CODE 50                                                  
      #define lustre_version_code 50                                                  
      /* This case passes */                                                                               
      #if lustre_verison_code < SUM(10, 4)                                            
      int x;                                                                          
      #endif                                                                          
                                                                                    
      /* This case passes */    
        
      #if SUM(10, 4) < lustre_verison_code                                            
      int x1;                                                                         
      #endif                                                                          
                                                                                    
      /* This case passes */    
        
      #if SUM(10, 4) < LUSTRE_VERSION_CODE                                            
      int x2;                                                                         
      #endif                                                                          
                                                                                    
      /* This case FAILS. Proposed patch to fix this case */    
        
      #if LUSTRE_VERSION_CODE < SUM(10, 4)                                            
      int x3;                                                                         
      #endif             
      

       

      Attachments

        Activity

          People

            arshad512 Arshad Hussain
            arshad512 Arshad Hussain
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: