On Wed, 26 Dec 2012 20:32:35 +0100 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@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...