Skip to content
  • Philip Withnall's avatar
    gmessages: Fix -Wformat warnings for g_message() and friends · 32cc60db
    Philip Withnall authored
    
    
    When compiling with G_LOG_USE_STRUCTURED, g_message(), g_debug(), etc.
    use g_log_structured(). The message format string and its format
    arguments are passed as the final set of arguments in a longer varargs
    list, which includes the log domain and level (and other) fields.
    Passing the message format in this way means it’s not possible for the
    compiler to know to check its format placeholders when compiling with
    -Wformat.
    
    Fix support for this by adding a new semi-private helper function,
    _g_log_structured_standard(), which only uses varargs for the message
    format and its arguments, and uses fixed arguments for the other fields.
    This is then converted to a set of GLogFields and passed to
    g_log_structured() as normal.
    
    Support for -Wformat when compiling *without* G_LOG_USE_STRUCTURED was
    never broken.
    
    Signed-off-by: default avatarPhilip Withnall <withnall@endlessm.com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793074
    32cc60db