libnm: use macros function arguments for NMSettInfoPropertType
These functions tend to have many arguments. They are also quite som boilerplate to implement the hundereds of properties we have, while we want that properties have common behaviors and similarities. Instead of repeatedly spelling out the function arguments, use a macro. Advantages: - the usage of a _NM_SETT_INFO_PROP_*_FCN_ARGS macro signals that this is an implementation of a property. You can now grep for these macros to find all implementation. That was previously rather imprecise, you could only `git grep '\.to_dbus_fcn'` to find the uses, but not the implementations. As the goal is to keep properties "similar", there is a desire to reduce the number of similar implementations and to find them. - changing the arguments now no longer will require you to go through all implementations. At least not, if you merely add an argument that has a reasonable default behavior and does not require explicit handling by most implementation. - it's convenient to be able to patch the argument list to let the compiler help to reason about something. For example, the "connection_dict" argument to from_dbus_fcn() is usually unused. If you'd like to find who uses it, rename the parameter, and review the (few) compiler errors. - it does save 573 LOC of boilerplate with no actual logic or useful information. I argue, that this simplifies the code and review, by increasing the relative amount of actually meaningful code. Disadvantages: - the user no longer directly sees the argument list. They would need cscope/ctags or an IDE to jump to the macro definition and conveniently see all arguments. Also use _nm_nil, so that clang-format interprets this as a function parameter list. Otherwise, it formats the function differently.
This commit is contained in:
@@ -1315,13 +1315,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
||||
}
|
||||
|
||||
static NMTernary
|
||||
compare_fcn_vlans(const NMSettInfoSetting * sett_info,
|
||||
const NMSettInfoProperty *property_info,
|
||||
NMConnection * con_a,
|
||||
NMSetting * set_a,
|
||||
NMConnection * con_b,
|
||||
NMSetting * set_b,
|
||||
NMSettingCompareFlags flags)
|
||||
compare_fcn_vlans(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil)
|
||||
{
|
||||
if (set_b) {
|
||||
return _nm_utils_bridge_compare_vlans(NM_SETTING_BRIDGE_GET_PRIVATE(set_a)->vlans,
|
||||
|
Reference in New Issue
Block a user