summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/syntaxes
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2009-05-19 13:17:11 -0600
committerRich Megginson <rmeggins@redhat.com>2009-05-19 14:05:25 -0600
commitf9db3ac14855eb07e49f2f5797cbb7d338bb614b (patch)
tree4bc8d8283ba975ed2decaa664615548081866679 /ldap/servers/plugins/syntaxes
parent47a59378cbf4b48eef492530ebc1c8ea6059a757 (diff)
downloadds-f9db3ac14855eb07e49f2f5797cbb7d338bb614b.tar.gz
ds-f9db3ac14855eb07e49f2f5797cbb7d338bb614b.tar.xz
ds-f9db3ac14855eb07e49f2f5797cbb7d338bb614b.zip
Fix various compiler warnings
1) Make sure we use "const" consistently 2) Make sure we use "unsigned char" consistently for some reason (unsigned char)*p did not compare to '\xHH' literals unless the literal was also cast to (unsigned char) 3) added some missing function prototypes 4) removed some unused variables/functions, or commented out for use when debugging 5) various other compiler warnings With all of these, the code compiles cleanly on RHEL5 x86_64 using gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44) and CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic" The only warning now is the spurious message about %llu or %lld having the wrong format argument. Reviewed by: nhosoi (Thanks!)
Diffstat (limited to 'ldap/servers/plugins/syntaxes')
-rw-r--r--ldap/servers/plugins/syntaxes/cis.c4
-rw-r--r--ldap/servers/plugins/syntaxes/dn.c18
-rw-r--r--ldap/servers/plugins/syntaxes/phonetic.c6
-rw-r--r--ldap/servers/plugins/syntaxes/syntax.h18
-rw-r--r--ldap/servers/plugins/syntaxes/validate.c36
-rw-r--r--ldap/servers/plugins/syntaxes/validate_task.c2
6 files changed, 41 insertions, 43 deletions
diff --git a/ldap/servers/plugins/syntaxes/cis.c b/ldap/servers/plugins/syntaxes/cis.c
index f20ae5eb..4f1d9d71 100644
--- a/ldap/servers/plugins/syntaxes/cis.c
+++ b/ldap/servers/plugins/syntaxes/cis.c
@@ -730,7 +730,7 @@ static int postal_validate(
if (*p == '\\') {
p++;
/* ensure that we're not at the end of the value */
- if ((p > end) || (strncmp(p, "24", 2) != 0) && (strncasecmp(p, "5C", 2) != 0)) {
+ if ((p > end) || ((strncmp(p, "24", 2) != 0) && (strncasecmp(p, "5C", 2) != 0))) {
rc = 1;
goto exit;
} else {
@@ -776,7 +776,7 @@ static int oid_validate(
{
int rc = 0; /* assume the value is valid */
const char *p = NULL;
- char *end = NULL;
+ const char *end = NULL;
/* Per RFC4512:
*
diff --git a/ldap/servers/plugins/syntaxes/dn.c b/ldap/servers/plugins/syntaxes/dn.c
index 80a3f8bf..ab6b254d 100644
--- a/ldap/servers/plugins/syntaxes/dn.c
+++ b/ldap/servers/plugins/syntaxes/dn.c
@@ -58,7 +58,7 @@ static int dn_assertion2keys_ava( Slapi_PBlock *pb, Slapi_Value *val,
static int dn_assertion2keys_sub( Slapi_PBlock *pb, char *initial, char **any,
char *final, Slapi_Value ***ivals );
static int dn_validate( struct berval *val );
-static int rdn_validate( char *begin, char *end, char **last );
+static int rdn_validate( const char *begin, const char *end, const char **last );
/* the first name is the official one from RFC 2252 */
static char *names[] = { "DN", DN_SYNTAX_OID, 0 };
@@ -156,9 +156,9 @@ static int dn_validate( struct berval *val )
*/
if (val->bv_len > 0) {
int strict = 0;
- char *p = val->bv_val;
- char *end = &(val->bv_val[val->bv_len - 1]);
- char *last = NULL;
+ const char *p = val->bv_val;
+ const char *end = &(val->bv_val[val->bv_len - 1]);
+ const char *last = NULL;
/* Check if we should be performing strict validation. */
strict = config_get_dn_validate_strict();
@@ -168,7 +168,7 @@ static int dn_validate( struct berval *val )
* stored in the backend unmodified. */
val_copy = PL_strndup(val->bv_val, val->bv_len);
p = val_copy;
- end = slapi_dn_normalize_to_end(p, NULL) - 1;
+ end = slapi_dn_normalize_to_end(val_copy, NULL) - 1;
}
/* Validate one RDN at a time in a loop. */
@@ -212,12 +212,12 @@ exit:
* will be set in the "last parameter. This will be the end of the RDN
* in the valid case, and the illegal character in the invalid case.
*/
-static int rdn_validate( char *begin, char *end, char **last )
+static int rdn_validate( const char *begin, const char *end, const char **last )
{
int rc = 0; /* Assume RDN is valid */
int numericform = 0;
char *separator = NULL;
- char *p = begin;
+ const char *p = begin;
/* Find the '=', then use the helpers for descr and numericoid */
if ((separator = PL_strnchr(p, '=', end - begin + 1)) == NULL) {
@@ -228,13 +228,13 @@ static int rdn_validate( char *begin, char *end, char **last )
/* Process an attribute type. The 'descr'
* form must start with a 'leadkeychar'. */
if (IS_LEADKEYCHAR(*p)) {
- if (rc = keystring_validate(p, separator - 1)) {
+ if ((rc = keystring_validate(p, separator - 1))) {
goto exit;
}
/* See if the 'numericoid' form is being used */
} else if (isdigit(*p)) {
numericform = 1;
- if (rc = numericoid_validate(p, separator - 1)) {
+ if ((rc = numericoid_validate(p, separator - 1))) {
goto exit;
}
} else {
diff --git a/ldap/servers/plugins/syntaxes/phonetic.c b/ldap/servers/plugins/syntaxes/phonetic.c
index f8f8e023..dd9e8304 100644
--- a/ldap/servers/plugins/syntaxes/phonetic.c
+++ b/ldap/servers/plugins/syntaxes/phonetic.c
@@ -249,9 +249,9 @@ static char vsvfn[26] = {
char *
phonetic( char *Word )
{
- unsigned char *n, *n_start, *n_end; /* pointers to string */
+ unsigned char *n_start, *n, *n_end; /* pointers to string */
char *metaph_end; /* pointers to metaph */
- char ntrans[42]; /* word with uppercase letters */
+ unsigned char ntrans[42]; /* word with uppercase letters */
int KSflag; /* state flag for X -> KS */
char buf[MAXPHONEMELEN + 2];
char *Metaph;
@@ -268,7 +268,7 @@ phonetic( char *Word )
}
++Word;
} else {
- auto const size_t len = LDAP_UTF8COPY(n, Word);
+ auto const size_t len = LDAP_UTF8COPY((char *)n, Word);
n += len; Word += len;
}
}
diff --git a/ldap/servers/plugins/syntaxes/syntax.h b/ldap/servers/plugins/syntaxes/syntax.h
index b9a01370..e673718f 100644
--- a/ldap/servers/plugins/syntaxes/syntax.h
+++ b/ldap/servers/plugins/syntaxes/syntax.h
@@ -75,13 +75,13 @@
#define IS_LDIGIT(c) ( (c != '0') && isdigit(c) )
#define IS_SHARP(c) ( (c == '#') )
#define IS_ESC(c) ( (c == '\\') )
-#define IS_UTF0(c) ( (c >= '\x80') && (c <= '\xBF') )
-#define IS_UTF1(c) ( !(c & 128) )
+#define IS_UTF0(c) ( ((unsigned char)(c) >= (unsigned char)'\x80') && ((unsigned char)(c) <= (unsigned char)'\xBF') )
+#define IS_UTF1(c) ( !((unsigned char)(c) & 128) )
/* These are only checking the first byte of the multibyte character. They
* do not verify that the entire multibyte character is correct. */
-#define IS_UTF2(c) ( (c >= '\xC2') && (c <= '\xDF') )
-#define IS_UTF3(c) ( (c >= '\xE0') && (c <= '\xEF') )
-#define IS_UTF4(c) ( (c >= '\xF0') && (c <= '\xF4') )
+#define IS_UTF2(c) ( ((unsigned char)(c) >= (unsigned char)'\xC2') && ((unsigned char)(c) <= (unsigned char)'\xDF') )
+#define IS_UTF3(c) ( ((unsigned char)(c) >= (unsigned char)'\xE0') && ((unsigned char)(c) <= (unsigned char)'\xEF') )
+#define IS_UTF4(c) ( ((unsigned char)(c) >= (unsigned char)'\xF0') && ((unsigned char)(c) <= (unsigned char)'\xF4') )
#define IS_UTFMB(c) ( IS_UTF2(c) || IS_UTF3(c) || IS_UTF4(c) )
#define IS_UTF8(c) ( IS_UTF1(c) || IS_UTFMB(c) )
@@ -119,9 +119,9 @@ char *next_word( char *s );
char *phonetic( char *s );
/* Validation helper functions */
-int keystring_validate( char *begin, char *end );
-int numericoid_validate( char *begin, char *end );
-int utf8char_validate( char *begin, char *end, char **last );
-int utf8string_validate( char *begin, char *end, char **last );
+int keystring_validate( const char *begin, const char *end );
+int numericoid_validate( const char *begin, const char *end );
+int utf8char_validate( const char *begin, const char *end, const char **last );
+int utf8string_validate( const char *begin, const char *end, const char **last );
#endif
diff --git a/ldap/servers/plugins/syntaxes/validate.c b/ldap/servers/plugins/syntaxes/validate.c
index 8367e083..a34830cd 100644
--- a/ldap/servers/plugins/syntaxes/validate.c
+++ b/ldap/servers/plugins/syntaxes/validate.c
@@ -52,8 +52,8 @@
* Returns non-zero if the value is not a valide 'keystring'.
*/
int keystring_validate(
- char *begin,
- char *end
+ const char *begin,
+ const char *end
)
{
int rc = 0; /* assume the value is valid */
@@ -90,13 +90,13 @@ exit:
* Returns non-zero if the value is not a valide 'numericoid'.
*/
int numericoid_validate(
- char *begin,
- char *end
+ const char *begin,
+ const char *end
)
{
int rc = 0; /* assume the value is valid */
int found_separator = 0;
- char *p = NULL;
+ const char *p = NULL;
if ((begin == NULL) || (end == NULL)) {
rc = 1;
@@ -181,13 +181,13 @@ exit:
*
* Returns 0 if it is valid and non-zero otherwise. */
int utf8char_validate(
- char *begin,
- char *end,
- char **last
+ const char *begin,
+ const char *end,
+ const char **last
)
{
int rc = 0; /* Assume char is valid */
- char *p = begin;
+ const char *p = begin;
if ((begin == NULL) || (end == NULL)) {
rc = 1;
@@ -233,14 +233,14 @@ int utf8char_validate(
if (*p == '\xE0') {
/* The next byte must be %xA0-BF. */
p++;
- if ((*p < '\xA0') || (*p > '\xBF')) {
+ if (((unsigned char)*p < (unsigned char)'\xA0') || ((unsigned char)*p > (unsigned char)'\xBF')) {
rc = 1;
goto exit;
}
} else if (*p == '\xED') {
/* The next byte must be %x80-9F. */
p++;
- if ((*p < '\x80') || (*p > '\x9F')) {
+ if (((unsigned char)*p < (unsigned char)'\x80') || ((unsigned char)*p > (unsigned char)'\x9F')) {
rc = 1;
goto exit;
}
@@ -270,13 +270,13 @@ int utf8char_validate(
* the second byte. */
if (*p == '\xF0') {
/* The next byte must be %x90-BF. */
- if ((*p < '\x90') || (*p > '\xBF')) {
+ if (((unsigned char)*p < (unsigned char)'\x90') || ((unsigned char)*p > (unsigned char)'\xBF')) {
rc = 1;
goto exit;
}
} else if (*p == '\xF4') {
/* The next byte must be %x80-BF. */
- if ((*p < '\x80') || (*p > '\xBF')) {
+ if (((unsigned char)*p < (unsigned char)'\x80') || ((unsigned char)*p > (unsigned char)'\xBF')) {
rc = 1;
goto exit;
}
@@ -307,7 +307,7 @@ int utf8char_validate(
exit:
if (last) {
- *last = p;
+ *last = (const char *)p;
}
return(rc);
}
@@ -321,13 +321,13 @@ exit:
*
* Returns 0 if it is valid and non-zero otherwise. */
int utf8string_validate(
- char *begin,
- char *end,
- char **last
+ const char *begin,
+ const char *end,
+ const char **last
)
{
int rc = 0; /* Assume string is valid */
- char *p = NULL;
+ const char *p = NULL;
if ((begin == NULL) || (end == NULL)) {
rc = 1;
diff --git a/ldap/servers/plugins/syntaxes/validate_task.c b/ldap/servers/plugins/syntaxes/validate_task.c
index d469ccd6..38c35218 100644
--- a/ldap/servers/plugins/syntaxes/validate_task.c
+++ b/ldap/servers/plugins/syntaxes/validate_task.c
@@ -49,8 +49,6 @@
/*
* Globals
*/
-static Slapi_PluginDesc pdesc = { "syntax-validate-task", PLUGIN_MAGIC_VENDOR_STR,
- PRODUCTTEXT, "syntax validation task plugin" };
static void* _PluginID = NULL;