clang produces warnings, that gcc doesn't:
ldap/servers/plugins/acctpolicy/acct_util.c:224:30: warning: expression which evaluates to zero treated as a null pointer constant of type 'time_t *' (aka 'long *') [-Wnon-literal-null-conversion] cur_local_epochtime = time( (time_t)0 ); ^~~~~~~~~ 1 warning generated. ldap/servers/slapd/bind.c:921:27: warning: format specifies type 'long' but the argument has type 'ber_tag_t' (aka 'unsigned int') [-Wformat] method, version, msg ); ^~~~~~ ldap/servers/slapd/bind.c:927:27: warning: format specifies type 'long' but the argument has type 'ber_tag_t' (aka 'unsigned int') [-Wformat] method, version ); ^~~~~~ 2 warnings generated. ldap/servers/slapd/csngen.c:685:35: warning: absolute value function 'abs' given an argument of type 'time_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST)) ^ ldap/servers/slapd/csngen.c:685:35: note: use function 'labs' instead if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST)) ^~~ labs ldap/servers/slapd/csngen.c:689:30: warning: absolute value function 'abs' given an argument of type 'time_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] abs (time_diff), CSN_MAX_TIME_ADJUST); ^ ldap/servers/slapd/csngen.c:689:30: note: use function 'labs' instead abs (time_diff), CSN_MAX_TIME_ADJUST); ^~~ labs ldap/servers/slapd/csngen.c:694:69: warning: absolute value function 'abs' given an argument of type 'time_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] gen->state.local_offset = MAX_VAL (gen->state.local_offset, abs (time_diff)); ^ ldap/servers/slapd/csngen.c:26:31: note: expanded from macro 'MAX_VAL' #define MAX_VAL(x,y) ((x)>(y)?(x):(y)) ^ ldap/servers/slapd/csngen.c:694:69: note: use function 'labs' instead gen->state.local_offset = MAX_VAL (gen->state.local_offset, abs (time_diff)); ^~~ labs ldap/servers/slapd/csngen.c:26:31: note: expanded from macro 'MAX_VAL' #define MAX_VAL(x,y) ((x)>(y)?(x):(y)) ^ ldap/servers/slapd/csngen.c:694:69: warning: absolute value function 'abs' given an argument of type 'time_t' (aka 'long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] gen->state.local_offset = MAX_VAL (gen->state.local_offset, abs (time_diff)); ^ ldap/servers/slapd/csngen.c:26:39: note: expanded from macro 'MAX_VAL' #define MAX_VAL(x,y) ((x)>(y)?(x):(y)) ^ ldap/servers/slapd/csngen.c:694:69: note: use function 'labs' instead gen->state.local_offset = MAX_VAL (gen->state.local_offset, abs (time_diff)); ^~~ labs ldap/servers/slapd/csngen.c:26:39: note: expanded from macro 'MAX_VAL' #define MAX_VAL(x,y) ((x)>(y)?(x):(y)) ^ 4 warnings generated. ldap/servers/slapd/mapping_tree.c:2666:26: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] if ((target_node == mapping_tree_root) ){ ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ ldap/servers/slapd/mapping_tree.c:2666:26: note: remove extraneous parentheses around the comparison to silence this warning if ((target_node == mapping_tree_root) ){ ~ ^ ~ ldap/servers/slapd/mapping_tree.c:2666:26: note: use '=' to turn this equality comparison into an assignment if ((target_node == mapping_tree_root) ){ ^~ = 1 warning generated. ldap/servers/plugins/acl/acl.c:2927:18: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Wnon-literal-null-conversion] testRights[1] = '\0'; ^~~~ ldap/servers/plugins/acl/acl.c:4194:17: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Wnon-literal-null-conversion] testRight[1] = '\0'; ^~~~ ldap/servers/plugins/acl/acleffectiverights.c:1032:12: warning: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Wnon-literal-null-conversion] *errbuf = '\0'; ^~~~ 1 warning generated. 2 warnings generated.
Thanks for running clang and filing this ticket, Viktor.
I also would like to run clang myself. Could you please give me the instructions?
I've just installed clang on my laptop... Thanks!
clang can be used as a drop-in replacement for gcc, so I didn't mess with the autotools, but instead I created a symlink for gcc pointing to clang (not the best solution, yeah) {{{ ls -la /usr/bin/gcc lrwxrwxrwx. 1 root root 5 Apr 23 20:04 /usr/bin/gcc -> /usr/bin/clang }}} And then did the usual ./configure && make.
git patch file (master) 0001-Ticket-48802-Compilation-warnings-from-clang.patch
Thanks to Viktor for sharing the method. I could find more warnings which were hidden in the first run!
Reviewed by Mark (Thank you!!)
Pushed to master: fa620fc..6881e0a master -> master commit 6881e0a
Replying to [comment:3 vashirov]:
clang can be used as a drop-in replacement for gcc, so I didn't mess with the autotools, but instead I created a symlink for gcc pointing to clang (not the best solution, yeah) {{{ ls -la /usr/bin/gcc lrwxrwxrwx. 1 root root 5 Apr 23 20:04 /usr/bin/gcc -> /usr/bin/clang }}} And then did the usual ./configure && make. I would not recommend to do such changes.
Simpler way is to set compiler via environment variable e.g. {{{ CC=/usr/bin/clang ./configure && make or CC=/path/to/icc ./configure && make }}}
Metadata Update from @nhosoi: - Issue assigned to nhosoi - Issue set to the milestone: 1.3.5.1
389-ds-base is moving from Pagure to Github. This means that new issues and pull requests will be accepted only in 389-ds-base's github repository.
This issue has been cloned to Github and is available here: - https://github.com/389ds/389-ds-base/issues/1862
If you want to receive further updates on the issue, please navigate to the github issue and click on subscribe button.
subscribe
Thank you for understanding. We apologize for all inconvenience.
Metadata Update from @spichugi: - Issue close_status updated to: wontfix (was: Fixed)
Login to comment on this ticket.