Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Compiler warnings when using Clang on FreeBSD 10.0 #426

Closed
ThomasHabets opened this issue Oct 10, 2014 · 1 comment
Closed

Compiler warnings when using Clang on FreeBSD 10.0 #426

ThomasHabets opened this issue Oct 10, 2014 · 1 comment

Comments

@ThomasHabets
Copy link
Contributor

Original issue 427 created by rsimmons0 on 2014-08-26T16:12:51.000Z:

What steps will reproduce the problem?
Download current revision 1d0bf2e
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 1d0bf2e 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant