mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Fix pointer to integer cast warnings
This fixes warning: cast to pointer from integer of different size. In Windows platform, long is 4 bytes. So, void* is first cast to intptr_t then to int. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/630>
This commit is contained in:
parent
747efc1017
commit
f5b94eff76
5 changed files with 18 additions and 15 deletions
|
|
@ -21,6 +21,7 @@
|
|||
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
/*
|
||||
|
|
@ -103,10 +104,10 @@ static inline bool pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) {
|
|||
}
|
||||
|
||||
typedef struct pa_atomic_ptr {
|
||||
volatile unsigned long value;
|
||||
volatile uintptr_t value;
|
||||
} pa_atomic_ptr_t;
|
||||
|
||||
#define PA_ATOMIC_PTR_INIT(v) { .value = (long) (v) }
|
||||
#define PA_ATOMIC_PTR_INIT(v) { .value = (uintptr_t) (v) }
|
||||
|
||||
#ifdef HAVE_ATOMIC_BUILTINS_MEMORY_MODEL
|
||||
|
||||
|
|
@ -117,7 +118,7 @@ static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
|
|||
}
|
||||
|
||||
static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void* p) {
|
||||
__atomic_store_n(&a->value, (unsigned long) p, __ATOMIC_SEQ_CST);
|
||||
__atomic_store_n(&a->value, (uintptr_t) p, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
@ -128,14 +129,14 @@ static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
|
|||
}
|
||||
|
||||
static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) {
|
||||
a->value = (unsigned long) p;
|
||||
a->value = (uintptr_t) p;
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline bool pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) {
|
||||
return __sync_bool_compare_and_swap(&a->value, (long) old_p, (long) new_p);
|
||||
return __sync_bool_compare_and_swap(&a->value, (uintptr_t) old_p, (uintptr_t) new_p);
|
||||
}
|
||||
|
||||
#elif defined(__NetBSD__) && defined(HAVE_SYS_ATOMIC_H)
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ static HANDLE
|
|||
HandleFromFd (int fd)
|
||||
{
|
||||
/* since socket() returns a HANDLE already, try that first */
|
||||
if (IsSocketHandle((HANDLE) fd))
|
||||
return ((HANDLE) fd);
|
||||
if (IsSocketHandle(PA_INT_TO_PTR(fd)))
|
||||
return PA_INT_TO_PTR(fd);
|
||||
|
||||
return ((HANDLE) _get_osfhandle(fd));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4715,7 +4715,7 @@ static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag,
|
|||
CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOEXTENSION);
|
||||
CHECK_VALIDITY(c->pstream, m->load_once || idx != PA_INVALID_INDEX, tag, PA_ERR_INVALID);
|
||||
|
||||
cb = (pa_native_protocol_ext_cb_t) (unsigned long) pa_hashmap_get(c->protocol->extensions, m);
|
||||
cb = pa_hashmap_get(c->protocol->extensions, m);
|
||||
CHECK_VALIDITY(c->pstream, cb, tag, PA_ERR_NOEXTENSION);
|
||||
|
||||
if (cb(c->protocol, m, c, tag, t) < 0)
|
||||
|
|
@ -5414,7 +5414,7 @@ int pa_native_protocol_install_ext(pa_native_protocol *p, pa_module *m, pa_nativ
|
|||
pa_assert(cb);
|
||||
pa_assert(!pa_hashmap_get(p->extensions, m));
|
||||
|
||||
pa_assert_se(pa_hashmap_put(p->extensions, m, (void*) (unsigned long) cb) == 0);
|
||||
pa_assert_se(pa_hashmap_put(p->extensions, m, cb) == 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include <pulse/mainloop.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#define NSTREAMS 4
|
||||
#define SINE_HZ 440
|
||||
|
|
@ -56,7 +57,7 @@ static const pa_buffer_attr buffer_attr = {
|
|||
static void nop_free_cb(void *p) {}
|
||||
|
||||
static void underflow_cb(struct pa_stream *s, void *userdata) {
|
||||
int i = (int) (long) userdata;
|
||||
int i = PA_PTR_TO_INT(userdata);
|
||||
|
||||
fprintf(stderr, "Stream %i finished\n", i);
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
|
|||
|
||||
case PA_STREAM_READY: {
|
||||
|
||||
int r, i = (int) (long) userdata;
|
||||
int r, i = PA_PTR_TO_INT(userdata);
|
||||
|
||||
fprintf(stderr, "Writing data to stream %i.\n", i);
|
||||
|
||||
|
|
@ -135,7 +136,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
|
|||
|
||||
streams[i] = pa_stream_new_extended(c, name, formats, 1, NULL);
|
||||
fail_unless(streams[i] != NULL);
|
||||
pa_stream_set_state_callback(streams[i], stream_state_callback, (void*) (long) i);
|
||||
pa_stream_set_state_callback(streams[i], stream_state_callback, PA_INT_TO_PTR(i));
|
||||
pa_stream_connect_playback(streams[i], NULL, &buffer_attr, PA_STREAM_START_CORKED, NULL, i == 0 ? NULL : streams[0]);
|
||||
|
||||
pa_format_info_free(formats[0]);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include <pulse/mainloop.h>
|
||||
#include <pulsecore/macro.h>
|
||||
|
||||
#define NSTREAMS 4
|
||||
#define SINE_HZ 440
|
||||
|
|
@ -62,7 +63,7 @@ static const pa_buffer_attr buffer_attr = {
|
|||
static void nop_free_cb(void *p) {}
|
||||
|
||||
static void underflow_cb(struct pa_stream *s, void *userdata) {
|
||||
int i = (int) (long) userdata;
|
||||
int i = PA_PTR_TO_INT(userdata);
|
||||
|
||||
fprintf(stderr, "Stream %i finished\n", i);
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
|
|||
|
||||
case PA_STREAM_READY: {
|
||||
|
||||
int r, i = (int) (long) userdata;
|
||||
int r, i = PA_PTR_TO_INT(userdata);
|
||||
|
||||
fprintf(stderr, "Writing data to stream %i.\n", i);
|
||||
|
||||
|
|
@ -134,7 +135,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
|
|||
|
||||
streams[i] = pa_stream_new(c, name, &sample_spec, NULL);
|
||||
fail_unless(streams[i] != NULL);
|
||||
pa_stream_set_state_callback(streams[i], stream_state_callback, (void*) (long) i);
|
||||
pa_stream_set_state_callback(streams[i], stream_state_callback, PA_INT_TO_PTR(i));
|
||||
pa_stream_connect_playback(streams[i], NULL, &buffer_attr, PA_STREAM_START_CORKED, NULL, i == 0 ? NULL : streams[0]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue