[ovs-dev] [PATCH] lib: Fix compiler warnings on x86_64
Ethan Jackson
ethan at nicira.com
Sun Dec 26 23:23:33 UTC 2010
This patch resolves some compiler warnings which can occur on 64bit
systems.
---
lib/multipath.c | 8 ++++++--
lib/ofp-parse.c | 2 ++
lib/ovsdb-data.c | 4 ++--
lib/ovsdb-types.c | 14 +++++++-------
lib/ovsdb-types.h | 4 ++--
lib/stream-ssl.c | 2 +-
6 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/lib/multipath.c b/lib/multipath.c
index 7d4b541..e0e54ce 100644
--- a/lib/multipath.c
+++ b/lib/multipath.c
@@ -17,6 +17,7 @@
#include <config.h>
#include "multipath.h"
+#include <arpa/inet.h>
#include <inttypes.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -267,7 +268,10 @@ multipath_format(const struct nx_action_multipath *mp, struct ds *s)
{
const char *fields, *algorithm;
- switch ((enum nx_mp_fields) ntohs(mp->fields)) {
+ uint16_t mp_fields = ntohs(mp->fields);
+ uint16_t mp_algorithm = ntohs(mp->algorithm);
+
+ switch ((enum nx_mp_fields) mp_fields) {
case NX_MP_FIELDS_ETH_SRC:
fields = "eth_src";
break;
@@ -278,7 +282,7 @@ multipath_format(const struct nx_action_multipath *mp, struct ds *s)
fields = "<unknown>";
}
- switch ((enum nx_mp_algorithm) ntohs(mp->algorithm)) {
+ switch ((enum nx_mp_algorithm) mp_algorithm) {
case NX_MP_ALG_MODULO_N:
algorithm = "modulo_n";
break;
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index e30c8a9..f8464b9 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -200,6 +200,7 @@ str_to_action(char *str, struct ofpbuf *b)
char *pos;
pos = str;
+ n_actions = 0;
for (;;) {
char *act, *arg;
size_t actlen;
@@ -414,6 +415,7 @@ str_to_action(char *str, struct ofpbuf *b)
} else {
ovs_fatal(0, "Unknown action: %s", act);
}
+ n_actions++;
}
}
diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
index 492da7f..9738cfa 100644
--- a/lib/ovsdb-data.c
+++ b/lib/ovsdb-data.c
@@ -646,12 +646,12 @@ check_string_constraints(const char *s,
return ovsdb_error(
"constraint violation",
"\"%s\" length %zu is less than minimum allowed "
- "length %u", s, n_chars, c->minLen);
+ "length %llu", s, n_chars, c->minLen);
} else if (n_chars > c->maxLen) {
return ovsdb_error(
"constraint violation",
"\"%s\" length %zu is greater than maximum allowed "
- "length %u", s, n_chars, c->maxLen);
+ "length %llu", s, n_chars, c->maxLen);
}
return NULL;
diff --git a/lib/ovsdb-types.c b/lib/ovsdb-types.c
index b3452dd..3d1781c 100644
--- a/lib/ovsdb-types.c
+++ b/lib/ovsdb-types.c
@@ -312,14 +312,14 @@ ovsdb_base_type_clear_constraints(struct ovsdb_base_type *base)
}
static struct ovsdb_error *
-parse_optional_uint(struct ovsdb_parser *parser, const char *member,
- unsigned int *uint)
+parse_optional_ullint(struct ovsdb_parser *parser, const char *member,
+ unsigned long long *uint)
{
const struct json *json;
json = ovsdb_parser_member(parser, member, OP_INTEGER | OP_OPTIONAL);
if (json) {
- if (json->u.integer < 0 || json->u.integer > UINT_MAX) {
+ if (json->u.integer < 0 || json->u.integer > ULLONG_MAX) {
return ovsdb_syntax_error(json, NULL,
"%s out of valid range 0 to %u",
member, UINT_MAX);
@@ -395,12 +395,12 @@ ovsdb_base_type_from_json(struct ovsdb_base_type *base,
}
} else if (base->type == OVSDB_TYPE_STRING) {
if (!error) {
- error = parse_optional_uint(&parser, "minLength",
- &base->u.string.minLen);
+ error = parse_optional_ullint(&parser, "minLength",
+ &base->u.string.minLen);
}
if (!error) {
- error = parse_optional_uint(&parser, "maxLength",
- &base->u.string.maxLen);
+ error = parse_optional_ullint(&parser, "maxLength",
+ &base->u.string.maxLen);
}
if (!error && base->u.string.minLen > base->u.string.maxLen) {
error = ovsdb_syntax_error(json, NULL,
diff --git a/lib/ovsdb-types.h b/lib/ovsdb-types.h
index 6903aa8..7f492b0 100644
--- a/lib/ovsdb-types.h
+++ b/lib/ovsdb-types.h
@@ -70,8 +70,8 @@ struct ovsdb_base_type {
/* No constraints for Boolean types. */
struct ovsdb_string_constraints {
- unsigned int minLen; /* minLength or 0. */
- unsigned int maxLen; /* maxLength or UINT_MAX. */
+ unsigned long long minLen; /* minLength or 0. */
+ unsigned long long maxLen; /* maxLength or ULLONG_MAX. */
} string;
struct ovsdb_uuid_constraints {
diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c
index 1fc7446..7bdaf51 100644
--- a/lib/stream-ssl.c
+++ b/lib/stream-ssl.c
@@ -1291,7 +1291,7 @@ stream_ssl_set_ca_cert_file__(const char *file_name, bool bootstrap)
for (i = 0; i < n_certs; i++) {
/* SSL_CTX_add_client_CA makes a copy of the relevant data. */
if (SSL_CTX_add_client_CA(ctx, certs[i]) != 1) {
- VLOG_ERR("failed to add client certificate %d from %s: %s",
+ VLOG_ERR("failed to add client certificate %Zu from %s: %s",
i, file_name,
ERR_error_string(ERR_get_error(), NULL));
} else {
--
1.7.2.3
More information about the dev
mailing list