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

Remove dependency on strings.h #481

Merged
merged 3 commits into from Mar 2, 2017

Conversation

Projects
None yet
4 participants
@nurupo
Member

nurupo commented Feb 20, 2017

strings.h is not available on MSVC.


This change is Reviewable

@nurupo nurupo added this to the v0.1.7 milestone Feb 20, 2017

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 20, 2017

Member

Looks like the -Werror makes the clang build on Travis fail because clang's ctype.h header triggers -Wdisabled-macro-expansion. gcc and mingw don't have such an issue.

/home/travis/build/TokTok/c-toxcore/testing/misc_tools.c:56:18: error: disabled expansion of recursive macro [-Werror,-Wdisabled-macro-expansion]
        int c1 = tolower(*(s1++));
                 ^
/usr/include/ctype.h:230:35: note: expanded from macro 'tolower'
#  define tolower(c)    __tobody (c, tolower, *__ctype_tolower_loc (), (c))
                                     ^
/usr/include/ctype.h:176:14: note: expanded from macro '__tobody'
            __res = f args;                                                   \
                    ^

@iphydf How should we deal with it, is disabling -Wdisabled-macro-expansion just for clang acceptable?

Member

nurupo commented Feb 20, 2017

Looks like the -Werror makes the clang build on Travis fail because clang's ctype.h header triggers -Wdisabled-macro-expansion. gcc and mingw don't have such an issue.

/home/travis/build/TokTok/c-toxcore/testing/misc_tools.c:56:18: error: disabled expansion of recursive macro [-Werror,-Wdisabled-macro-expansion]
        int c1 = tolower(*(s1++));
                 ^
/usr/include/ctype.h:230:35: note: expanded from macro 'tolower'
#  define tolower(c)    __tobody (c, tolower, *__ctype_tolower_loc (), (c))
                                     ^
/usr/include/ctype.h:176:14: note: expanded from macro '__tobody'
            __res = f args;                                                   \
                    ^

@iphydf How should we deal with it, is disabling -Wdisabled-macro-expansion just for clang acceptable?

@Diadlo

This comment has been minimized.

Show comment
Hide comment
@Diadlo

Diadlo Feb 20, 2017

Or we can write own tolower

Diadlo commented Feb 20, 2017

Or we can write own tolower

This was referenced Feb 20, 2017

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Feb 22, 2017

Member

Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


testing/misc_tools.c, line 53 at r1 (raw file):

}

int tox_strncasecmp(const char* s1, const char* s2, size_t n)

add a comment that this is implemented because strings.h is not available on MSVC.


Comments from Reviewable

Member

cebe commented Feb 22, 2017

Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


testing/misc_tools.c, line 53 at r1 (raw file):

}

int tox_strncasecmp(const char* s1, const char* s2, size_t n)

add a comment that this is implemented because strings.h is not available on MSVC.


Comments from Reviewable

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 22, 2017

Member

testing/misc_tools.c, line 53 at r1 (raw file):

Previously, cebe (Carsten Brandt) wrote…

add a comment that this is implemented because strings.h is not available on MSVC.

Added.


Comments from Reviewable

Member

nurupo commented Feb 22, 2017

testing/misc_tools.c, line 53 at r1 (raw file):

Previously, cebe (Carsten Brandt) wrote…

add a comment that this is implemented because strings.h is not available on MSVC.

Added.


Comments from Reviewable

@Diadlo

This comment has been minimized.

Show comment
Hide comment
@Diadlo

Diadlo Feb 22, 2017

Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

Diadlo commented Feb 22, 2017

Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Feb 22, 2017

Member

:lgtm:


Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

Member

cebe commented Feb 22, 2017

:lgtm:


Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@Diadlo

This comment has been minimized.

Show comment
Hide comment
@Diadlo

Diadlo Feb 22, 2017

@cebe Why do you lgtm, if current build is failed?

Diadlo commented Feb 22, 2017

@cebe Why do you lgtm, if current build is failed?

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Feb 23, 2017

Member

@Diadlo sorry I did not notice that, was looking at the code only.

Member

cebe commented Feb 23, 2017

@Diadlo sorry I did not notice that, was looking at the code only.

@cebe

This comment has been minimized.

Show comment
Hide comment
@cebe

cebe Feb 23, 2017

Member

:lgtm_cancel:


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


Comments from Reviewable

Member

cebe commented Feb 23, 2017

:lgtm_cancel:


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


Comments from Reviewable

@Diadlo

This comment has been minimized.

Show comment
Hide comment
@Diadlo

Diadlo Feb 24, 2017

Reviewed 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 99 at r4 (raw file):

    add_flag("-Wno-covered-switch-default")
    # Due to clang's tolower() macro being recursive https://github.com/TokTok/c-toxcore/pull/481
    add_flag("-Wno-disabled-macro-expansion")

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?


Comments from Reviewable

Diadlo commented Feb 24, 2017

Reviewed 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 99 at r4 (raw file):

    add_flag("-Wno-covered-switch-default")
    # Due to clang's tolower() macro being recursive https://github.com/TokTok/c-toxcore/pull/481
    add_flag("-Wno-disabled-macro-expansion")

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?


Comments from Reviewable

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 24, 2017

Member

CMakeLists.txt, line 99 at r4 (raw file):

Previously, Diadlo (Polshakov Dmitry) wrote…

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?

Do we really want this warning to be enabled in the first place?


Comments from Reviewable

Member

nurupo commented Feb 24, 2017

CMakeLists.txt, line 99 at r4 (raw file):

Previously, Diadlo (Polshakov Dmitry) wrote…

Maybe put inside if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")?

Do we really want this warning to be enabled in the first place?


Comments from Reviewable

@iphydf

This comment has been minimized.

Show comment
Hide comment
@iphydf

iphydf Feb 26, 2017

Member

:lgtm_strong: could you write a test for this function?


Reviewed 1 of 2 files at r1, 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

Member

iphydf commented Feb 26, 2017

:lgtm_strong: could you write a test for this function?


Reviewed 1 of 2 files at r1, 1 of 1 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 26, 2017

Member

Uh, sure, if you really want. I thought the function was trivial enough to verify that it does the right thing.

Hm, it's probably easier to just replace this function with an ifdef using strncasecmp() on POSIX systems and _strnicmp() on Windows rather than writing tests for it.

Member

nurupo commented Feb 26, 2017

Uh, sure, if you really want. I thought the function was trivial enough to verify that it does the right thing.

Hm, it's probably easier to just replace this function with an ifdef using strncasecmp() on POSIX systems and _strnicmp() on Windows rather than writing tests for it.

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 26, 2017

Member

Added the test. Hopefully the 20 minutes I have spent on it were worth it. Also, I ran out of wafers while writing it, thus the wafer test cases.

Member

nurupo commented Feb 26, 2017

Added the test. Hopefully the 20 minutes I have spent on it were worth it. Also, I ran out of wafers while writing it, thus the wafer test cases.

@iphydf

This comment has been minimized.

Show comment
Hide comment
@iphydf

iphydf Feb 27, 2017

Member

Thanks, looks good. Can you fix the typo and then rebase? I'll merge it after.

Member

iphydf commented Feb 27, 2017

Thanks, looks good. Can you fix the typo and then rebase? I'll merge it after.

@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Feb 27, 2017

Member

auto_tests/tox_strncasecmp_test.c, line 164 at r5 (raw file):

Previously, iphydf wrote…

s/mist/mis/

Done.


Comments from Reviewable

Member

nurupo commented Feb 27, 2017

auto_tests/tox_strncasecmp_test.c, line 164 at r5 (raw file):

Previously, iphydf wrote…

s/mist/mis/

Done.


Comments from Reviewable

@iphydf

This comment has been minimized.

Show comment
Hide comment
@iphydf

iphydf Mar 1, 2017

Member

Did I merge something after your rebase? I can't merge this, yet. Can you rebase (again)?

Member

iphydf commented Mar 1, 2017

Did I merge something after your rebase? I can't merge this, yet. Can you rebase (again)?

nurupo added some commits Feb 20, 2017

Disable -Wdisabled-macro-expansion
Due to clang's tolower() macro being recursive.
@nurupo

This comment has been minimized.

Show comment
Hide comment
@nurupo

nurupo Mar 2, 2017

Member

Rebased.

Member

nurupo commented Mar 2, 2017

Rebased.

@iphydf iphydf merged commit def92ab into TokTok:master Mar 2, 2017

3 of 4 checks passed

ci/circleci Your tests are queued behind your running builds
Details
code-review/reviewable 1/1 LGTMs
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment