use recommended switch with default case to catch invalid values
Details
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 69959 Build 66842: arc lint + arc unit
Event Timeline
I'm not sure I'm convinced that dir is actually always set, but I haven't spent that much time reading the above logic. An assertion on that here might be good to try and do something useful instead of infinitely looping, but I don't insist
this uses saner code variant for change just done recently
When you do that, you want to use a Fixes: <shorthash> (title) line at the bottom of the commit message, that way the commits stay together for all the interesting things that can happen with branches or downstream.
i tried to read too, seems like it has error checks for not set conditions
but,
while (stream && fdir != DIR_NONE && !err && !feof(stdin));
then?
| usr.sbin/spi/spi.c | ||
|---|---|---|
| 367–368 | note - assert doesn't always get compiled in. It's only compiled in with -DDEBUG. I recommend handling it in a case statement with a default: switch (fdir) { <foo> break; case DIR_WRITE: <foo> break; case DIR_READWRITE: <foo> break; default: fprintf(stderr, "Invalid state (%d)\n", fdir); err = EINVAL; break; } That way you handle all of the valid ones and capture any other states. | |