[blivet:master 09/21] Simplify NoDevFS.type.

Anne Mulhern amulhern at redhat.com
Tue Jan 20 20:12:15 UTC 2015





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Tuesday, January 20, 2015 1:32:39 PM
> Subject: Re: [blivet:master 09/21] Simplify NoDevFS.type.
> 
> On 01/15/2015 12:39 PM, mulhern wrote:
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> >   blivet/formats/fs.py | 5 +----
> >   1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
> > index 6fede96..158b7c4 100644
> > --- a/blivet/formats/fs.py
> > +++ b/blivet/formats/fs.py
> > @@ -1494,10 +1494,7 @@ class NoDevFS(FS):
> >
> >       @property
> >       def type(self):
> > -        if self.device != self._type:
> > -            return self.device
> > -        else:
> > -            return self._type
> > +        return self.device
> >
> >       @property
> >       def mountType(self):
> >
> 
> Please make sure this does not cause issues with special naming of nodev
> devices in blivet.devicetree.getActiveMounts. You can test this by
> setting flags.include_nodev early in examples/list_devices.py.
> 
> David
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

We know that in the else branch, self.device == self._type, so,
if the only thing we're interested in is the value, it doesn't
matter which is returned on that branch. Returning self.device is simpler
and clearer.

If there was a plan to mutate the returned object, then which was returned would
matter. But that would be wrong, and the returned objects are strings,
which are immutable, so it should be safe.

- mulhern


More information about the anaconda-patches mailing list