[flashrom] [PATCH] Change programmer selection in cli and generic code
stefan.tauner at student.tuwien.ac.at
Tue Sep 6 10:23:11 CEST 2011
On Tue, 06 Sep 2011 02:20:31 +0200
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net> wrote:
> > should we also check against < 0? enums are based on int.
> Not sure about that:
> Are they really guaranteed to be signed int? If not, some compilers will
> warn about "comparison always yields false".
18.104.22.168 Enumeration specifiers
"The expression that defines the value of an enumeration constant shall
be an integer constant expression that has a value representable as an int."
but that does only restrict the "input" type of the "initializers".
the really important part is paragraph 4:
"Each enumerated type shall be compatible with char, a signed integer
type, or an unsigned integer type. The choice of type is
implementation-defined, but shall be capable of representing the values
of all the members of the enumeration. The enumerated type is
incomplete until after the } that terminates the list of enumerator
so eventually this is another implementation-defined behavior, hurray.
gcc does this:
define a precondition for programmer_init that parameter prog must be
in the range defined by the enum and else the behavior is undefined,
and think of the > part of the check as a user-friendly bonus :)
a detailed description of what the functions exported by libflashrom do
is required anyway...
i am fine with the current implementation.
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
More information about the flashrom