Skip to content

Commit f699213

Browse files
committed
mostly address review comments; one more fix coming.
1 parent 445d2fa commit f699213

File tree

7 files changed

+35
-28
lines changed

7 files changed

+35
-28
lines changed

src/data.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ static void
129129
_dispatch_data_destroy_buffer(const void* buffer, size_t size,
130130
dispatch_queue_t queue, dispatch_block_t destructor)
131131
{
132-
#if !HAVE_MACH
133-
(void)size;
134-
#endif
135132
if (destructor == DISPATCH_DATA_DESTRUCTOR_FREE) {
136133
free((void*)buffer);
137134
} else if (destructor == DISPATCH_DATA_DESTRUCTOR_NONE) {
@@ -141,6 +138,8 @@ _dispatch_data_destroy_buffer(const void* buffer, size_t size,
141138
mach_vm_size_t vm_size = size;
142139
mach_vm_address_t vm_addr = (uintptr_t)buffer;
143140
mach_vm_deallocate(mach_task_self(), vm_addr, vm_size);
141+
#else
142+
(void)size;
144143
#endif
145144
} else {
146145
if (!queue) {

src/event/event_epoll.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,29 +85,29 @@ static struct dispatch_epoll_timeout_s _dispatch_epoll_timeout[] = {
8585

8686
DISPATCH_ALWAYS_INLINE
8787
static inline struct dispatch_muxnote_bucket_s *
88-
_dispatch_muxnote_bucket(int ident)
88+
_dispatch_muxnote_bucket(uint32_t ident)
8989
{
90-
return &_dispatch_sources[DSL_HASH((uint32_t)ident)];
90+
return &_dispatch_sources[DSL_HASH(ident)];
9191
}
9292
#define _dispatch_unote_muxnote_bucket(du) \
93-
_dispatch_muxnote_bucket((int)du._du->du_ident)
93+
_dispatch_muxnote_bucket(du._du->du_ident)
9494

9595
DISPATCH_ALWAYS_INLINE
9696
static inline dispatch_muxnote_t
9797
_dispatch_muxnote_find(struct dispatch_muxnote_bucket_s *dmb,
98-
int ident, int16_t filter)
98+
uint32_t ident, int16_t filter)
9999
{
100100
dispatch_muxnote_t dmn;
101101
if (filter == EVFILT_WRITE) filter = EVFILT_READ;
102102
TAILQ_FOREACH(dmn, dmb, dmn_list) {
103-
if (dmn->dmn_ident == ident && dmn->dmn_filter == filter) {
103+
if (dmn->dmn_ident == (int)ident && dmn->dmn_filter == filter) {
104104
break;
105105
}
106106
}
107107
return dmn;
108108
}
109109
#define _dispatch_unote_muxnote_find(dmb, du) \
110-
_dispatch_muxnote_find(dmb, (int)du._du->du_ident, du._du->du_filter)
110+
_dispatch_muxnote_find(dmb, du._du->du_ident, du._du->du_filter)
111111

112112
static void
113113
_dispatch_muxnote_dispose(dispatch_muxnote_t dmn)
@@ -148,11 +148,12 @@ _dispatch_muxnote_create(dispatch_unote_t du, uint32_t events)
148148
sigset_t sigmask;
149149

150150
switch (filter) {
151-
case EVFILT_SIGNAL:
152-
if (!sigismember(&signals_with_unotes, (int)du._du->du_ident)) {
151+
case EVFILT_SIGNAL: {
152+
int signo = (int)du._du->du_ident;
153+
if (!sigismember(&signals_with_unotes, signo)) {
153154
manager_thread = pthread_self();
154-
sigaddset(&signals_with_unotes, (int)du._du->du_ident);
155-
sigaction((int)du._du->du_ident, &sa, NULL);
155+
sigaddset(&signals_with_unotes, signo);
156+
sigaction(signo, &sa, NULL);
156157
}
157158
sigemptyset(&sigmask);
158159
sigaddset(&sigmask, (int)du._du->du_ident);
@@ -161,7 +162,7 @@ _dispatch_muxnote_create(dispatch_unote_t du, uint32_t events)
161162
return NULL;
162163
}
163164
break;
164-
165+
}
165166
case EVFILT_WRITE:
166167
filter = EVFILT_READ;
167168
case EVFILT_READ:
@@ -350,7 +351,8 @@ _dispatch_event_merge_timer(dispatch_clock_t clock)
350351
}
351352

352353
static void
353-
_dispatch_timeout_program(uint32_t tidx, uint64_t target, DISPATCH_UNUSED uint64_t leeway)
354+
_dispatch_timeout_program(uint32_t tidx, uint64_t target,
355+
DISPATCH_UNUSED uint64_t leeway)
354356
{
355357
dispatch_clock_t clock = DISPATCH_TIMER_CLOCK(tidx);
356358
dispatch_epoll_timeout_t timer = &_dispatch_epoll_timeout[clock];

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,13 @@ _dispatch_bug(size_t line, long val)
614614
_dispatch_build, (unsigned long)line, val);
615615
}
616616

617-
#if HAVE_MACH
618617
void
619618
_dispatch_bug_client(const char* msg)
620619
{
621620
_dispatch_bug_log("BUG in libdispatch client: %s", msg);
622621
}
623622

623+
#if HAVE_MACH
624624
void
625625
_dispatch_bug_mach_client(const char* msg, mach_msg_return_t kr)
626626
{

src/internal.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
394394
DISPATCH_EXPORT DISPATCH_NOINLINE
395395
void _dispatch_bug(size_t line, long val);
396396

397-
#if HAVE_MACH
398397
DISPATCH_NOINLINE
399398
void _dispatch_bug_client(const char* msg);
399+
#if HAVE_MACH
400400
DISPATCH_NOINLINE
401401
void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
402402
#endif // HAVE_MACH
@@ -466,7 +466,9 @@ void _dispatch_log(const char *msg, ...);
466466
} \
467467
} while (0)
468468
#else
469-
static inline void _dispatch_assert(long e, size_t line) {
469+
static inline void
470+
_dispatch_assert(long e, size_t line)
471+
{
470472
if (DISPATCH_DEBUG && !e) _dispatch_abort(line, e);
471473
}
472474
#define dispatch_assert(e) _dispatch_assert((long)(e), __LINE__)
@@ -488,7 +490,9 @@ static inline void _dispatch_assert(long e, size_t line) {
488490
} \
489491
} while (0)
490492
#else
491-
static inline void _dispatch_assert_zero(long e, size_t line) {
493+
static inline void
494+
_dispatch_assert_zero(long e, size_t line)
495+
{
492496
if (DISPATCH_DEBUG && e) _dispatch_abort(line, e);
493497
}
494498
#define dispatch_assert_zero(e) _dispatch_assert_zero((long)(e), __LINE__)
@@ -512,7 +516,9 @@ static inline void _dispatch_assert_zero(long e, size_t line) {
512516
_e; \
513517
})
514518
#else
515-
static inline long _dispatch_assume(long e, long line) {
519+
static inline long
520+
_dispatch_assume(long e, long line)
521+
{
516522
if (!e) _dispatch_bug(line, e);
517523
return e;
518524
}
@@ -535,7 +541,9 @@ static inline long _dispatch_assume(long e, long line) {
535541
_e; \
536542
})
537543
#else
538-
static inline long _dispatch_assume_zero(long e, long line) {
544+
static inline long
545+
_dispatch_assume_zero(long e, long line)
546+
{
539547
if (e) _dispatch_bug(line, e);
540548
return e;
541549
}
@@ -850,7 +858,7 @@ _dispatch_ktrace_impl(uint32_t code, uint64_t a, uint64_t b,
850858
#define _dispatch_hardware_crash() \
851859
__asm__(""); __builtin_trap() // <rdar://problem/17464981>
852860

853-
#define _dispatch_set_crash_log_cause_and_message(ac, msg)
861+
#define _dispatch_set_crash_log_cause_and_message(ac, msg) ((void)(ac))
854862
#define _dispatch_set_crash_log_message(msg)
855863
#define _dispatch_set_crash_log_message_dynamic(msg)
856864

src/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
21672167
op->advise_offset += advise.ra_count;
21682168
#ifdef __linux__
21692169
_dispatch_io_syscall_switch(err,
2170-
readahead(op->fd_entry->fd, advise.ra_offset, (size_t)advise.ra_count),
2170+
readahead(op->fd_entry->fd, advise.ra_offset, (size_t)advise.ra_count),
21712171
case EINVAL: break; // fd does refer to a non-supported filetype
21722172
default: (void)dispatch_assume_zero(err); break;
21732173
);

src/queue.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5329,8 +5329,9 @@ _dispatch_root_queue_push(dispatch_queue_t rq, dispatch_object_t dou,
53295329
if (_dispatch_root_queue_push_needs_override(rq, qos)) {
53305330
return _dispatch_root_queue_push_override(rq, dou, qos);
53315331
}
5332-
#endif
5332+
#else
53335333
(void)qos;
5334+
#endif
53345335
_dispatch_root_queue_push_inline(rq, dou, dou, 1);
53355336
}
53365337

@@ -6221,7 +6222,6 @@ DISPATCH_NORETURN
62216222
static void
62226223
_dispatch_deferred_items_cleanup(void *ctxt)
62236224
{
6224-
(void)ctxt;
62256225
// POSIX defines that destructors are only called if 'ctxt' is non-null
62266226
DISPATCH_INTERNAL_CRASH(ctxt,
62276227
"Premature thread exit with unhandled deferred items");
@@ -6231,7 +6231,6 @@ DISPATCH_NORETURN
62316231
static void
62326232
_dispatch_frame_cleanup(void *ctxt)
62336233
{
6234-
(void)ctxt;
62356234
// POSIX defines that destructors are only called if 'ctxt' is non-null
62366235
DISPATCH_INTERNAL_CRASH(ctxt,
62376236
"Premature thread exit while a dispatch frame is active");
@@ -6241,7 +6240,6 @@ DISPATCH_NORETURN
62416240
static void
62426241
_dispatch_context_cleanup(void *ctxt)
62436242
{
6244-
(void)ctxt;
62456243
// POSIX defines that destructors are only called if 'ctxt' is non-null
62466244
DISPATCH_INTERNAL_CRASH(ctxt,
62476245
"Premature thread exit while a dispatch context is set");

src/voucher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ _voucher_create_accounting_voucher(voucher_t voucher)
15501550
return NULL;
15511551
}
15521552

1553-
#if __has_include(<mach/mach.h>)
1553+
#if HAVE_MACH
15541554
voucher_t
15551555
voucher_create_with_mach_msg(mach_msg_header_t *msg)
15561556
{

0 commit comments

Comments
 (0)