[PATCH v6 08/23] modetest: Add a command line parameter to set properties

Ville Syrjälä ville.syrjala at linux.intel.com
Thu Jun 27 01:31:48 PDT 2013


On Thu, Jun 27, 2013 at 10:10:43AM +0200, Laurent Pinchart wrote:
> Hi Ville,
> 
> Thank you for the review.
> 
> On Monday 24 June 2013 18:08:37 Ville Syrjälä wrote:
> > On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote:
> > > The -w parameter can be used to set a property value from the command
> > > line, using the target object ID and the property name.
> > > 
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > > ---
> > > 
> > >  tests/modetest/modetest.c | 108 ++++++++++++++++++++++++++++++++++++++++-
> > >  1 file changed, 106 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> > > index 778af62..858d480 100644
> > > --- a/tests/modetest/modetest.c
> > > +++ b/tests/modetest/modetest.c
> > 
> > <snip>
> > 
> > > @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const
> > > char *arg)> 
> > >  	return 0;
> > >  
> > >  }
> > > 
> > > +static int parse_property(struct property_arg *p, const char *arg)
> > > +{
> > > +	if (sscanf(arg, "%d:%32[^:]:%" SCNu64, &p->obj_id, p->name, &p-
> >value)
> > > != 3)
> > nit: could use stringification to get rid of the magic number 32 here.
> 
> What do you mean exactly ?

Something like this:

#define str(x) #x
#define xstr(x) str(x)
sscanf(arg, "%d:%" xstr(DRM_PROP_NAME_LEN) "[^:]:%" SCNu64, ...

Although it does make it a bit hard to parse for a human.

-- 
Ville Syrjälä
Intel OTC


More information about the dri-devel mailing list