[Freeipa-devel] [PATCH] detect failure to write ipa_kpasswd.pid file

Simo Sorce ssorce at redhat.com
Thu May 15 15:56:30 UTC 2008


On Thu, 2008-05-15 at 17:28 +0200, Jim Meyering wrote:
> Simo Sorce <ssorce at redhat.com> wrote:
> ...
> >> I have the opposite preference.
> >> I prefer to avoid the added line (more code fits on a screen/page),
> >> and to avoid the duplicate use of the variable name (one fewer detail
> >> that can get out of sync).
> >
> > I hate it when debugging like I hate things like:
> > if ((xyz = abc(def(foo))) == bar) { ...
> > it makes debugging unnecessarily harder.
> 
> When xyz is a short name, sometimes I too prefer to avoid the
> assignment-in-condition.  Performing the assignment as a separate
> statement makes it obvious that there is an actual assignment:
> 
>     xyz = abc(def(foo));
>     if (xyz == bar) { ...
> 
> However, when the assignment LHS is long enough to require
> significant visual work to confirm that it is the same one
> being tested on the next line, then I much prefer to avoid
> the duplication.  I.e., I find this hard to read/maintain:
> 
>     kset->keys[i].ekey->value.bv_val = malloc(len+2);
>     if (!kset->keys[i].ekey->value.bv_val) { ...
> 
> and prefer the code where I don't have to visually match long
> strings (too easy to miss details like s/i/j/ or s/ekey/akey/):
> 
>     if ((kset->keys[i].ekey->value.bv_val = malloc(len+2)) != NULL) { ...
> 
> I.e., obscuring the assignment hinders readability,
> but it's worth doing in cases like this.
> 
> > But this is a matter of personal choice I guess.
> 
> It's a balancing act.

yes but it depends on what you balance for.
I tend to balance for debuggability in gdb, which asks for code to be
split in lines so that you can easily set break points.

Also I tend to use tools like cscope/ctags/etc... and colorized editors
so that readability even of long variables is not a big problem usually.

Anyway, whom writes the code get to decide, as this specific detail is
not covered by our coding style guide.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York




More information about the Freeipa-devel mailing list