-
Notifications
You must be signed in to change notification settings - Fork 471
fixes to src to prep for enabling additional compiler warnings #273
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
Conversation
happy to adjust based on feedback. I've mainly gone with local fixes/casts to resolve the warnings and tried to avoid changing very much cross-platform code. This might not always have been the right thing to do... |
2cd7124
to
e6030f1
Compare
src/event/event_epoll.c
Outdated
@@ -89,12 +89,12 @@ _dispatch_muxnote_bucket(int ident) | |||
return &_dispatch_sources[DSL_HASH((uint32_t)ident)]; | |||
} | |||
#define _dispatch_unote_muxnote_bucket(du) \ | |||
_dispatch_muxnote_bucket(du._du->du_ident) | |||
_dispatch_muxnote_bucket((int)du._du->du_ident) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think _dispatch_muxnote_bucket() argument type should take a uint32_t instead.
src/event/event_epoll.c
Outdated
|
||
DISPATCH_ALWAYS_INLINE | ||
static inline dispatch_muxnote_t | ||
_dispatch_muxnote_find(struct dispatch_muxnote_bucket_s *dmb, | ||
uint64_t ident, int16_t filter) | ||
int ident, int16_t filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int
seems the wrong type since it forces a cast at the call site, why int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a cast somewhere on this call path because dmn_ident is an int (makes since since file descriptors are ints), but du_ident is an uint32_t.
I can push the cast down to the == compare instead of bubbling it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my worry is that signed stuff for a hash table is a bad idea. Moving to uint32_t
would be fine fWIW. and the reason for uint32_t
for du_ident
is because it's unsigned on Darwin because of kevent and it'll be hell if we change signedness of this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I changed dmn_ident to be a uint32_t for the epoll backend.
src/event/event_epoll.c
Outdated
int16_t filter = du._du->du_filter; | ||
bool socket_listener = false; | ||
sigset_t sigmask; | ||
|
||
switch (filter) { | ||
case EVFILT_SIGNAL: | ||
if (!sigismember(&signals_with_unotes, du._du->du_ident)) { | ||
if (!sigismember(&signals_with_unotes, (int)du._du->du_ident)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would take a temporary int signo = (int)du._du->du_ident
which would make it clearer in the first place and avoid that many ugly casts
src/event/event_epoll.c
Outdated
@@ -343,32 +343,32 @@ _dispatch_event_merge_timer(dispatch_clock_t clock) | |||
} | |||
|
|||
static void | |||
_dispatch_timeout_program(uint32_t tidx, uint64_t target, uint64_t leeway) | |||
_dispatch_timeout_program(uint32_t tidx, uint64_t target, DISPATCH_UNUSED uint64_t leeway) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
80 columns (?) you need to wrap
src/init.c
Outdated
@@ -614,13 +614,13 @@ _dispatch_bug(size_t line, long val) | |||
_dispatch_build, (unsigned long)line, val); | |||
} | |||
|
|||
#if HAVE_MACH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems wrong, are you sure it's never used on linux ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the prototype in internal.h is already guarded this way, but agree that that seems wrong. This is currently only used in event_kevent.c (so could be guarded by DISPATCH_EVENT_BACKEND_KEVENT) but it is really intended to be a generic facility that can be used anywhere, so the better fix is probably to remove the ifdef of the prototype in internal.h
src/internal.h
Outdated
@@ -466,7 +466,7 @@ void _dispatch_log(const char *msg, ...); | |||
} \ | |||
} while (0) | |||
#else | |||
static inline void _dispatch_assert(long e, long line) { | |||
static inline void _dispatch_assert(long e, size_t line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the style while at it, it's unlike the rest of dispatch, it should be:
static inline void
_dispatch_assert(long e, size_t line)
{
thanks
src/internal.h
Outdated
@@ -488,7 +488,7 @@ static inline void _dispatch_assert(long e, long line) { | |||
} \ | |||
} while (0) | |||
#else | |||
static inline void _dispatch_assert_zero(long e, long line) { | |||
static inline void _dispatch_assert_zero(long e, size_t line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/io.c
Outdated
@@ -2167,7 +2167,7 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size) | |||
op->advise_offset += advise.ra_count; | |||
#ifdef __linux__ | |||
_dispatch_io_syscall_switch(err, | |||
readahead(op->fd_entry->fd, advise.ra_offset, advise.ra_count), | |||
readahead(op->fd_entry->fd, advise.ra_offset, (size_t)advise.ra_count), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that indent seems wrong :)
src/queue.c
Outdated
@@ -5330,6 +5330,7 @@ _dispatch_root_queue_push(dispatch_queue_t rq, dispatch_object_t dou, | |||
return _dispatch_root_queue_push_override(rq, dou, qos); | |||
} | |||
#endif | |||
(void)qos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please inside a #else
instead
src/queue.c
Outdated
@@ -6218,6 +6221,7 @@ DISPATCH_NORETURN | |||
static void | |||
_dispatch_deferred_items_cleanup(void *ctxt) | |||
{ | |||
(void)ctxt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think DISPATCH_INTERNAL_CRASH
should ((void)(ac)) instead to avoid this
src/voucher.c
Outdated
@@ -1550,12 +1550,14 @@ _voucher_create_accounting_voucher(voucher_t voucher) | |||
return NULL; | |||
} | |||
|
|||
#if __has_include(<mach/mach.h>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be HAVE_MACH, that matches the guards of this type
src/data.c
Outdated
@@ -129,6 +129,9 @@ static void | |||
_dispatch_data_destroy_buffer(const void* buffer, size_t size, | |||
dispatch_queue_t queue, dispatch_block_t destructor) | |||
{ | |||
#if !HAVE_MACH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nicer as an #else to the #if HAVE_MACH below
src/init.c
Outdated
@@ -614,13 +614,13 @@ _dispatch_bug(size_t line, long val) | |||
_dispatch_build, (unsigned long)line, val); | |||
} | |||
|
|||
#if HAVE_MACH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the prototype in internal.h is already guarded this way, but agree that that seems wrong. This is currently only used in event_kevent.c (so could be guarded by DISPATCH_EVENT_BACKEND_KEVENT) but it is really intended to be a generic facility that can be used anywhere, so the better fix is probably to remove the ifdef of the prototype in internal.h
Thanks for the comments; I will revise/rebase and let you know when it is ready for second review (was out on vacation last week...) |
9d64682
to
6a3f928
Compare
updated to address comments, rebased to tip of master, & squashed. Ready for you to look at again. |
src/event/event_epoll.c
Outdated
} | ||
sigemptyset(&sigmask); | ||
sigaddset(&sigmask, du._du->du_ident); | ||
sigaddset(&sigmask, (int)du._du->du_ident); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signo ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, missed that one. fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
work in progress on cleaning up code so it can be compiled with the same set of warning flags used on Darwin. This is an initial pass through the C files in src to resolve warnings. Most warnings are related to implicit size/sign conversions between integral types and missing explicit prototypes for non-static functions.
6a3f928
to
03cd694
Compare
@swift-ci please test |
fixes to src to prep for enabling additional compiler warnings Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
work in progress on cleaning up code so it can be compiled
with the same set of warning flags used on Darwin. This is an inital
pass through the C files in src to resolve warnings. Most warnings
are related to implicit size/sign conversions between integral types.