[U-Boot] [RFC 2/2] env: Add prefix to error messages when loading env

Wolfgang Denk
2018-07-19T19:49:01Z

Dear Tom,

In message <20180719125230.GJ4609@bill-the-cat> you wrote:
>
> > > > Loading Environment from FAT... MMC: no card present
> > > > ** Bad device mmc 0 **
> > > > Failed (-5)
> > > > Loading Environment from MMC... OK
...
> > In the non-error case, the output should be a single (ideally short)
> > line.
> >
> > Rationale: to many lines of ourput clutter your screen and make you
> > miss context faster; to many/long lines take time to print so they
> > make booting slower.
> >
> > In the error case, the user should be able to understand what the
> > problem was and decide if it was critical or can be ignored (like
> > here when intentionally booting without SDCard).
>
> I understand, but I don't know if we can get there still. The problem
> is we don't know if we've succeeded until we've done the relevant
> probing and that in turn is what's breaking the single line, and got us
> to where we are now.

Well, IMO the approach should be the other way round - think about
where we print errror messages, and when.

In the example above the "MMC: no card present" makes most sense.

When we come to printing the "** Bad device mmc 0 **" we should be
in an error path, where all possible causes have already printed an
appropriate message, so this line can be removed.

Ditto for the "Failed (-5)" which is pretty useless anyway - if
error handling was consequent, this message should never be needed,
as all error paths ending there would have printed proper messages
long before.

So instead of adding prefixes or fancy postformatting we should
clean up error handling and use a consistent style to report the
errors where they are found and the causes for the errors are known.

Thanks.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Die meisten Menschen pflegen im Kindesalter vom Zeigen auf Gegenstän-
de (Mausbewegung) und "ga" sagen (Mausklick) abzukommen, zugunsten
eines mächtigeren und langwierig zu erlernenden Tools (Sprache).
-- Achim Linder in de.comp.os.linux.misc