Skip to content

Fix a number of warnings when building on Windows #758

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

Merged
merged 2 commits into from
Jun 22, 2022

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented May 6, 2022

This PR fixes a number of warnings when building on Windows.

A common one involves the use of dispatch_assert() and related macros. Passing a pointer to these macros produces a narrowing conversion on Windows because long is 32 bits. This change uses intptr_t instead.

The following warnings are also resolved:

S:\SourceCache\swift-corelibs-libdispatch\src/shims/time.h(266,24): warning: comparison of integers of different signs: 'dispatch_time_t' (aka 'unsigned long long') and 'int' [-Wsign-compare]
                        actual_value = time == DISPATCH_WALLTIME_NOW ?
                                       ~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\init.c(1153,11): warning: comparison of integers of different signs: 'int' and 'unsigned long long' [-Wsign-compare]
                                len = MIN(len, sizeof(szMessage) - 1);
                                      ^   ~~~  ~~~~~~~~~~~~~~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\source.c(1405,4): warning: format specifies type 'unsigned int' but the argument has type 'dispatch_unote_ident_t' (aka 'unsigned long long') [-Wformat]
                        dr->du_ident, dr->du_fflags, (unsigned long long)dr->ds_pending_data,
                        ^~~~~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\queue.c(776,39): warning: cast to smaller integer type 'dispatch_invoke_flags_t' from 'void *' [-Wvoid-pointer-to-enum-cast]
        dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)dc->dc_ctxt;
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\queue.c(7019,1): warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
}
^
                                            ^~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\event\event.c(801,2): warning: format specifies type 'unsigned int' but the argument has type 'dispatch_unote_ident_t' (aka 'unsigned long long') [-Wformat]
        _dispatch_timer_du_debug("disarmed", dt);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
S:\SourceCache\swift-corelibs-libdispatch\src\event\workqueue.c(229,59): warning: format specifies type 'unsigned int' but the argument has type 'dispatch_tid' (aka 'unsigned long') [-Wformat]
                        _dispatch_debug("workq: unable to open thread %u: %u", tid, GetLastError());
                                                                      ~~       ^~~
                                                                      %lu

@grynspan grynspan requested review from compnerd, lorentey and rokhinip May 6, 2022 04:02
@grynspan
Copy link
Contributor Author

grynspan commented May 6, 2022

@swift-ci please test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

LGTM from the Windows side. Would be nice to get @rokhinip's eyes on this as well (for Darwin).

@grynspan
Copy link
Contributor Author

grynspan commented May 6, 2022

This all builds locally on Windows but it doesn't appear that @swift-ci knows how to kick off a Windows build to verify.

@grynspan
Copy link
Contributor Author

grynspan commented May 6, 2022

@swift-ci please test

@grynspan grynspan requested a review from rokhinip May 6, 2022 14:04
@grynspan
Copy link
Contributor Author

grynspan commented May 6, 2022

@swift-ci please test

@lorentey lorentey requested a review from millenomi June 10, 2022 18:04
@millenomi millenomi merged commit 4bf826d into swiftlang:main Jun 22, 2022
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.

4 participants