Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit convert UINT64_MAX to unsigned #217

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Conversation

jianminzhao
Copy link
Contributor

In Jenkins' build machine (MacOS), we found it failed to convert UINT64_MAX to unsigned with @() after we upgraded MACOSX_DEVELOPMENT_TARGET to 12 from 10.14.

A test is falied because of it. Fix it by explicit cast.

…64_MAX to unsigned with @() after we upgraded MACOSX_DEVELOPMENT_TARGET to 12 from 10.14.

A test is falied because of it. Fix it by explict cast.
@jianminzhao jianminzhao requested review from pasin and snej April 8, 2024 22:27
@@ -62,7 +62,10 @@ static void checkIt(id obj, const char* json) {
checkIt(@123456789, "123456789");
checkIt(@123456789012, "123456789012");
checkIt(@(INT64_MAX), "9223372036854775807");
checkIt(@(UINT64_MAX), "18446744073709551615");
// checkIt(@(UINT64_MAX), "18446744073709551615");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay. I was waving between whether to remove it.

@jianminzhao jianminzhao merged commit adec5e3 into release/3.2 Apr 8, 2024
3 checks passed
@jianminzhao jianminzhao deleted the cast-unsigned branch April 8, 2024 23:11
checkIt(@(UINT64_MAX), "18446744073709551615");
// It was found that @() may not turn UINT64_MAX to unsigned. In the following,
// we apply an explicit conversion
checkIt(@([@UINT64_MAX unsignedLongLongValue]), "18446744073709551615");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unnecessarily convoluted. You create an NSNumber, turn it back into a native number, then create another NSNumber from that.
It would be much simpler to write [NSNumber numberWithUnsignedLongLong: UINT64_MAX].
Or else @((unsigned long long)UINT64_MAX)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the advice. This is test code and won't be in the product. I will change when ported the the master branch.

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.

None yet

3 participants