#6 reserved identifier violation

closed-rejected
nobody
None
5
2011-01-04
2010-12-27
No

I suggest to try the search pattern "\<_(?:(?:_(.*))|([A-Z]+))" on source files. A couple of places will be found where names begin with two underscores or an underscore and an uppercase letter.

Examples:
- _BIOS_equipment_flags_str
- _VCPI_installation_check
http://sourceforge.net/projects/gujin/files/gujin/2.8.3/gujin-2.8.3.tar.gz/download

This does not fit to the expected naming conventions of the C language standard.
https://www.securecoding.cert.org/confluence/display/seccode/DCL37-C.+Do+not+use+identifiers+that+are+reserved+for+the+implementation

Discussion

  • Etienne LORRAIN

    Etienne LORRAIN - 2010-12-30

    First, thanks for being interested in Gujin.
    I have read somewhere that double underscore are reserved for the compiler internal symbols, and single underscore are reserved for libraries/low level drivers.
    Gujin has its own low level drivers, it cannot load any libraries whatsoever (because any library would be compiled for protected mode), so "Trying to define a reserved identifier can result in its name conflicting with that used in implementation" has no real meaning in that case.
    Anyway I will try to check all those, symbols with underscore should only appear in really low level code - preferably be hidden only in inline functions in include files.

     
  • Markus Elfring

    Markus Elfring - 2010-12-30

    How do you think about the wording in the article "DCL37-C" and in the section "7.1.3 Reserved identifiers".
    http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf

    Would you like to use your project name as a known prefix?

    How do you think about to append an UUID as a suffix to make your include guards unique?

     
  • Etienne LORRAIN

    Etienne LORRAIN - 2011-01-04
    • status: open --> closed-rejected
     
  • Etienne LORRAIN

    Etienne LORRAIN - 2011-01-04

    1- Your regex do not work for me.
    2- the command:
    $ grep "__[A-Z]" *.[ch] | grep -v __FUNCTION__ | grep -v __LINE__ | grep -v __a
    ttribute__ | grep -v __GNUC__ | grep -v __ELF__ | grep -v __VERSION__ | grep -v __VA_ARGS__
    only returns __ERROR() as something defined by Gujin with double underscore,
    I do not consider that as a major problem.
    3- There are quite a lot of single underscore names, but most are for very low level assembler magic and direct BIOS calls - i.e. they are there exactly to tell that the "service" is not a straitforward call and should be really understood before being used.
    4- The Gujin project files cannot be used in another project (which other project runs in real mode and calls the BIOS directly anyway?), and I can myself manage 24 include files without resorting to UUID suffixes.
    5- Gujin's include guards do not begin with underscore.