Skip to content
  • Thomas Haller's avatar
    shared: don't allow aliases re-numbering in _nm_utils_enum_from_str_full() · 84a6eff1
    Thomas Haller authored
    For _nm_utils_enum_to_str_full(), we always first look whether we have
    an alias/nick for the numeric value, and preferably use that. That makes a
    lot of sense, as it allows the caller to provide better names (aliases),
    which are preferred over the name from the GLib type. It renames the
    numeric value.
    
    For the reverse conversion, this makes less sense. A name should have a
    unique numeric value. That is, we should not use one name that maps to
    a different numeric value based on value_infos and GLib type. IOW, we
    should not re-number names.
    
    Add an assertion that we don't provide such a value_infos parameter,
    that conflicts with names from GLib type.
    
    Also, although the case where GLib type and value_infos disagree is now
    forbidden by an assert, reorder the statements in _nm_utils_enum_from_str_full()
    too. There is no difference in practice, but it mirros what we do in the
    to-str case.
    84a6eff1