From: <svn...@op...> - 2009-03-30 05:00:00
|
Author: dgollub Date: Mon Mar 30 06:59:57 2009 New Revision: 5458 URL: http://www.opensync.org/changeset/5458 Log: Cleaned up int vs. unsigned int for marshal API refs #974 Modified: trunk/opensync/common/opensync_marshal.c trunk/opensync/common/opensync_marshal.h trunk/opensync/ipc/opensync_message.c trunk/opensync/ipc/opensync_message_internals.h trunk/opensync/ipc/opensync_serializer.c trunk/tests/format-tests/check_objformat.c trunk/tests/mock-plugin/mock_format.c Modified: trunk/opensync/common/opensync_marshal.c ============================================================================== --- trunk/opensync/common/opensync_marshal.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/common/opensync_marshal.c Mon Mar 30 06:59:57 2009 (r5458) @@ -104,28 +104,28 @@ void osync_marshal_write_string(OSyncMarshal *marshal, const char *value) { - int length = 0; + unsigned int length = 0; if (value == NULL) { length = -1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( int ) ); + g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); } else { - int length = strlen( value ) + 1; - g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( int ) ); + length = strlen( value ) + 1; + g_byte_array_append( marshal->buffer, (unsigned char*)&length, sizeof( unsigned int ) ); g_byte_array_append( marshal->buffer, (unsigned char*)value, length ); } } -void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, int size) +void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, unsigned int size) { /* TODO move this to PRIVATE API */ g_byte_array_append( marshal->buffer, value, size ); } -void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, int size) +void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, unsigned int size) { /* serialize the length of the data to make it possible to determine the end of this data blob in the serialized blob. This makes demarshaling possible! */ - osync_marshal_write_int(marshal, size); + osync_marshal_write_uint(marshal, size); if (size > 0) osync_marshal_write_data(marshal, value, size); } @@ -171,8 +171,8 @@ void osync_marshal_read_string(OSyncMarshal *marshal, char **value) { - int length = 0; - osync_marshal_read_int(marshal, &length); + unsigned int length = 0; + osync_marshal_read_uint(marshal, &length); if (length == -1) { *value = NULL; @@ -190,7 +190,7 @@ marshal->buffer_read_pos += length; } -void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, int size) +void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, unsigned int size) { osync_assert(marshal->buffer->len >= marshal->buffer_read_pos + size); @@ -198,7 +198,7 @@ marshal->buffer_read_pos += size; } -void osync_marshal_read_data(OSyncMarshal *marshal, void *value, int size) +void osync_marshal_read_data(OSyncMarshal *marshal, void *value, unsigned int size) { osync_assert(marshal->buffer->len >= marshal->buffer_read_pos + size); @@ -206,10 +206,10 @@ marshal->buffer_read_pos += size; } -void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, int *size) +void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, unsigned int *size) { /* Now, read the data from the marshal */ - osync_marshal_read_int(marshal, size); + osync_marshal_read_uint(marshal, size); if (*size > 0) { *value = g_malloc0(*size); Modified: trunk/opensync/common/opensync_marshal.h ============================================================================== --- trunk/opensync/common/opensync_marshal.h Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/common/opensync_marshal.h Mon Mar 30 06:59:57 2009 (r5458) @@ -127,7 +127,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_EXPORT void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, int size); +OSYNC_EXPORT void osync_marshal_write_data(OSyncMarshal *marshal, const void *value, unsigned int size); /** @brief Appends data with a specific length to the serialized buffer, * plus the length of the data to determine the end. @@ -136,7 +136,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_EXPORT void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, int size); +OSYNC_EXPORT void osync_marshal_write_buffer(OSyncMarshal *marshal, const void *value, unsigned int size); /** @brief Read serialized integer from marshal buffer. This increments the read * position of the marshal buffer. @@ -179,7 +179,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_EXPORT void osync_marshal_read_data(OSyncMarshal *marshal, void *value, int size); +OSYNC_EXPORT void osync_marshal_read_data(OSyncMarshal *marshal, void *value, unsigned int size); /** @brief Read serialized const data from marshal buffer. This increments the read * position of the marshal buffer. @@ -188,7 +188,7 @@ * @param value Reference to store the data pointer * @param size The size of data */ -OSYNC_EXPORT void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, int size); +OSYNC_EXPORT void osync_marshal_read_const_data(OSyncMarshal *marshal, void **value, unsigned int size); /** @brief Read serialized const string from marshal buffer. This increments the read * position of the marshal buffer. @@ -206,7 +206,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_EXPORT void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, int *size); +OSYNC_EXPORT void osync_marshal_read_buffer(OSyncMarshal *marshal, void **value, unsigned int *size); /*@}*/ Modified: trunk/opensync/ipc/opensync_message.c ============================================================================== --- trunk/opensync/ipc/opensync_message.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_message.c Mon Mar 30 06:59:57 2009 (r5458) @@ -225,12 +225,12 @@ osync_marshal_write_string(message->marshal, value); } -void osync_message_write_data(OSyncMessage *message, const void *value, int size) +void osync_message_write_data(OSyncMessage *message, const void *value, unsigned int size) { osync_marshal_write_data(message->marshal, value, size); } -void osync_message_write_buffer(OSyncMessage *message, const void *value, int size) +void osync_message_write_buffer(OSyncMessage *message, const void *value, unsigned int size) { osync_marshal_write_buffer(message->marshal, value, size); } @@ -261,17 +261,17 @@ osync_marshal_read_string(message->marshal, value); } -void osync_message_read_const_data(OSyncMessage *message, void **value, int size) +void osync_message_read_const_data(OSyncMessage *message, void **value, unsigned int size) { osync_marshal_read_const_data(message->marshal, value, size); } -void osync_message_read_data(OSyncMessage *message, void *value, int size) +void osync_message_read_data(OSyncMessage *message, void *value, unsigned int size) { osync_marshal_read_data(message->marshal, value, size); } -void osync_message_read_buffer(OSyncMessage *message, void **value, int *size) +void osync_message_read_buffer(OSyncMessage *message, void **value, unsigned int *size) { osync_marshal_read_buffer(message->marshal, value, size); } Modified: trunk/opensync/ipc/opensync_message_internals.h ============================================================================== --- trunk/opensync/ipc/opensync_message_internals.h Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_message_internals.h Mon Mar 30 06:59:57 2009 (r5458) @@ -309,7 +309,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_TEST_EXPORT void osync_message_write_data(OSyncMessage *message, const void *value, int size); +OSYNC_TEST_EXPORT void osync_message_write_data(OSyncMessage *message, const void *value, unsigned int size); /** @brief Appends data with a specific length to the serialized message buffer, * plus the length of the data to determine the end. @@ -318,7 +318,7 @@ * @param value The data to append * @param size Size of corresponding data parameter */ -OSYNC_TEST_EXPORT void osync_message_write_buffer(OSyncMessage *message, const void *value, int size); +OSYNC_TEST_EXPORT void osync_message_write_buffer(OSyncMessage *message, const void *value, unsigned int size); /** @brief Read serialized integer from message buffer. This increments the read * position of the message buffer. @@ -361,7 +361,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_TEST_EXPORT void osync_message_read_data(OSyncMessage *message, void *value, int size); +OSYNC_TEST_EXPORT void osync_message_read_data(OSyncMessage *message, void *value, unsigned int size); /** @brief Read serialized const data from message buffer. This increments the read * position of the message buffer. @@ -370,7 +370,7 @@ * @param value Reference to store the data pointer * @param size The size of data */ -OSYNC_TEST_EXPORT void osync_message_read_const_data(OSyncMessage *message, void **value, int size); +OSYNC_TEST_EXPORT void osync_message_read_const_data(OSyncMessage *message, void **value, unsigned int size); /** @brief Read serialized const string from message buffer. This increments the read * position of the message buffer. @@ -388,7 +388,7 @@ * @param value Reference to store the pointer to the newly allocated data * @param size Size of data */ -OSYNC_TEST_EXPORT void osync_message_read_buffer(OSyncMessage *message, void **value, int *size); +OSYNC_TEST_EXPORT void osync_message_read_buffer(OSyncMessage *message, void **value, unsigned int *size); /*@}*/ Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/opensync/ipc/opensync_serializer.c Mon Mar 30 06:59:57 2009 (r5458) @@ -124,7 +124,7 @@ if (!osync_objformat_demarshal(format, marshal, &input_data, &input_size, error)) goto error; } else { - osync_message_read_buffer(message, (void *)&input_data, (int *)&input_size); + osync_message_read_buffer(message, (void *)&input_data, &input_size); /* If the format is a plain, then we have to remove * one from the input_size, since once one was added by Modified: trunk/tests/format-tests/check_objformat.c ============================================================================== --- trunk/tests/format-tests/check_objformat.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/tests/format-tests/check_objformat.c Mon Mar 30 06:59:57 2009 (r5458) @@ -55,7 +55,7 @@ osync_bool demarshal_format(OSyncMarshal *marshal, char **output, unsigned int *outsize, void *user_data, OSyncError **error) { - osync_marshal_read_buffer(marshal, (void *)output, (int *)outsize); + osync_marshal_read_buffer(marshal, (void *)output, outsize); return TRUE; } Modified: trunk/tests/mock-plugin/mock_format.c ============================================================================== --- trunk/tests/mock-plugin/mock_format.c Mon Mar 30 06:57:37 2009 (r5457) +++ trunk/tests/mock-plugin/mock_format.c Mon Mar 30 06:59:57 2009 (r5458) @@ -218,7 +218,7 @@ osync_assert(file); osync_marshal_read_string(marshal, &(file->path)); - osync_marshal_read_buffer(marshal, (void *)&(file->data), (int *)&(file->size)); + osync_marshal_read_buffer(marshal, (void *)&(file->data), &(file->size)); *output = (char *)file; *outpsize = sizeof(OSyncFileFormat); |