10

I'm getting warnings in Xcode after updating to the recommended pod settings. The warning is

Possible misuse of comma operator here

with a suggested fix of

Cast expression to void to silence warning

The warnings occur in leveldb-library/db/c.cc at the start and limit keys:

void leveldb_compact_range(
    leveldb_t* db,
    const char* start_key, size_t start_key_len,
    const char* limit_key, size_t limit_key_len) {
  Slice a, b;
  db->rep->CompactRange(
      // Pass NULL Slice if corresponding "const char*" is NULL
      (start_key ? (a = Slice(start_key, start_key_len), &a) : NULL),
      (limit_key ? (b = Slice(limit_key, limit_key_len), &b) : NULL));
}

Has anyone else had the same or know what's causing it? I'm running Cocoapods 1.2.0.

Shane O'Seasnain
  • 3,534
  • 5
  • 24
  • 31
  • If you want to disable this warning you can do it by [disabling the "Suspicious Commas" warning in your Build Settings](https://stackoverflow.com/a/37026478/111307) – bobobobo Dec 16 '20 at 22:11

3 Answers3

4

leveldb now builds without warnings after a pod update to version 1.20 of the leveldb-library CocoaPod.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
4

This solution works for me.

Code:

 if (++keyIndexValue == [self.str length])
    keyIndexValue = 0, keyPtr = keyData;

I've solved it by splitting the statements over multiple lines within the "if" condition:

"If at end of key data, reset count and set key pointer back to start of key value"

if (++keyIndexValue == [self.str length])
{
   keyIndexValue = 0;
   keyPtr = keyData;
}
Gajendra K Chauhan
  • 3,387
  • 7
  • 40
  • 55
  • It seems this is what Apple wanted, but I have to say they shouldn't force us to add { squiggly brackets } around an if-block where we knew what we were doing – bobobobo Dec 16 '20 at 21:52
  • The other way to do it (which looks really messy) would be to cast the left operand to `operator,` to void, like this: `(void)(keyIndexValue = 0), keyPtr = keyData;` – bobobobo Dec 16 '20 at 21:59
1

We are aware of the warning, we'll update the version once the leveldb fixes the issue. For now you can ignore the warnings.

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36