[1/4] cmd: Avoid checking handle type when already known in WCMD_ReadFile

Dan Kegel dank at kegel.com
Tue Oct 4 06:45:36 CDT 2011


2011/10/4 Frédéric Delanoy <frederic.delanoy at gmail.com>:
> Well I thought about that, but found it a bit overkill for such a
> limited set of possible values.
> Also, if I used sthg like
>
> enum CMD_HANDLE_TYPE {
>   CMD_HT_FILE = 0,
>   CMD_HT_CONSOLE = 1,
>   CMD_HT_UNKNOWN = 2
> }
>
> , I'd have to add error checking for unknown parameters passed to
> WCMD_ReadFile, or never check for CMD_HT_UNKNOWN, and just use it as
> default value.
> So TBH I don't think an enum is really necessary (especially since
> it's just a corner case; all "similar" functions use a BOOL
> is_console_handle, covering cases 0 and 1. I wouldn't want to change
> those)

It's not overkill, and you don't have to add error checking, the
compiler will or should do that as long as you make all
the types that enum.

Really, the annoying part is the magic opencoded constants.
Those will set off alarm bells in anyone reviewing the code.



More information about the wine-devel mailing list