ehlo,
There were few warnings in bind-dyndb-ldap "duplicate 'const' declaration
specifier".
It does not make sense to have const twice in declaration
like a "const settings_set_t const settings_default_set"
This one was false positive.
The 2nd warning revealed potential problem.
const char const * dns_str
With previous declaration, you cannot modify data, but you can modify
pointer itself.
*dns_str = "asdasd" //compilation error
dns_str++ //works fine
If you want to disable modification data and disable modification of pointer
you will need to have 2nd const modifier after star "*"
You can find some examples of "const" usage in attached file test.c or
you can read article with explanation of next declaration
"char *(*(**foo [][8])())[];"
http://eli.thegreenplace.net/2008/07/18/reading-c-type-declarations/
Simple patch is attached.
LS
>From cd87f93f81e2d74506757b87117064eea6b3f282 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <[email protected]>
Date: Wed, 30 Oct 2013 08:52:59 +0100
Subject: [PATCH] Fix warning duplicate 'const' declaration specifier
It does not make sense to have const twice in declaration
like a "const settings_set_t const settings_default_set"
This one was false positive.
The 2nd warning revealed potential problem.
const char const * dns_str
With previous declaration, you cannot modify data, but you can modify
pointer itself.
*dns_str = "asdasd" //compilation error
dns_str++ //works fine
If you want to disable modification data and disable modification of pointer
you will need to have 2nd const modifier after star "*"
---
src/ldap_convert.c | 2 +-
src/ldap_helper.c | 2 +-
src/settings.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/ldap_convert.c b/src/ldap_convert.c
index
5b01b4db8e9cd9b88a8ade735ff82788808d0017..6493fddceb18c07f1ff25003b650df9aa5f62169
100644
--- a/src/ldap_convert.c
+++ b/src/ldap_convert.c
@@ -231,7 +231,7 @@ cleanup:
* will be checked & copied to the output buffer, without any additional
escaping.
*/
isc_result_t
-dns_to_ldap_dn_escape(isc_mem_t *mctx, const char const * dns_str, char **
ldap_name) {
+dns_to_ldap_dn_escape(isc_mem_t *mctx, const char * const dns_str, char **
ldap_name) {
isc_result_t result = ISC_R_FAILURE;
char * esc_name = NULL;
int idx_symb_first = -1; /* index of first "nice" printable symbol in
dns_str */
diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index
6a04d2b7da3977e3517fd7f449b7d218be6e1e93..38811d80e28e25e1c8ed90065301e71cbf0606e1
100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -234,7 +234,7 @@ struct ldap_psearchevent {
int chgtype;
};
-extern const settings_set_t const settings_default_set;
+extern const settings_set_t settings_default_set;
/** Local configuration file */
static const setting_t settings_local_default[] = {
diff --git a/src/settings.c b/src/settings.c
index
ceb525e5a949086a9486b4c70882f11c5ebe2030..ae5acf93a4f7fb442237400be275f00e0b9806c1
100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -80,7 +80,7 @@ static const setting_t settings_default[] = {
};
/** Settings set for built-in defaults. */
-const settings_set_t const settings_default_set = {
+const settings_set_t settings_default_set = {
NULL,
"built-in defaults",
NULL,
--
1.8.3.1
int main(void) {
int localVar=0;
// Example A
const int * ptr_to_const_data = &localVar;
// compilation will fail, try to uncomment
//*ptr_to_const_data = 1;
//test.c: error: assignment of read-only location ‘*ptr_to_const_data’
// *ptr_to_const_data = 1;
// incrementation of pointer work fine
ptr_to_const_data++;
// Example B
int const * ptr_to_data_const = &localVar;
// compilation will fail, try to uncomment
//*ptr_to_data_const = 2;
//test.c: error: assignment of read-only location ‘*ptr_to_data_const’
// *ptr_to_data_const = 2;
// incrementation of pointer work fine
ptr_to_data_const++;
// As you can see, there is no difference between example A and example B
// But you can try yourself with
const int const * ptr_to_const_data_const = &localVar;
// example C
int * const const_ptr_to_data = &localVar;
// modification to refered data is OK
*const_ptr_to_data = 3;
// cannot compile incrementation of pointer, try to uncomment
//const_ptr_to_data++;
//test.c: error: increment of read-only variable ‘const_ptr_to_data’
// const_ptr_to_data++;
//example D
int const * const const_ptr_to_const_data = &localVar;
// compilation will fail, try to uncomment
//*const_ptr_to_const_data = 4;
//test.c: error: assignment of read-only location ‘*const_ptr_to_const_data
// *const_ptr_to_const_data = 4;
// cannot compile incrementation of pointer, try to uncomment
//const_ptr_to_const_data++;
//test.c: error: increment of read-only variable ‘const_ptr_to_const_data’
// const_ptr_to_const_data++;
//example E
// situation is the same as in example D
const int * const const_ptr_to_data_const = &localVar;
return 0;
}
_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel