https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810

--- Comment #21 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
(In reply to Lawrence Velázquez from comment #20)
> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01377.html

Quick review of the patch:

 - version_as_modern_macro(): you implement a specific behavior for major <= 9,
but it's necessary at all. Having major <= 9 is simply impossible (and Apple's
compiler rejects it). I'd say let's make things simpler anduse a format of
"%02lu%02lu%02lu" and always be 6 characters long.

 - version_as_legacy_macro(): same issue. Why do we need to handle major <= 9?
You have rejected this possibility in macosx_version_as_macro() anyway.
Simplify here also.

 - throughout the patch, writing things like "(int) sizeof "9999" - 1" or "char
result[sizeof "9999"]" when you could write "4" and "char result[4]" means
harder code to read, and no real benefit in terms of security or
maintainability (since you're duplicating stuff anyway).

 - in macosx_version_as_macro(), you say "Allow for future major numbers
greater than 10", but you actually reject them (and that's OK). Adjust the
comment.

 - later, "version_array[MAJOR] == 10" is guaranteed. Remove it.

 - in parse_version(), the string passed is guaranteed to be non-NULL. No need
to test it.

Reply via email to