Skip to content

Build fixes for clang 18.1.8#359

Open
berolinux wants to merge 1 commit intoAlinto:masterfrom
berolinux:fixes/5.11.0-build
Open

Build fixes for clang 18.1.8#359
berolinux wants to merge 1 commit intoAlinto:masterfrom
berolinux:fixes/5.11.0-build

Conversation

@berolinux
Copy link
Copy Markdown

Fix various type differences (BOOL vs. BOOL* etc.) that cause compile failures with clang 18.1.8

https://bugs.sogo.nu/view.php?id=5997

Fix various type differences (BOOL vs. BOOL* etc.) that cause
compile failures with clang 18.1.8
@QHivert QHivert self-requested a review August 14, 2024 13:18
}

[ud setObject: [NSNumber numberWithUnsignedLongLong: [up getCDefaultsSize]] forKey: @"CDefaultsSize"]; // Add c_defaults field size
[ud setObject: [NSNumber numberWithUnsignedLongLong: (unsigned long long)[up getCDefaultsSize]] forKey: @"CDefaultsSize"]; // Add c_defaults field size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this cause a build falied? as this method is already defined as
- (unsigned long long)getCDefaultsSize;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, I get

 Compiling file SOGoUserDefaults.m ...
SOGoUserDefaults.m:92:60: warning: instance method '-getCDefaultsSize' not found (return type defaults to 'id') [-Wobjc-method-access]
   92 |   [ud setObject: [NSNumber numberWithUnsignedLongLong: [up getCDefaultsSize]] forKey: @"CDefaultsSize"]; // Add c_defaults field size
      |                                                            ^~~~~~~~~~~~~~~~
./SOGoUserProfile.h:44:12: note: receiver is instance of class declared here
   44 | @interface SOGoUserProfile : NSObject
      |            ^
SOGoUserDefaults.m:92:56: error: incompatible pointer to integer conversion sending 'id' to parameter of type 'unsigned long long' [-Wint-conversion]
   92 |   [ud setObject: [NSNumber numberWithUnsignedLongLong: [up getCDefaultsSize]] forKey: @"CDefaultsSize"]; // Add c_defaults field size
      |                                                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/Foundation/NSValue.h:205:63: note: passing argument to parameter 'value' here
  205 | + (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value;
      |                                                               ^
1 warning and 1 error generated.

Copy link
Copy Markdown
Contributor

@QHivert QHivert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check that the two modifs in comments indeed cause a build failure?

}

static NSInteger _compareFetchResultsByUID (id entry1, id entry2, NSDictionary *uids)
static NSComparisonResult _compareFetchResultsByUID (id entry1, id entry2, void *uidsp)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure to understand the utility the void* then the NSDictionnary* casting? Can you check again if this causes a fail?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this:

SOGoMailFolder.m:233:52: error: incompatible function pointer types sending 'NSInteger (id, id, NSDictionary *)' (aka 'long (id, id, NSDictionary *)') to parameter of type 'NSComparisonResult (*)(id, id, void *)' (aka 'enum NSComparisonResult (*)(id, id, void *)') [-Wincompatible-function-pointer-types]
  233 |   result = [fetchResults sortedArrayUsingFunction: _compareFetchResultsByUID
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/Foundation/NSArray.h:145:44: note: passing argument to parameter 'comparator' here
  145 |     (NSComparisonResult (*)(id, id, void*))comparator
      |                                            ^

@QHivert
Copy link
Copy Markdown
Contributor

QHivert commented Aug 21, 2024

@berolinux Hello, I've actually need to push the corrections on the (BOOL *) -> (BOOL). Could you make the adjustements on your PR? Or I can make a commit myself and credit you if you don't have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants