Skip to content
  • David Zeuthen's avatar
    GDBusMessage: Assert various things when serializing to a blob · 6e723e8b
    David Zeuthen authored
    We use g_assert() instead of setting the GError because it is a
    programming error if the GVariant contains invalid data - see commit
    5e6f762d for where the last hole in
    GVariant was closed.
    
    So if we can trust GVariant to only contain valid data (ignoring the
    case where unsafe API such as g_variant_new_from_data() is used), why
    g_assert() at all with costly g_utf8_validate() checks? Because a) it
    is relatively inexpensive; and b) it helps find bugs such as the one
    fixed in commit 5e6f762d
    
    .
    
    If performance is a concern we can play games like introducing
    environment variables or other machinery to avoid such "costly"
    checks. I doubt it will ever be an issue.
    
    Also replace two "Hmm" TODO item with a static assert - the code that
    serializes a gdouble into the D-Bus wire format by treating it as a
    guint64 is indeed correct - endianess needs to be taken into account
    (see the D-Bus reference implementation for similar code). But we want
    to make sure that we're indeed using an architecture/compiler where a
    gdouble takes up 8 bytes - hence the assertion.
    
    Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
    6e723e8b