const-correctness in interface
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libmemcached |
Fix Released
|
Undecided
|
Trond Norbye |
Bug Description
All the function declarations that contain this:
(... const char **keys, size_t *key_length, ...)
should be:
(... const char * const *keys, const size_t *key_length, ...)
(and the man pages fixed). The way the interfaces are declared in 0.33, this, e.g:
char **keys /* to be alloc'd and filled in */;
size_t *len /* same */;
rc = memcached_
results in the following error from GCC 4.x: "invalid conversion from 'char**' to 'const char**'". Legacy code that was written to the API prior to the introduction of the const qualifiers (< 0.21?) therefore does not build with the newer API (and newer GCC). An explicit (const char **) cast of the keys argument is required, as is done throughout the libmemcached code with calls to memcached_
You can grep for 'const char \*\*' to find all the places that need the added const qualifiers. WIth the correct const qualifiers the explicit casts on the memcached_
The changes do not alter the regression test results.
Related branches
- Libmemcached-developers: Pending requested
-
Diff: 1024 lines12 files modifieddocs/Makefile.am (+8/-0)
docs/memcached_get.pod (+39/-3)
libmemcached/common.h (+2/-1)
libmemcached/memcached.h (+1/-0)
libmemcached/memcached_connect.c (+19/-21)
libmemcached/memcached_fetch.c (+1/-1)
libmemcached/memcached_get.c (+99/-73)
libmemcached/memcached_get.h (+25/-6)
libmemcached/memcached_io.c (+109/-20)
libmemcached/memcached_key.c (+2/-3)
libmemcached/memcached_types.h (+9/-3)
tests/function.c (+174/-0)
Changed in libmemcached: | |
status: | Confirmed → Fix Released |
I'm all for any const correctness fixes.
Fred Richards wrote: mget(stptr, keys, len, count); key_test( ). key_test( ) argument that will no longer be
> Public bug reported:
>
> All the function declarations that contain this:
>
> (... const char **keys, size_t *key_length, ...)
>
> should be:
>
> (... const char * const *keys, const size_t *key_length, ...)
>
> (and the man pages fixed). The way the interfaces are declared in 0.33,
> this, e.g:
>
> char **keys /* to be alloc'd and filled in */;
> size_t *len /* same */;
>
> rc = memcached_
>
> results in the following error from GCC 4.x: "invalid conversion from
> 'char**' to 'const char**'". Legacy code that was written to the API
> prior to the introduction of the const qualifiers (< 0.21?) therefore
> does not build with the newer API (and newer GCC). An explicit (const
> char **) cast of the keys argument is required, as is done throughout
> the libmemcached code with calls to memcached_
>
> You can grep for 'const char \*\*' to find all the places that need the
> added const qualifiers. WIth the correct const qualifiers the explicit
> casts on the memcached_
> necessary.
>
> The changes do not alter the regression test results.
>
> ** Affects: libmemcached
> Importance: Undecided
> Status: New
>