[PATCH] various fixes for marshlling empty fixed type arrays
Havoc Pennington
hp at redhat.com
Mon Feb 6 19:22:14 PST 2006
Hi,
I think there's probably a better way to fix the dbus-marshal-basic.c
issue (I'm not sure where it was breaking); the functions called there
should allow a length of 0, so I'm guessing the problem was a NULL
array_start or something? If so perhaps making dbus_string_copy allow a
NULL string when length is 0 would be a nicer fix.
- g_assert (msgarray != NULL);
- g_assert (msgarray_len >= 0);
- g_array_append_vals (ret, msgarray, (guint) msgarray_len);
+ if (msgarray_len)
Suggestions:
- changing the first assert to msgarray != NULL || msgarray_len == 0
would be nicer I think
- why not leave the second assert there?
- prefer msgarray_len != 0 for the test since it's not a bool
- _dbus_return_if_fail (dbus_type_is_fixed
(_dbus_type_reader_get_current_type (&real->u.reader)));
Perhaps again the assertion could just be changed to
len == 0 || (existing assertion)
It's not redundant because assert and return_if_fail are different.
return_if_fail is only used in public functions, and remains enabled in
production code, while assertions are used to verify dbus's own internal
correctness and are disabled in production code.
This return_if_fail would give you a semi-helpful warning if you tried
to use the function on an array of non-fixed type, without it we
probably just crash or something (in a production build without
assertions)
Havoc
More information about the dbus
mailing list