Setting properties to "" or removing them

David Zeuthen david at fubar.dk
Fri Apr 30 12:29:58 PDT 2004


On Fri, 2004-04-30 at 20:26, Joe Shaw wrote:
> Hey,
> 
> I wanted to set some convention for empty properties in the daemon.  I
> came across some code which sets block.mount_point and block.fstype to
> "" when a filesystem is unmounted.  Do we want to do this or remove the
> property altogether.  I'd lean toward removing it, that way you don't
> have to check whether a property is NULL or "", but on the flip side you
> do need to check if it's NULL before doing something like strcmp().  
> 

I think it's sane to set properties to "" instead of the property not
being present. The exception would be stuff like storage.cdrom.* is only
present iff storage.cdrom==TRUE. 

So a general rule of thumb would be the following: if a property on one
depth-level is present, so should the other properties even though they
may have empty values. Values that can assume NULL (in a database sense,
e.g. it doesn't make sense to talk about the cdrom-writespeed on a
harddisk) should be placed in a sub-level just like storage.cdrom.*.

This should be documented in the spec - I'll get around to updating that
document in the near future for 0.3.0.

Cheers,
David

_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list