Am 26.12.2012 20:44 schrieb Stefan Tauner: > On Wed, 26 Dec 2012 20:32:35 +0100 > Carl-Daniel Hailfinger <[email protected]> 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/ _______________________________________________ flashrom mailing list [email protected] http://www.flashrom.org/mailman/listinfo/flashrom
