Skip to content

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

Merged
merged 1 commit into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/BlocksRuntime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ GC support stub routines


static void *_Block_alloc_default(const unsigned long size, const bool initialCountIsOne, const bool isObject) {
(void)initialCountIsOne;
(void)isObject;
return malloc(size);
}

Expand All @@ -156,16 +158,20 @@ static void _Block_assign_default(void *value, void **destptr) {
}

static void _Block_setHasRefcount_default(const void *ptr, const bool hasRefcount) {
(void)ptr;
(void)hasRefcount;
}

#if HAVE_OBJC
static void _Block_do_nothing(const void *aBlock) { }
#endif

static void _Block_retain_object_default(const void *ptr) {
(void)ptr;
}

static void _Block_release_object_default(const void *ptr) {
(void)ptr;
}

static void _Block_assign_weak_default(const void *ptr, void *dest) {
Expand Down Expand Up @@ -193,7 +199,9 @@ static void _Block_memmove_gc_broken(void *dest, void *src, unsigned long size)
}
#endif

static void _Block_destructInstance_default(const void *aBlock) {}
static void _Block_destructInstance_default(const void *aBlock) {
(void)aBlock;
}

/**************************************************************************
GC support callout functions - initially set to stub routines
Expand Down
2 changes: 2 additions & 0 deletions src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ _dispatch_data_destroy_buffer(const void* buffer, size_t size,
mach_vm_size_t vm_size = size;
mach_vm_address_t vm_addr = (uintptr_t)buffer;
mach_vm_deallocate(mach_task_self(), vm_addr, vm_size);
#else
(void)size;
#endif
} else {
if (!queue) {
Expand Down
48 changes: 25 additions & 23 deletions src/event/event_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef struct dispatch_muxnote_s {
TAILQ_HEAD(, dispatch_unote_linkage_s) dmn_readers_head;
TAILQ_HEAD(, dispatch_unote_linkage_s) dmn_writers_head;
int dmn_fd;
int dmn_ident;
uint32_t dmn_ident;
uint32_t dmn_events;
int16_t dmn_filter;
bool dmn_skip_outq_ioctl;
Expand Down Expand Up @@ -85,17 +85,17 @@ static struct dispatch_epoll_timeout_s _dispatch_epoll_timeout[] = {

DISPATCH_ALWAYS_INLINE
static inline struct dispatch_muxnote_bucket_s *
_dispatch_muxnote_bucket(int ident)
_dispatch_muxnote_bucket(uint32_t ident)
{
return &_dispatch_sources[DSL_HASH((uint32_t)ident)];
return &_dispatch_sources[DSL_HASH(ident)];
}
#define _dispatch_unote_muxnote_bucket(du) \
_dispatch_muxnote_bucket(du._du->du_ident)

DISPATCH_ALWAYS_INLINE
static inline dispatch_muxnote_t
_dispatch_muxnote_find(struct dispatch_muxnote_bucket_s *dmb,
uint64_t ident, int16_t filter)
uint32_t ident, int16_t filter)
{
dispatch_muxnote_t dmn;
if (filter == EVFILT_WRITE) filter = EVFILT_READ;
Expand All @@ -112,7 +112,7 @@ _dispatch_muxnote_find(struct dispatch_muxnote_bucket_s *dmb,
static void
_dispatch_muxnote_dispose(dispatch_muxnote_t dmn)
{
if (dmn->dmn_filter != EVFILT_READ || dmn->dmn_fd != dmn->dmn_ident) {
if (dmn->dmn_filter != EVFILT_READ || (uint32_t)dmn->dmn_fd != dmn->dmn_ident) {
close(dmn->dmn_fd);
}
free(dmn);
Expand Down Expand Up @@ -142,26 +142,27 @@ _dispatch_muxnote_create(dispatch_unote_t du, uint32_t events)

dispatch_muxnote_t dmn;
struct stat sb;
int fd = du._du->du_ident;
int fd = (int)du._du->du_ident;
int16_t filter = du._du->du_filter;
bool skip_outq_ioctl = false, skip_inq_ioctl = false;
sigset_t sigmask;

switch (filter) {
case EVFILT_SIGNAL:
if (!sigismember(&signals_with_unotes, du._du->du_ident)) {
case EVFILT_SIGNAL: {
int signo = (int)du._du->du_ident;
if (!sigismember(&signals_with_unotes, signo)) {
manager_thread = pthread_self();
sigaddset(&signals_with_unotes, du._du->du_ident);
sigaction(du._du->du_ident, &sa, NULL);
sigaddset(&signals_with_unotes, signo);
sigaction(signo, &sa, NULL);
}
sigemptyset(&sigmask);
sigaddset(&sigmask, du._du->du_ident);
sigaddset(&sigmask, signo);
fd = signalfd(-1, &sigmask, SFD_NONBLOCK | SFD_CLOEXEC);
if (fd < 0) {
return NULL;
}
break;

}
case EVFILT_WRITE:
filter = EVFILT_READ;
case EVFILT_READ:
Expand Down Expand Up @@ -290,7 +291,7 @@ _dispatch_unote_resume(dispatch_unote_t du)
}

bool
_dispatch_unote_unregister(dispatch_unote_t du, uint32_t flags)
_dispatch_unote_unregister(dispatch_unote_t du, DISPATCH_UNUSED uint32_t flags)
{
switch (du._du->du_filter) {
case DISPATCH_EVFILT_CUSTOM_ADD:
Expand All @@ -313,10 +314,10 @@ _dispatch_unote_unregister(dispatch_unote_t du, uint32_t flags)
dul->du_muxnote = NULL;

if (TAILQ_EMPTY(&dmn->dmn_readers_head)) {
events &= ~EPOLLIN;
events &= (uint32_t)(~EPOLLIN);
}
if (TAILQ_EMPTY(&dmn->dmn_writers_head)) {
events &= ~EPOLLOUT;
events &= (uint32_t)(~EPOLLOUT);
}

if (events == dmn->dmn_events) {
Expand Down Expand Up @@ -350,32 +351,33 @@ _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)
{
dispatch_clock_t clock = DISPATCH_TIMER_CLOCK(tidx);
dispatch_epoll_timeout_t timer = &_dispatch_epoll_timeout[clock];
struct epoll_event ev = {
.events = EPOLLONESHOT | EPOLLIN,
.data = { .u32 = timer->det_ident },
};
unsigned long op;
int op;

if (target >= INT64_MAX && !timer->det_registered) {
return;
}

if (unlikely(timer->det_fd < 0)) {
clockid_t clock;
clockid_t clockid;
int fd;
switch (DISPATCH_TIMER_CLOCK(tidx)) {
case DISPATCH_CLOCK_MACH:
clock = CLOCK_MONOTONIC;
clockid = CLOCK_MONOTONIC;
break;
case DISPATCH_CLOCK_WALL:
clock = CLOCK_REALTIME;
clockid = CLOCK_REALTIME;
break;
}
fd = timerfd_create(clock, TFD_NONBLOCK | TFD_CLOEXEC);
fd = timerfd_create(clockid, TFD_NONBLOCK | TFD_CLOEXEC);
if (!dispatch_assume(fd >= 0)) {
return;
}
Expand Down Expand Up @@ -451,7 +453,7 @@ _dispatch_epoll_init(void *context DISPATCH_UNUSED)
.events = EPOLLIN | EPOLLFREE,
.data = { .u32 = DISPATCH_EPOLL_EVENTFD, },
};
unsigned long op = EPOLL_CTL_ADD;
int op = EPOLL_CTL_ADD;
if (epoll_ctl(_dispatch_epfd, op, _dispatch_eventfd, &ev) < 0) {
DISPATCH_INTERNAL_CRASH(errno, "epoll_ctl() failed");
}
Expand Down Expand Up @@ -504,7 +506,7 @@ _dispatch_get_buffer_size(dispatch_muxnote_t dmn, bool writer)
return 1;
}

if (ioctl(dmn->dmn_ident, writer ? SIOCOUTQ : SIOCINQ, &n) != 0) {
if (ioctl((int)dmn->dmn_ident, writer ? SIOCOUTQ : SIOCINQ, &n) != 0) {
switch (errno) {
case EINVAL:
case ENOTTY:
Expand Down
16 changes: 7 additions & 9 deletions src/event/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

#if DISPATCH_USE_INTERNAL_WORKQUEUE

// forward looking typedef; not yet defined in dispatch
typedef pid_t dispatch_tid;

/*
* dispatch_workq monitors the thread pool that is
* executing the work enqueued on libdispatch's pthread
Expand Down Expand Up @@ -88,7 +85,7 @@ _dispatch_workq_worker_register(dispatch_queue_t root_q, qos_class_t cls)
dispatch_qos_t qos = _dispatch_qos_from_qos_class(cls);
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[qos-1];
dispatch_assert(mon->dq == root_q);
dispatch_tid tid = _dispatch_thread_getspecific(tid);
dispatch_tid tid = _dispatch_tid_self();
_dispatch_unfair_lock_lock(&mon->registered_tid_lock);
dispatch_assert(mon->num_registered_tids < WORKQ_MAX_TRACKED_TIDS-1);
int worker_id = mon->num_registered_tids++;
Expand All @@ -103,7 +100,8 @@ _dispatch_workq_worker_unregister(dispatch_queue_t root_q, qos_class_t cls)
#if HAVE_DISPATCH_WORKQ_MONITORING
dispatch_qos_t qos = _dispatch_qos_from_qos_class(cls);
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[qos-1];
dispatch_tid tid = _dispatch_thread_getspecific(tid);
dispatch_assert(mon->dq == root_q);
dispatch_tid tid = _dispatch_tid_self();
_dispatch_unfair_lock_lock(&mon->registered_tid_lock);
for (int i = 0; i < mon->num_registered_tids; i++) {
if (mon->registered_tids[i] == tid) {
Expand Down Expand Up @@ -138,10 +136,10 @@ _dispatch_workq_count_runnable_workers(dispatch_workq_monitor_t mon)
for (int i = 0; i < mon->num_registered_tids; i++) {
dispatch_tid tid = mon->registered_tids[i];
int fd;
size_t bytes_read = -1;
ssize_t bytes_read = -1;

int r = snprintf(path, sizeof(path), "/proc/%d/stat", tid);
dispatch_assert(r > 0 && r < sizeof(path));
dispatch_assert(r > 0 && r < (int)sizeof(path));

fd = open(path, O_RDONLY | O_NONBLOCK);
if (unlikely(fd == -1)) {
Expand Down Expand Up @@ -179,7 +177,7 @@ _dispatch_workq_count_runnable_workers(dispatch_workq_monitor_t mon)
static void
_dispatch_workq_monitor_pools(void *context DISPATCH_UNUSED)
{
int global_soft_max = WORKQ_OVERSUBSCRIBE_FACTOR * dispatch_hw_config(active_cpus);
int global_soft_max = WORKQ_OVERSUBSCRIBE_FACTOR * (int)dispatch_hw_config(active_cpus);
int global_runnable = 0;
for (dispatch_qos_t i = DISPATCH_QOS_MAX; i > DISPATCH_QOS_UNSPECIFIED; i--) {
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[i-1];
Expand Down Expand Up @@ -228,7 +226,7 @@ static void
_dispatch_workq_init_once(void *context DISPATCH_UNUSED)
{
#if HAVE_DISPATCH_WORKQ_MONITORING
int target_runnable = dispatch_hw_config(active_cpus);
int target_runnable = (int)dispatch_hw_config(active_cpus);
for (dispatch_qos_t i = DISPATCH_QOS_MAX; i > DISPATCH_QOS_UNSPECIFIED; i--) {
dispatch_workq_monitor_t mon = &_dispatch_workq_monitors[i-1];
mon->dq = _dispatch_get_root_queue(i, false);
Expand Down
20 changes: 14 additions & 6 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
DISPATCH_EXPORT DISPATCH_NOINLINE
void _dispatch_bug(size_t line, long val);

#if HAVE_MACH
DISPATCH_NOINLINE
void _dispatch_bug_client(const char* msg);
#if HAVE_MACH
DISPATCH_NOINLINE
void _dispatch_bug_mach_client(const char *msg, mach_msg_return_t kr);
#endif // HAVE_MACH
Expand Down Expand Up @@ -466,7 +466,9 @@ 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)
{
if (DISPATCH_DEBUG && !e) _dispatch_abort(line, e);
}
#define dispatch_assert(e) _dispatch_assert((long)(e), __LINE__)
Expand All @@ -488,7 +490,9 @@ 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)
{
if (DISPATCH_DEBUG && e) _dispatch_abort(line, e);
}
#define dispatch_assert_zero(e) _dispatch_assert_zero((long)(e), __LINE__)
Expand All @@ -512,7 +516,9 @@ static inline void _dispatch_assert_zero(long e, long line) {
_e; \
})
#else
static inline long _dispatch_assume(long e, long line) {
static inline long
_dispatch_assume(long e, long line)
{
if (!e) _dispatch_bug(line, e);
return e;
}
Expand All @@ -535,7 +541,9 @@ static inline long _dispatch_assume(long e, long line) {
_e; \
})
#else
static inline long _dispatch_assume_zero(long e, long line) {
static inline long
_dispatch_assume_zero(long e, long line)
{
if (e) _dispatch_bug(line, e);
return e;
}
Expand Down Expand Up @@ -850,7 +858,7 @@ _dispatch_ktrace_impl(uint32_t code, uint64_t a, uint64_t b,
#define _dispatch_hardware_crash() \
__asm__(""); __builtin_trap() // <rdar://problem/17464981>

#define _dispatch_set_crash_log_cause_and_message(ac, msg)
#define _dispatch_set_crash_log_cause_and_message(ac, msg) ((void)(ac))
#define _dispatch_set_crash_log_message(msg)
#define _dispatch_set_crash_log_message_dynamic(msg)

Expand Down
6 changes: 3 additions & 3 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

#ifndef PAGE_SIZE
#define PAGE_SIZE getpagesize()
#define PAGE_SIZE ((size_t)getpagesize())
#endif

#if DISPATCH_DATA_IS_BRIDGED_TO_NSDATA
Expand Down Expand Up @@ -1372,7 +1372,7 @@ _dispatch_fd_entry_create_with_fd(dispatch_fd_t fd, uintptr_t hash)
break;
);
}
int32_t dev = major(st.st_dev);
dev_t dev = major(st.st_dev);
// We have to get the disk on the global dev queue. The
// barrier queue cannot continue until that is complete
dispatch_suspend(fd_entry->barrier_queue);
Expand Down Expand Up @@ -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),
case EINVAL: break; // fd does refer to a non-supported filetype
default: (void)dispatch_assume_zero(err); break;
);
Expand Down
6 changes: 5 additions & 1 deletion src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5329,6 +5329,8 @@ _dispatch_root_queue_push(dispatch_queue_t rq, dispatch_object_t dou,
if (_dispatch_root_queue_push_needs_override(rq, qos)) {
return _dispatch_root_queue_push_override(rq, dou, qos);
}
#else
(void)qos;
#endif
_dispatch_root_queue_push_inline(rq, dou, dou, 1);
}
Expand Down Expand Up @@ -5870,7 +5872,7 @@ _dispatch_worker_thread(void *context)

#if DISPATCH_USE_INTERNAL_WORKQUEUE
if (monitored) {
_dispatch_workq_worker_unregister(dq, qc->dgq_qos);
_dispatch_workq_worker_unregister(dq, qc->dgq_qos);
}
#endif
(void)os_atomic_inc2o(qc, dgq_thread_pool_size, release);
Expand Down Expand Up @@ -5962,6 +5964,7 @@ _dispatch_runloop_root_queue_wakeup_4CF(dispatch_queue_t dq)
_dispatch_runloop_queue_wakeup(dq, 0, false);
}

#if TARGET_OS_MAC
dispatch_runloop_handle_t
_dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t dq)
{
Expand All @@ -5970,6 +5973,7 @@ _dispatch_runloop_root_queue_get_port_4CF(dispatch_queue_t dq)
}
return _dispatch_runloop_queue_get_handle(dq);
}
#endif

static void
_dispatch_runloop_queue_handle_init(void *ctxt)
Expand Down
Loading