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

MSVC compatibility for vcpkg #266

Merged
merged 6 commits into from
Nov 29, 2024
Merged

Conversation

mrexodia
Copy link
Contributor

@mrexodia mrexodia commented Nov 28, 2024

Closes #76

…(rare)

This prevents a bug class where we bswap things when __LITTLE_ENDIAN__ is not defined.
Almost all modern systems are little endian, so detecting __BIG_ENDIAN__ is a better strategy.
@mrexodia mrexodia changed the title Vcpkg patches MSVC compatibility for vcpkg Nov 28, 2024
@@ -343,7 +389,7 @@ static char *plist_utf16be_to_utf8(uint16_t *unistr, long len, long *items_read,
}

while (i < len) {
wc = be16toh(get_unaligned(unistr + i));
wc = UINT_TO_HOST(unistr + i, sizeof(wc));
Copy link
Member

@nikias nikias Nov 28, 2024

Choose a reason for hiding this comment

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

Getting this:

bplist.c:392:18: warning: pointer type mismatch ('const char *' and 'uint16_t *' (aka 'unsigned short *')) [-Wpointer-type-mismatch]
                wc = (uint16_t)UINT_TO_HOST(unistr + i, sizeof(wc));
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bplist.c:190:24: note: expanded from macro 'UINT_TO_HOST'
                __up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (x); \
                                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~
1 warning generated.```

src/bplist.c Outdated
#define UINT_TO_HOST(x, n) \
({ \
union plist_uint_ptr __up; \
__up.src = ((n) > 8) ? (x) + ((n) - 8) : (x); \
__up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (x); \
Copy link
Member

Choose a reason for hiding this comment

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

See comment below. I think we need another cast, like this:

__up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (const char*)(x);

And maybe in the _MSC_VER variant too.

Copy link
Member

Choose a reason for hiding this comment

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

it does pass all checks though when I remove the cast you put there.

@nikias nikias merged commit 3d61170 into libimobiledevice:master Nov 29, 2024
3 checks passed
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