Skip to content

Commit aebe837

Browse files
toofishesAlon Levy
authored and
Alon Levy
committed
Add casts for compatibility purposes
Some non-Linux platforms return a (caddr_t *) result for the return value of mmap(), which is very unfortunate. Add a (void *) cast to explicitly avoid the warning when compiling with -Werror. For the IO vector related stuff, signed vs. unsigned comes into play so adding a (void *) cast here is technically correct for all platforms. Signed-off-by: Dan McGee <[email protected]>
1 parent 5868c99 commit aebe837

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

common/marshaller.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ int spice_marshaller_fill_iovec(SpiceMarshaller *m, struct iovec *vec,
525525
if (v == n_vec) {
526526
return v; /* Not enough space in vec */
527527
}
528-
vec[v].iov_base = item->data + skip_bytes;
528+
vec[v].iov_base = (void *)item->data + skip_bytes;
529529
vec[v].iov_len = item->len - skip_bytes;
530530
skip_bytes = 0;
531531
v++;

server/reds.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3623,7 +3623,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
36233623
if (ftruncate(fd, REDS_STAT_SHM_SIZE) == -1) {
36243624
red_error("statistics ftruncate failed, %s", strerror(errno));
36253625
}
3626-
reds->stat = mmap(NULL, REDS_STAT_SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
3626+
reds->stat = (SpiceStat *)mmap(NULL, REDS_STAT_SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
36273627
if (reds->stat == (SpiceStat *)MAP_FAILED) {
36283628
red_error("statistics mmap failed, %s", strerror(errno));
36293629
}

tools/reds_stat.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int main(int argc, char **argv)
8484
return -1;
8585
}
8686
shm_size = sizeof(SpiceStat);
87-
reds_stat = mmap(NULL, shm_size, PROT_READ, MAP_SHARED, fd, 0);
87+
reds_stat = (SpiceStat *)mmap(NULL, shm_size, PROT_READ, MAP_SHARED, fd, 0);
8888
if (reds_stat == (SpiceStat *)MAP_FAILED) {
8989
perror("mmap");
9090
goto error1;

0 commit comments

Comments
 (0)