Skip to content
  • Thomas Haller's avatar
    device: use NM_UTILS_STRING_LOOKUP_TABLE() for reason_to_string() · 0a6cca94
    Thomas Haller authored
    Showcase for the new macros NM_UTILS_STRING_LOOKUP_TABLE() and
    NM_UTILS_STRING_LOOKUP_TABLE_DEFINE_STATIC().
    
    It changes behavior in case of looking up an invalid/unknown
    state reason. Previously it would just have returned "unknown"
    -- which was indistinguishable from a regular "unknown" value.
    
    Now it returns the numeric id as a string. The string is allocated
    with alloca(), which is desired but one should be aware of the pitfalls:
    
    - prevents the caller from being inlined
    - bad idea to do in a loop.
    0a6cca94