[flashrom] [PATCH] C99 cleanliness

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Sun Aug 26 02:35:01 CEST 2012

i looked into this again (mainly from a linux perspective), here is what
i have found out:

following functions are not in c99:
 - strdup (posix, all over the place, easily replaceable)
 - getpagesize (alternatives:
 - strcasecmp, strncasecmp (posix)
 - popen/pclose (posix, will be gone with internal dmi decoder)
 - usleep (posix, and even there deprecated!)
 - gethostbyname et al (posix, serprog only)
   also, struct hostent->h_addr should be h_addr_list[0]
 - fileno (posix, used in flashrom.c)

the termios flag CRTSCTS is not specified in c or posix (bsd, used in
serial.c's sp_openserport)

and then there is the __asm__ __volatile__ thingy.

not too bad imho.
it gets worse with -pedantic of course...
 - unnamed unions (which became part of c11)
 - empty struct initializers ({}, mostly fixed by using {0} although
   gcc and clang continue to warn if there are substructs. this would
   lead to things like {{{{{0}}}}} in some cases and that's just not
   worth it.)
 - 0-sized arrays (coreboot_tables.h, wtf?)
 - lots of: pointer of type ‘void *’ used in arithmetic (mmio

i have fixed the h_addr and __asm__ __volatile__ problem and also
replaced all empty struct initializers with {0} as this is the standard
0/NULL initializer (as discussed in the -p internal:mainboard= thread
IIRC) in my tested_stuff branch.
Kind regards/Mit freundlichen Grüßen, Stefan Tauner

More information about the flashrom mailing list