mirror of
https://github.com/SuperBFG7/ympd
synced 2024-09-28 06:18:13 +00:00
Fix: compiler warnings on 64bit arch
This commit is contained in:
parent
044456cbba
commit
0681386eb8
@ -52,7 +52,7 @@
|
|||||||
//check and return buffer size
|
//check and return buffer size
|
||||||
#define CHECK_RETURN_LEN() do { \
|
#define CHECK_RETURN_LEN() do { \
|
||||||
if (len > MAX_SIZE) \
|
if (len > MAX_SIZE) \
|
||||||
printf("Buffer truncated: %d, %d\n", len, MAX_SIZE); \
|
printf("ERROR: Buffer truncated\n"); \
|
||||||
return len; \
|
return len; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -1140,7 +1140,7 @@ static void mpd_client_idle(t_config *config, t_mpd_state *mpd_state) {
|
|||||||
printf("MPD connection failed.\n");
|
printf("MPD connection failed.\n");
|
||||||
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"disconnected\"}");
|
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"disconnected\"}");
|
||||||
mpd_client_notify(buffer, len);
|
mpd_client_notify(buffer, len);
|
||||||
|
// fall through
|
||||||
case MPD_DISCONNECT:
|
case MPD_DISCONNECT:
|
||||||
case MPD_RECONNECT:
|
case MPD_RECONNECT:
|
||||||
if (mpd_state->conn != NULL)
|
if (mpd_state->conn != NULL)
|
||||||
|
@ -79,6 +79,7 @@ int tiny_queue_push(tiny_queue_t *queue, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int tiny_queue_length(tiny_queue_t *queue, int timeout) {
|
int tiny_queue_length(tiny_queue_t *queue, int timeout) {
|
||||||
|
timeout = timeout * 1000;
|
||||||
int rc = pthread_mutex_lock(&queue->mutex);
|
int rc = pthread_mutex_lock(&queue->mutex);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("Error in pthread_mutex_lock: %d\n", rc);
|
printf("Error in pthread_mutex_lock: %d\n", rc);
|
||||||
@ -88,9 +89,14 @@ int tiny_queue_length(tiny_queue_t *queue, int timeout) {
|
|||||||
struct timespec max_wait = {0, 0};
|
struct timespec max_wait = {0, 0};
|
||||||
clock_gettime(CLOCK_REALTIME, &max_wait);
|
clock_gettime(CLOCK_REALTIME, &max_wait);
|
||||||
//timeout in ms
|
//timeout in ms
|
||||||
max_wait.tv_nsec += timeout * 1000;
|
if (max_wait.tv_nsec <= (999999999 - timeout)) {
|
||||||
|
max_wait.tv_nsec += timeout;
|
||||||
|
} else {
|
||||||
|
max_wait.tv_sec += 1;
|
||||||
|
max_wait.tv_nsec = timeout - (999999999 - max_wait.tv_nsec);
|
||||||
|
}
|
||||||
rc = pthread_cond_timedwait(&queue->wakeup, &queue->mutex, &max_wait);
|
rc = pthread_cond_timedwait(&queue->wakeup, &queue->mutex, &max_wait);
|
||||||
if (rc != 0) {
|
if (rc != 0 && rc != ETIMEDOUT) {
|
||||||
printf("Error in pthread_cond_timedwait: %d\n", rc);
|
printf("Error in pthread_cond_timedwait: %d\n", rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,6 +109,7 @@ int tiny_queue_length(tiny_queue_t *queue, int timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *tiny_queue_shift(tiny_queue_t *queue, int timeout) {
|
void *tiny_queue_shift(tiny_queue_t *queue, int timeout) {
|
||||||
|
timeout = timeout * 1000;
|
||||||
int rc = pthread_mutex_lock(&queue->mutex);
|
int rc = pthread_mutex_lock(&queue->mutex);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("Error in pthread_mutex_lock: %d\n", rc);
|
printf("Error in pthread_mutex_lock: %d\n", rc);
|
||||||
@ -113,10 +120,18 @@ void *tiny_queue_shift(tiny_queue_t *queue, int timeout) {
|
|||||||
struct timespec max_wait = {0, 0};
|
struct timespec max_wait = {0, 0};
|
||||||
clock_gettime(CLOCK_REALTIME, &max_wait);
|
clock_gettime(CLOCK_REALTIME, &max_wait);
|
||||||
//timeout in ms
|
//timeout in ms
|
||||||
max_wait.tv_nsec += timeout * 1000;
|
if (max_wait.tv_nsec <= (999999999 - timeout)) {
|
||||||
|
max_wait.tv_nsec += timeout;
|
||||||
|
} else {
|
||||||
|
max_wait.tv_sec += 1;
|
||||||
|
max_wait.tv_nsec = timeout - (999999999 - max_wait.tv_nsec);
|
||||||
|
}
|
||||||
rc = pthread_cond_timedwait(&queue->wakeup, &queue->mutex, &max_wait);
|
rc = pthread_cond_timedwait(&queue->wakeup, &queue->mutex, &max_wait);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("Error in pthread_cond_timedwait: %d\n", rc);
|
if (rc != ETIMEDOUT) {
|
||||||
|
printf("Error in pthread_cond_timedwait: %d\n", rc);
|
||||||
|
printf("nsec: %ld\n", max_wait.tv_nsec);
|
||||||
|
}
|
||||||
rc = pthread_mutex_unlock(&queue->mutex);
|
rc = pthread_mutex_unlock(&queue->mutex);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
printf("Error in pthread_mutex_unlock: %d\n", rc);
|
printf("Error in pthread_mutex_unlock: %d\n", rc);
|
||||||
|
Loading…
Reference in New Issue
Block a user