https://bugs.openldap.org/show_bug.cgi?id=9545

--- Comment #2 from Howard Chu <[email protected]> ---
(In reply to Simon Pichugin from comment #0)
> There are a few compile warnings that are present in OPENLDAP_REL_ENG_2_4
> libraries.
> 
> I understand that 2.4 is not in an active development state anymore but I
> think it's important to keep it as clean as possible as the libraries are
> actively used by other projects.
> 
> The warnings:
> 
>     tls2.c: In function ‘ldap_int_tls_connect’:
>     tls2.c:378:9: warning: implicit declaration of function
> ‘ldap_pvt_tls_check_hostname’ [-Wimplicit-function-declaration]
>       378 |   err = ldap_pvt_tls_check_hostname( ld, ssl, host );
>           |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>     thr_posix.c: In function ‘ldap_pvt_thread_set_concurrency’:
>     thr_posix.c:93:9: warning: implicit declaration of function
> ‘pthread_setconcurrency’ [-Wimplicit-function-declaration]
>        93 |  return pthread_setconcurrency( n );
>           |         ^~~~~~~~~~~~~~~~~~~~~~
>     thr_posix.c: In function ‘ldap_pvt_thread_get_concurrency’:
>     thr_posix.c:107:9: warning: implicit declaration of function
> ‘pthread_getconcurrency’; did you mean ‘ldap_pvt_thread_get_concurrency’?
> [-Wimplicit-function-declaration]
>       107 |  return pthread_getconcurrency();
>           |         ^~~~~~~~~~~~~~~~~~~~~~
>           |         ldap_pvt_thread_get_concurrency
>     charray.c: In function ‘ldap_charray2str’:
>     charray.c:269:3: warning: ‘strncpy’ specified bound depends on the
> length of the source argument [-Wstringop-overflow=]
>       269 |   strncpy( p, *v, len );
>           |   ^~~~~~~~~~~~~~~~~~~~~
>     charray.c:268:9: note: length computed here
>       268 |   len = strlen( *v );
>           |         ^~~~~~~~~~~~
> 
> Additional information:
> The 'implicit declaration' warnings can be potentially harmful.

But they clearly are not, in any of these cases.

> If the compiler does not see the declaration of a function _before_ it is
> called, it assumes the following implicit declaration instead:
> 
>     int fnc_name();
> 
> ... which has severe consequences:
> 
> 1. Only sizeof(int) bytes are read from the return value even if the
> function returns a different type.

These functions return int, so this is irrelevant.

> 2. Count and type of the arguments passed to the functions are not checked
> at all because the compiler has no means to know what the callee expects as
> parameters.

The getconcurrency/setconcurrency functions take none or one int argument,
so again this is irrelevant. Note that we have already included <pthread.h>
correctly, which is where these functions are declared. If you're getting
these warnings that generally means your compiler environment is incorrect.

In any case, none of these warnings indicate any bug in OpenLDAP code.
The ldap_pvt_tls_check_hostname prototype has been added in 2.5 to silence
the warning but code is correct regardless.

-- 
You are receiving this mail because:
You are on the CC list for the issue.

Reply via email to