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

cl_mode_user_to_kernel returns unsigned enum, cannot be negative

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • Lustre 2.17.0
    • Lustre 2.17.0
    • None
    • 3
    • 9223372036854775807

    Description

      cl_mode_user_to_kernel() function is declared as returning an enum which is an unsigned integer type, as such returning negative values is bad:

      static enum cl_lock_mode cl_mode_user_to_kernel(enum lock_mode_user mode)
      {
              switch (mode) {
              case MODE_READ_USER:
                      return CLM_READ;
              case MODE_WRITE_USER:
                      return CLM_WRITE;
              default:
                      return -EINVAL;
              }
      }
      

      Further checks like this would be always false too:

              enum cl_lock_mode cl_mode;
      
              cl_mode = cl_mode_user_to_kernel(ladvise->lla_lockahead_mode);
              if (cl_mode < 0)
                      GOTO(out, result = cl_mode);
      

      Introduced in https://review.whamcloud.com/13564

      Attachments

        Issue Links

          Activity

            People

              wc-triage WC Triage
              green Oleg Drokin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: