Skip to content

nm-meta-setting-desc: refactor and comment when get_gtype is disallowed

Íñigo Huguet requested to merge ih/enum-meta-desc into main

Summary

The get_gtype field in property_typ_data is intended to specify an enum type for properties that are really defined as (u)int in the NMSetting class. Specifying get_gtype for properties that are already defined as enum in the NMSetting class is rejected as a runtime error. However, the error message doesn't explain the reason. Put a code comment explaining the reason.

Explaining it in a comment is actually enough because:

  • The error is a runtime assertion that indicates a programming error
  • The assertion is checked any time that the property is read or written, so it should always be detected at developing time when doing changes to the property.

Anyway, the code that did this checks was very difficult to read, so let's take the opportunity to refactor it, with no functional changes.

Purpose

Help to understand the error if it arises and improve code readability.

Checklist

Please read https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/CONTRIBUTING.md before opening the merge request. In particular, check that:

  • the subject for all commits is concise and explicative
  • the message for all commits explains the reason for the change
  • the source is properly formatted
  • any relevant documentation is up to date
  • you have added unit tests if applicable
Edited by Íñigo Huguet

Merge request reports