Skip to content
  • Dan Winship's avatar
    libnm-core: fix up connection deserialize/copy/replace semantics · ad8b1309
    Dan Winship authored
    libnm-util's connection deserializing/copying/replacing functions have
    odd semantics where sometimes they both modify a connection AND return
    an error. libnm-core tried to improve things by guaranteeing that the
    connection would not be modified if the new settings were invalid, but
    this ended up breaking a bunch of places that needed to be able to
    work with invalid connections. So re-fix the functions by reverting
    back to the old semantics, but having return values that clearly
    distinguish whether the connection was modified or not.
    
    For comparison:
    
      - nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():
    
          - libnm-util: returns a valid connection or NULL.
    
          - OLD libnm-core: returned a valid connection or NULL.
    
          - NEW libnm-core: returns a valid connection or NULL.
    
      - nm_connection_duplicate() / nm_simple_connection_new_clone():
    
          - libnm-util: always succeeds, whether or not the connection is
            valid.
    
          - OLD libnm-core: returned a valid connection or NULL
    
          - NEW libnm-core: always succeeds, whether or not the connection
            is valid.
    
        - nm_connection_replace_settings_from_connection():
    
          - libnm-util: always replaces the settings, but returns FALSE if
            the connection is now invalid.
    
          - OLD libnm-core: either replaced the settings and returned TRUE
            (if the settings were valid), or else left the connection
            unchanged and returned FALSE (if not).
    
          - NEW libnm-core: always replaces the settings, and has no
            return value. (The modified connection is valid if and only if
            the replaced-from connection was valid; just like with the
            libnm-util version.)
    
        - nm_connection_replace_settings():
    
          - libnm-util: returns TRUE if the new settings are valid, or
            FALSE if either (a) the new settings could not be deserialized
            and the connection is unchanged, or (b) the new settings were
            deserialized, and the connection was updated, but is now not
            valid.
    
          - OLD libnm-core: either replaced the settings and returned TRUE
            (if the settings were valid), or else left the connection
            unchanged and returned FALSE (if not).
    
          - NEW libnm-core: returns TRUE if the connection was updated
            (whether or not it is valid), or FALSE if the new settings
            could not be deserialized and the connection is unchanged.
    ad8b1309