libftdi Archives

Subject: Re: [PATCH] -FT230X: Readout, decode and encode the RS232 inverson configuration bits.

From: Rogier Wolff <R.E.Wolff@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 8 Sep 2014 17:30:20 +0200
On Mon, Sep 08, 2014 at 04:57:50PM +0200, Thomas Jarosch wrote:
> On Tuesday, 2. September 2014 13:50:32 Uwe Bonnes wrote:
> >     Thomas> any comment on Roger's comment? Any plans to update your
> > patch? Reworked patch appended, using array for the strings, but not
> > extra function.

My question is: Why NOT the extra function? Performance? Is this a
critical path? Is it called very often? I don't think so. 

I think it's much more likely that a "bunch of names for bitfields"
need printing elsewhere, so that the function would be reused. 

Now, if someone finds himself needing to print a bunch of names for
bitfields, he'll look for an example, and find your "using array for
the string, but not the extra function" code, and copy that. This is
the easiest way out.

This started with

  if (bitfield & 1) printf ("someflag");

which got copied around. That was the easiest (least thinking-work
required) solution. 


So I'd say: 
 ALWAYS create a separate function. 
   except: 
      if the code is NEVER going to be called from somewhere else
    and
      the code is more readable with the function "inline"

An exception can be made for a performance critical piece of code
where inlining through a compiler directive is ineffective.

> Applied, thanks Uwe! I've slightly tweaked the commit message.

I don't have the time right now to rework it as I think it should be
done. :-( 

I hope to be able to influence your programming styles for the future,
and "fixing" this can be done "when convenient"... (if you're
convinced by my arguments... :-) )

        Roger. 

-- 
** R.E.Wolff@xxxxxxxxxxxx ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread