swiftlang / swift-corelibs-libdispatch

The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware
swift.org
Apache License 2.0
2.47k stars 460 forks source link

Fix a number of warnings when building on Windows #758

Closed grynspan closed 2 years ago

grynspan commented 2 years ago

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 commented 2 years ago

@swift-ci please test

grynspan commented 2 years ago

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 commented 2 years ago

@swift-ci please test

grynspan commented 2 years ago

@swift-ci please test