Обсуждение: dead assignment src/bin/scripts/print.c line 421

Поиск
Список
Период
Сортировка

dead assignment src/bin/scripts/print.c line 421

От
Laurent Laborde
Дата:
Friendly greetings !

in file src/bin/scripts/print.c line 421 :
need_recordsep = false;
then set to true line 424.

Now i'm pretty sure it's a meaningless "bug" without any consequence (the commit that introduced it is 15 years old).

There is a lot of (apparently) dead assignment here and there but some assigment could be used for debugging purpose so ... why not. But this one ?

--
Laurent "ker2x" Laborde
DBA gandi.net \o/

Re: dead assignment src/bin/scripts/print.c line 421

От
Laurent Laborde
Дата:
Should have been sent to the bugs ML sorry :-/

On Mon, Jul 13, 2015 at 3:56 PM, Laurent Laborde <kerdezixe@gmail.com> wrote:
Friendly greetings !

in file src/bin/scripts/print.c line 421 :
need_recordsep = false;
then set to true line 424.

Now i'm pretty sure it's a meaningless "bug" without any consequence (the commit that introduced it is 15 years old).

There is a lot of (apparently) dead assignment here and there but some assigment could be used for debugging purpose so ... why not. But this one ?

--
Laurent "ker2x" Laborde
DBA gandi.net \o/



--
Laurent "ker2x" Laborde

Re: dead assignment src/bin/scripts/print.c line 421

От
Heikki Linnakangas
Дата:
On 07/13/2015 04:56 PM, Laurent Laborde wrote:
> Friendly greetings !
>
> in file src/bin/scripts/print.c line 421 :
> need_recordsep = false;
> then set to true line 424.
>
> Now i'm pretty sure it's a meaningless "bug" without any consequence (the
> commit that introduced it is 15 years old).
>
> There is a lot of (apparently) dead assignment here and there but some
> assigment could be used for debugging purpose so ... why not. But this one ?

The code in question looks like this:

> for (f = footers; f; f = f->next)
> {
>     if (need_recordsep)
>     {
>         print_separator(cont->opt->recordSep, fout);
>         need_recordsep = false;
>     }
>     fputs(f->data, fout);
>     need_recordsep = true;
> }

Hmm. It does kind of make sense. Right after printing the separator, you 
don't need to print a separator because you just printed one.  But as 
soon as you print the field, you need a separator again. It would be 
quite understandable without that dead assignment too, and that's 
probably how I would've written it in the first place. But since that's 
how it is and has been for 15 years, I'm inclined to just leave it so.

- Heikki