Quoth Tom Whitten on Mon, Oct 13, 2008 at 10:23:35AM -0600:
> David Bustos writes:
> > Quoth Antonello Cruz on Fri, Oct 10, 2008 at 02:41:14PM -0700:
> > > >>>>>> lib/libscf/common/scf_tmpl.c
> > > >>>>>> 3479: Why isn't this SCF_ERROR_TEMPLATE_INVALID?
> > ...
> > > > Ok, sorry, I asked the wrong question.  I should have asked "Is there
> > > > a way to create a property template through the manifest which has an
> > > > SCF_PROPERTY_TM_TYPE with a single empty value?"  And then I think the
> > > > same decision process applies as for line 3972 above.
> > >
> > > David, you get an SCF_PROPERTY_TM_TYPE if the manifest has 
> > > <prop_pattern> with no type attribute.
> > 
> > Really?  I would think that svccfg import would only create an
> > SCF_PROPERTY_TM_TYPE property if prop_pattern *had* a type attribute.
> > Otherwise, where do you put the value of the type attribute when it's
> > present?
> 
> Unlike other properties, svccfg does create a property with an empty string
> for SCF_PROPERTY_TM_TYPE even if the manifest does not declare the
> prop_pattern type.  I can no longer remember why I coded
> SCF_PROPERTY_TM_TYPE this way.  It is a trivial code change to make
> SCF_PROPERTY_TM_TYPE act like all the other optional properties.

Oh, so svccfg import always creates SCF_PROPERTY_TM_TYPE, but if the
attribute was missing from the XML element, then it creates it with
a single empty value?  Ok, that's a good explanation for why we should
not return SCF_ERROR_TEMPLATE_INVALID when
_read_single_astring_from_pg() returns an empty string.

I would ask, though, whether it should return TEMPLATE_INVALID if the
property is missing altogether.  (Presumably when
_read_single_astring_from_pg() fails with SCF_ERROR_NOT_FOUND.)  And
whether it's legitimate for a developer to write a manifest which
specifies the empty string for the attribute.  (I presume it's not, and
svccfg import / validate catches that and fails?)

It's entirely possible that the code is correct as is, I just want to
understand the reasoning so I can verify that it's sound.


David

Reply via email to