Fix integer signedness and fd size confusion

dev
Kristian Høgsberg 14 years ago
parent f821f5ad93
commit 4f14f6e109
  1. 29
      connection.c

@ -222,7 +222,7 @@ close_fds(struct wl_buffer *buffer)
return; return;
wl_buffer_copy(buffer, fds, size); wl_buffer_copy(buffer, fds, size);
count = size / 4; count = size / sizeof fds[0];
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
close(fds[i]); close(fds[i]);
buffer->tail += size; buffer->tail += size;
@ -340,7 +340,7 @@ wl_connection_vmarshal(struct wl_connection *connection,
struct wl_closure *closure = &connection->closure; struct wl_closure *closure = &connection->closure;
struct wl_object *object; struct wl_object *object;
uint32_t length, *p, size; uint32_t length, *p, size;
int32_t dup_fd; int dup_fd;
struct wl_array *array; struct wl_array *array;
const char *s; const char *s;
int i, count, fd; int i, count, fd;
@ -350,9 +350,11 @@ wl_connection_vmarshal(struct wl_connection *connection,
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
switch (message->signature[i]) { switch (message->signature[i]) {
case 'u': case 'u':
case 'i':
*p++ = va_arg(ap, uint32_t); *p++ = va_arg(ap, uint32_t);
break; break;
case 'i':
*p++ = va_arg(ap, int32_t);
break;
case 's': case 's':
s = va_arg(ap, const char *); s = va_arg(ap, const char *);
length = s ? strlen(s) + 1: 0; length = s ? strlen(s) + 1: 0;
@ -428,7 +430,8 @@ wl_connection_demarshal(struct wl_connection *connection,
struct wl_hash_table *objects, struct wl_hash_table *objects,
const struct wl_message *message) const struct wl_message *message)
{ {
uint32_t *p, *next, *end, length, *uint; uint32_t *p, *next, *end, length;
int *fd;
char *extra, **s; char *extra, **s;
int i, count, extra_space; int i, count, extra_space;
struct wl_object **object; struct wl_object **object;
@ -466,10 +469,13 @@ wl_connection_demarshal(struct wl_connection *connection,
switch (message->signature[i - 2]) { switch (message->signature[i - 2]) {
case 'u': case 'u':
case 'i':
closure->types[i] = &ffi_type_uint32; closure->types[i] = &ffi_type_uint32;
closure->args[i] = p++; closure->args[i] = p++;
break; break;
case 'i':
closure->types[i] = &ffi_type_sint32;
closure->args[i] = p++;
break;
case 's': case 's':
closure->types[i] = &ffi_type_pointer; closure->types[i] = &ffi_type_pointer;
length = *p++; length = *p++;
@ -557,15 +563,14 @@ wl_connection_demarshal(struct wl_connection *connection,
p = next; p = next;
break; break;
case 'h': case 'h':
closure->types[i] = &ffi_type_uint32; closure->types[i] = &ffi_type_sint;
uint = (uint32_t *) extra; fd = (int *) extra;
extra += sizeof *uint; extra += sizeof *fd;
closure->args[i] = uint; closure->args[i] = fd;
wl_buffer_copy(&connection->fds_in, wl_buffer_copy(&connection->fds_in, fd, sizeof *fd);
uint, sizeof *uint); connection->fds_in.tail += sizeof *fd;
connection->fds_in.tail += sizeof *uint;
break; break;
default: default:
printf("unknown type\n"); printf("unknown type\n");

Loading…
Cancel
Save