Skip to content
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
Merged

Improve C standard compliance. #96

merged 1 commit into from Sep 6, 2016

Conversation

@iphydf
Copy link
Member

@iphydf 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

@iphydf iphydf force-pushed the iphydf:compliance branch 2 times, most recently from 9c870c5 to 6c74f12 Sep 5, 2016
@nurupo
Copy link
Member

@nurupo 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
Copy link
Member

@nurupo 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

@iphydf iphydf force-pushed the iphydf:compliance branch from 6c74f12 to 4116af7 Sep 5, 2016
@JFreegman
Copy link
Member

@JFreegman 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
Copy link

@GrayHatter 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

@iphydf iphydf force-pushed the iphydf:compliance branch from 4116af7 to 391a026 Sep 6, 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.
@iphydf iphydf force-pushed the iphydf:compliance branch from 391a026 to 5b57ab6 Sep 6, 2016
@iphydf iphydf closed this Sep 6, 2016
@iphydf iphydf merged commit 5b57ab6 into TokTok:master Sep 6, 2016
3 checks passed
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.