After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768521 - [review] cleanup NMRDisc [th/rdisc-cleanup-bgo768521]
[review] cleanup NMRDisc [th/rdisc-cleanup-bgo768521]
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2016-07-07 13:47 UTC by Thomas Haller
Modified: 2016-07-08 10:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Haller 2016-07-07 13:47:25 UTC
please review
Comment 1 Lubomir Rintel 2016-07-07 14:59:05 UTC
Looks like a very nice improvement in general.

> d040aebf rdisc: emit config-changed signal by ID and not by name

The move of the (changed) conditionals seems to harm readability; I'd prefer if 
you didn't do that (fine with using the signal names though).

+static void
+_emit_config_change (NMRDisc *self, NMRDiscConfigMap changed)
+{
+       if (changed)
+               g_signal_emit (self, signals[CONFIG_CHANGED], 0, (int) changed);
+}

-       if (changed)
-               g_signal_emit_by_name (rdisc, NM_RDISC_CONFIG_CHANGED, NM_RDISC_CONFIG_ADDRESSES);
+       _emit_config_change (rdisc, NM_RDISC_CONFIG_ADDRESSES);

Here it even changes behavior; and using a numeric value of a NMRDiscConfigMap 
in a conditional looks like a poor style to me.

> 69eedf44 rdisc: hide internal fields from NMRDisc API

Honestly, this looks worse to me with the NMRDiscData split off :(
Comment 2 Thomas Haller 2016-07-07 15:20:26 UTC
(In reply to Lubomir Rintel from comment #1)
> Looks like a very nice improvement in general.
> 
> > d040aebf rdisc: emit config-changed signal by ID and not by name
> 
> The move of the (changed) conditionals seems to harm readability; I'd prefer
> if 
> you didn't do that (fine with using the signal names though).
> 
> +static void
> +_emit_config_change (NMRDisc *self, NMRDiscConfigMap changed)
> +{
> +       if (changed)
> +               g_signal_emit (self, signals[CONFIG_CHANGED], 0, (int)
> changed);
> +}
> 
> -       if (changed)
> -               g_signal_emit_by_name (rdisc, NM_RDISC_CONFIG_CHANGED,
> NM_RDISC_CONFIG_ADDRESSES);
> +       _emit_config_change (rdisc, NM_RDISC_CONFIG_ADDRESSES);
> 
> Here it even changes behavior; and using a numeric value of a
> NMRDiscConfigMap 
> in a conditional looks like a poor style to me.
> 
> > 69eedf44 rdisc: hide internal fields from NMRDisc API

Yeah, this was wrong. Fixed.


> Honestly, this looks worse to me with the NMRDiscData split off :(

The idea is, that the RA data is not part of NMRDisc instead, instead it is separate data: the NMRDiscData argument in the "config-changed" signal.

Also, NMRDiscData is immuable and presented to the user of the API in a cleaner way (with proper C types).

Also, subclass NMLndpRDisc can access NMRDiscDataInternal (defined in nm-rdisc-private.h). Thus, the mutable data is hidden and only accessible from within rdisc implementation.


The overhead of this is:
 - 130 LOC
   - note that test-rdisc-fake.c alone grew by 30 lines, because it has
     more assertions.
   - I gained some line by the "guint changed_int" change.
 - one additional call to _data_complete().
Comment 3 Beniamino Galvani 2016-07-08 09:52:25 UTC
> disc: move public fields from NMRDisc to NMRDiscPrivate

+const char *
+nm_rdisc_get_ifname (NMRDisc *self)
+{
+       g_return_val_if_fail (NM_IS_RDISC (self), 0);

Nitpick:
g_return_val_if_fail (NM_IS_RDISC (self), NULL);


LGTM