Add new comment

Use of AND operators in dcraw_common.cpp

Dear all,

When compiling LibRaw on OS X 10.7.3 (as part of compiling Darktable, actually) Clang gives me a few warnings about AND-ing actions in dcraw_common.cpp. I have pasted them below. They all look valid to me and would probably benefit from doing what the compiler suggests. Can someone please verify and fix this? Or is there another path I should follow to do this?

/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:827:28: warning: & has lower precedence than >=; >= will be evaluated
      first [-Wparentheses]
          if(offset[slice] & 0x0fffffff >= raw_width * raw_height)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:827:28: note: place parentheses around the >= expression to silence
      this warning
          if(offset[slice] & 0x0fffffff >= raw_width * raw_height)
                           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:827:28: note: place parentheses around the & expression to evaluate
      it first
          if(offset[slice] & 0x0fffffff >= raw_width * raw_height)
                           ^
             (                         )
/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:7589:30: warning: use of logical '&&' with constant operand
      [-Wconstant-logical-operand]
      is_raw += (i = get4()) && 1;
                             ^  ~
/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:7589:30: note: use '&' for a bitwise operation
      is_raw += (i = get4()) && 1;
                             ^~
                             &
/Users/jhegeman/tmp_darktable/darktable/src/external/LibRaw/internal/dcraw_common.cpp:7589:30: note: remove constant to silence this warning
      is_raw += (i = get4()) && 1;
                             ^~~~

Best regards,
Jeroen

Forums: