New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve C standard compliance. #96

Merged
merged 1 commit into from Sep 6, 2016

Conversation

Projects
None yet
5 participants
@iphydf
Member

iphydf commented Sep 5, 2016

  • Don't cast between object and function pointers.
  • Use standard compliant __VA_ARGS__ in macros.
  • Add explicit __extension__ on unnamed union in struct (it's a GNU
    extension).
  • Remove ; after function definitions.
  • Replace const T foo = 3; for integral types T with enum { foo = 3 };.
    Folding integral constants like that as compile time constants is a GNU
    extension. Arrays allocated with foo as dimension are VLAs on strictly
    compliant C99 compilers.
  • Replace empty initialiser list {} with zero-initialiser-list {0}.
    The former is a GNU extension meaning the latter.
  • Cast T* (where T != void) to void * in format arguments. While any
    object pointer can be implicitly converted to and from void *, this
    conversion does not happen in variadic function calls.
  • Replace arithmetic on void * with arithmetic on char *. The former
    is non-compliant.
  • Replace non-int-derived types (like uint16_t, which is
    short-derived) in bit fields with int-derived types. Using any type
    other than int or unsigned int (or any of their aliases) in bit
    fields is a GNU extension.

This change is Reviewable

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Sep 5, 2016

Member

Reviewed 13 of 13 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

Member

nurupo commented Sep 5, 2016

Reviewed 13 of 13 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Sep 5, 2016

Member

:lgtm_strong:


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

Member

nurupo commented Sep 5, 2016

:lgtm_strong:


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@JFreegman

This comment has been minimized.

Show comment
Hide comment
@JFreegman

JFreegman Sep 6, 2016

Member

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

Member

JFreegman commented Sep 6, 2016

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

@iphydf iphydf unassigned tux3 Sep 6, 2016

@GrayHatter

This comment has been minimized.

Show comment
Hide comment
@GrayHatter

GrayHatter Sep 6, 2016

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

GrayHatter commented Sep 6, 2016

:lgtm_strong:


Reviewed 12 of 13 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

Improve C standard compliance.
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
  extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
  Folding integral constants like that as compile time constants is a GNU
  extension. Arrays allocated with `foo` as dimension are VLAs on strictly
  compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
  The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
  object pointer can be implicitly converted to and from `void *`, this
  conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
  is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
  `short`-derived) in bit fields with `int`-derived types. Using any type
  other than `int` or `unsigned int` (or any of their aliases) in bit
  fields is a GNU extension.

@iphydf iphydf closed this Sep 6, 2016

@iphydf iphydf merged commit 5b57ab6 into TokTok:master Sep 6, 2016

3 checks passed

code-review/reviewable 3/3 LGTMs
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.03%) to 72.573%
Details

@iphydf iphydf deleted the iphydf:compliance branch Sep 6, 2016

@iphydf iphydf modified the milestone: v0.0.1 Nov 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment