4

I use Google Drive SDK in my app.

It has worked perfectly since around June 2014.

Following update to Xcode 6.3, none of my targets build.

The implementation file GTMOAuth2ViewControllerTouch.m contains two blocks that the compiler complains about:

if (accessibility == NULL
    && &kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly != NULL) {
        accessibility = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
}

specifically with the message: "Comparison of address of kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly not equal to a null pointer is always true".

AND

if (accessibility != NULL && &kSecAttrAccessible != NULL) {
    [keychainQuery setObject:(id)accessibility
                      forKey:(id)kSecAttrAccessible];
}

specifically with the message: "Comparison of address of kSecAttrAccessible not equal to a null pointer is always true".

The compiler is telling me that the two keys when compared to != NULL is always true.

I believe my lack of computer science training leaves me unable to understand the issue here - maybe that is just a bad perception?

I've had a look at this question but cannot understand the context in relation to my problem with Google Drive SDK implementation file GTMOAuth2ViewControllerTouch.m

I'd really like to understand the underlying issue.

Please help...

Community
  • 1
  • 1
andrewbuilder
  • 3,629
  • 2
  • 24
  • 46

2 Answers2

7

Instead of those snippets, you can use: accessibility = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly; and [keychainQuery setObject:(id)accessibility forKey:(id)kSecAttrAccessible];

This is because the constants will never have a NULL pointer, so there is no reason to do checking. I believe an update to the SDK is available to fix but you can do it manually.

Schemetrical
  • 5,506
  • 2
  • 26
  • 43
  • Appreciate your prompt assistance @Schemetrical. All targets build with your suggested changes - thank you. Wish I had thought to check the Google SDK, but ended doing the changes manually as you've written. – andrewbuilder Apr 11 '15 at 05:45
  • Are you able to explain why this changed between Xcode 6.2 / iOS 8.2 & Xcode 6.3 / iOS 8.3? – andrewbuilder Apr 11 '15 at 05:45
  • 1
    I believe the code was there to check if the constant existed. In 6.3, Xcode now checks the iOS version you use and the static analyser will spew errors for unnecessary code (such as comparing something to nothing always false). – Schemetrical Apr 11 '15 at 06:26
0

Apple added a new check to their compiler that warn when these checks can never fail, but unfortunately, it does so based on the current deployment target. For those of us who share code between projects with multiple deployment targets, though, that new feature is a real headache.

I'm told that you can disable the warning globally by adding -Wno-tautological-pointer-compare to your compiler flags, or on a one-off basis by wrapping the "&whatever" in parentheses.

dgatwood
  • 10,129
  • 1
  • 28
  • 49