google / google/google-authenticator-libpam
Compiler warnings when using Clang on FreeBSD 10.0
- Dominant language
- C
- Stars
- 2k
- Forks
- 305
- PR merge metrics
- No merged PRs in 30d
Description
_From @ThomasHabets on October 10, 2014 8:7_
Original [issue 427](https://code.google.com/p/google-authenticator/issues/detail?id=427) created by rsimmons0 on 2014-08-26T16:12:51.000Z:
What steps will reproduce the problem?
Download current revision 1d0bf2e6cff7
Build libpam on FreeBSD 10.0
What is the expected output? What do you see instead?
No warnings expected. The warnings in question are below.
What version of the product are you using? On what operating system?
revision 1d0bf2e6cff7 on FreeBSD 10.0-RELEASE-p7
Please provide any additional information below.
cc --std=gnu99 -Wall -O2 -g -fPIC -c -fvisibility=hidden -O2 -pipe -fno-strict-aliasing -o pam_google_authenticator.o pam_google_authenticator.c
pam_google_authenticator.c:777:49: warning: initializing 'char _' with an expression of type 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
.msg = prompt };
^~~~~~
pam_google_authenticator.c:973:44: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
~~~~~~^~~~~~~~~~~~
pam_google_authenticator.c:973:44: note: use array indexing to silence this warning
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
^
& [ ]
pam_google_authenticator.c:1132:48: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(reset, '\000'), " %d%+d" + !_reset, tms[i], skews[i]);
~~~~~~~~~^~~~~~~~~
pam_google_authenticator.c:1132:48: note: use array indexing to silence this warning
sprintf(strrchr(reset, '\000'), " %d%+d" + !*reset, tms[i], skews[i]);
^
& [ ]
3 warnings generated.
cc --std=gnu99 -Wall -O2 -g -fPIC -c -fvisibility=hidden -O2 -pipe -fno-strict-aliasing -o demo.o demo.c
demo.c:88:37: warning: 'memcpy' call operates on objects of type 'const char _' while the size is based on a different type 'const char *_'
[-Wsizeof-pointer-memaccess]
memcpy(item, &service, sizeof(&service));
~~~~~~~~ ^~~~~~~~
demo.c:88:37: note: did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?
memcpy(item, &service, sizeof(&service));
^~~~~~~~
demo.c:93:34: warning: 'memcpy' call operates on objects of type 'char _' while the size is based on a different type 'char *_'
[-Wsizeof-pointer-memaccess]
memcpy(item, &user, sizeof(&user));
~~~~~ ^~~~~
demo.c:93:34: note: did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?
memcpy(item, &user, sizeof(&user));
^~~~~
2 warnings generated.
cc -DDEMO --std=gnu99 -Wall -O2 -g -fPIC -c -fvisibility=hidden -O2 -pipe -fno-strict-aliasing -o pam_google_authenticator_demo.o pam_google_authenticator.c
pam_google_authenticator.c:777:49: warning: initializing 'char _' with an expression of type 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
.msg = prompt };
^~~~~~
pam_google_authenticator.c:973:44: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
~~~~~~^~~~~~~~~~~~
pam_google_authenticator.c:973:44: note: use array indexing to silence this warning
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
^
& [ ]
pam_google_authenticator.c:1132:48: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(reset, '\000'), " %d%+d" + !_reset, tms[i], skews[i]);
~~~~~~~~~^~~~~~~~~
pam_google_authenticator.c:1132:48: note: use array indexing to silence this warning
sprintf(strrchr(reset, '\000'), " %d%+d" + !*reset, tms[i], skews[i]);
^
& [ ]
3 warnings generated.
cc -DTESTING --std=gnu99 -Wall -O2 -g -fPIC -c -fvisibility=hidden -O2 -pipe -fno-strict-aliasing \
-o pam_google_authenticator_testing.o pam_google_authenticator.c
pam_google_authenticator.c:777:49: warning: initializing 'char _' with an expression of type 'const char *' discards qualifiers
[-Wincompatible-pointer-types-discards-qualifiers]
.msg = prompt };
^~~~~~
pam_google_authenticator.c:973:44: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
~~~~~~^~~~~~~~~~~~
pam_google_authenticator.c:973:44: note: use array indexing to silence this warning
sprintf(strrchr(disallow, '\000'), " %d" + !_disallow, tm);
^
& [ ]
pam_google_authenticator.c:1132:48: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
sprintf(strrchr(reset, '\000'), " %d%+d" + !_reset, tms[i], skews[i]);
~~~~~~~~~^~~~~~~~~
pam_google_authenticator.c:1132:48: note: use array indexing to silence this warning
sprintf(strrchr(reset, '\000'), " %d%+d" + !*reset, tms[i], skews[i]);
^
& [ ]
3 warnings generated.
cc --std=gnu99 -Wall -O2 -g -fPIC -c -fvisibility=hidden -O2 -pipe -fno-strict-aliasing -o pam_google_authenticator_unittest.o pam_google_authenticator_unittest.c
pam_google_authenticator_unittest.c:79:37: warning: 'memcpy' call operates on objects of type 'const char _' while the size is based on a different
type 'const char *_' [-Wsizeof-pointer-memaccess]
memcpy(item, &service, sizeof(&service));
~~~~~~~~ ^~~~~~~~
pam_google_authenticator_unittest.c:79:37: note: did you mean to remove the addressof in the argument to 'sizeof'
(and multiply it by the number of elements)?
memcpy(item, &service, sizeof(&service));
^~~~~~~~
pam_google_authenticator_unittest.c:84:34: warning: 'memcpy' call operates on objects of type 'char _' while the size is based on a different type
'char *_' [-Wsizeof-pointer-memaccess]
memcpy(item, &user, sizeof(&user));
~~~~~ ^~~~~
pam_google_authenticator_unittest.c:84:34: note: did you mean to remove the addressof in the argument to 'sizeof'
(and multiply it by the number of elements)?
memcpy(item, &user, sizeof(&user));
^~~~~
2 warnings generated.
_Copied from original issue: google/google-authenticator#426_
Contributor guide
Assessment
This issue has not been assessed yet.