[flashrom] [PATCH 2/4] Refactor PCI and USB device status printing.
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Wed Dec 26 21:04:41 CET 2012
Am 26.12.2012 20:44 schrieb Stefan Tauner:
> On Wed, 26 Dec 2012 20:32:35 +0100
> Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net> wrote:
>
>> Can't you simply handle USB/PCI/OTHER without switch()? After all,
>> devs.pci, devs.usb and devs.note are in a union and you can't detect
>> bugs like .type=USB combined with .devs.note="foobar" anyway. The only
>> special case is the internal programmer. Suggestion:
>>
>> switch(p.type) {
>> case USB:
>> case PCI:
>> case OTHER:
>> /* This is a union, check only one member. */
>> if (p.devs.note == NULL) {
>> if (strcmp("internal", p.name) == 0)
>> break; /* This one has its device list stored separately. */
>> msg_gerr("Programmer %s has neither a device list nor a textual
>> description!\n", p.name);
>> ret = 1;
>> break;
>> default:
>> ...
> that's certainly possible. the rationale for my code (besides its
> development while hacking around and refining) is:
> the detailed messages could help the programmer writer better than a
> generic message that catches all.
> the question is if that is worth it...
I don't think it's worth it. My suggested error message is not optimal,
though. It may have been misunderstood as "please add a device list or
textual description, your choice" which would be clearly wrong. What about
"Programmer %s has no device list/textual description of the right type!\n"
Regards,
Carl-Daniel
--
http://www.hailfinger.org/
More information about the flashrom
mailing list