From 1f91aeca2d9fecd1301d6fe2731a79d8640b2072 Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yaneg...@gmail.com>
Date: Sun, 9 Dec 2012 02:44:32 -0800
Subject: [PATCH 1/3] Fix -Wtautological-compare warnings with clang

V1:

The noted branch conditions are true or false and hence not
tested/executed as designed.

Prune the always true/false conditional checks.

V2:

Fix the conditional check in osm_vendor_new by properly checking for
IB_SUCCESS instead of assuming that values < 0 denotes error as this
isn't possible given the enum definition.

Signed-off-by: Garrett Cooper <yaneg...@gmail.com>
---
 libvendor/osm_vendor_ibumad.c | 2 +-
 opensm/osm_qos_parser_y.y     | 6 ++----
 opensm/st.c                   | 2 --
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index ca320a6..63b9594 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -574,7 +574,7 @@ osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,

        memset(p_vend, 0, sizeof(*p_vend));

-       if (osm_vendor_init(p_vend, p_log, timeout) < 0) {
+       if (osm_vendor_init(p_vend, p_log, timeout) != IB_SUCCESS) {
                free(p_vend);
                p_vend = NULL;
        }
diff --git a/opensm/osm_qos_parser_y.y b/opensm/osm_qos_parser_y.y
index 4e01ed4..0b567c8 100644
--- a/opensm/osm_qos_parser_y.y
+++ b/opensm/osm_qos_parser_y.y
@@ -1648,8 +1648,7 @@ sl2vl_scope_from_list_of_ranges: list_of_ranges {
                                 num_pair = 
(uint64_t*)cl_list_obj(list_iterator);
                                 if (num_pair)
                                 {
-                                    if ( num_pair[0] < 0 ||
-                                         num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+                                    if ( num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
                                     {
                                         yyerror("port number out of range 'from' 
list");
                                         free(num_pair);
@@ -1680,8 +1679,7 @@ sl2vl_scope_to_list_of_ranges: list_of_ranges {
                                 num_pair = 
(uint64_t*)cl_list_obj(list_iterator);
                                 if (num_pair)
                                 {
-                                    if ( num_pair[0] < 0 ||
-                                         num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+                                    if ( num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
                                     {
                                         yyerror("port number out of range 'to' 
list");
                                         free(num_pair);
diff --git a/opensm/st.c b/opensm/st.c
index 754648c..14db456 100644
--- a/opensm/st.c
+++ b/opensm/st.c
@@ -196,8 +196,6 @@ size_t size;
 #endif

        size = new_size(size);  /* round up to prime number */
-       if (size < 0)
-               return NULL;

        tbl = alloc(st_table);
        tbl->type = type;
--
1.8.0
From 1f91aeca2d9fecd1301d6fe2731a79d8640b2072 Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yaneg...@gmail.com>
Date: Sun, 9 Dec 2012 02:44:32 -0800
Subject: [PATCH v2 1/3] Fix -Wtautological-compare warnings with clang

V1:

The noted branch conditions are true or false and hence not
tested/executed as designed.

Prune the always true/false conditional checks.

V2:

Fix the conditional check in osm_vendor_new by properly checking for
IB_SUCCESS instead of assuming that values < 0 denotes error as this
isn't possible given the enum definition.

Signed-off-by: Garrett Cooper <yaneg...@gmail.com>
---
 libvendor/osm_vendor_ibumad.c | 2 +-
 opensm/osm_qos_parser_y.y     | 6 ++----
 opensm/st.c                   | 2 --
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/libvendor/osm_vendor_ibumad.c b/libvendor/osm_vendor_ibumad.c
index ca320a6..63b9594 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -574,7 +574,7 @@ osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
 
        memset(p_vend, 0, sizeof(*p_vend));
 
-       if (osm_vendor_init(p_vend, p_log, timeout) < 0) {
+       if (osm_vendor_init(p_vend, p_log, timeout) != IB_SUCCESS) {
                free(p_vend);
                p_vend = NULL;
        }
diff --git a/opensm/osm_qos_parser_y.y b/opensm/osm_qos_parser_y.y
index 4e01ed4..0b567c8 100644
--- a/opensm/osm_qos_parser_y.y
+++ b/opensm/osm_qos_parser_y.y
@@ -1648,8 +1648,7 @@ sl2vl_scope_from_list_of_ranges: list_of_ranges {
                                 num_pair = 
(uint64_t*)cl_list_obj(list_iterator);
                                 if (num_pair)
                                 {
-                                    if ( num_pair[0] < 0 ||
-                                         num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+                                    if ( num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
                                     {
                                         yyerror("port number out of range 
'from' list");
                                         free(num_pair);
@@ -1680,8 +1679,7 @@ sl2vl_scope_to_list_of_ranges: list_of_ranges {
                                 num_pair = 
(uint64_t*)cl_list_obj(list_iterator);
                                 if (num_pair)
                                 {
-                                    if ( num_pair[0] < 0 ||
-                                         num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+                                    if ( num_pair[1] >= 
OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
                                     {
                                         yyerror("port number out of range 'to' 
list");
                                         free(num_pair);
diff --git a/opensm/st.c b/opensm/st.c
index 754648c..14db456 100644
--- a/opensm/st.c
+++ b/opensm/st.c
@@ -196,8 +196,6 @@ size_t size;
 #endif
 
        size = new_size(size);  /* round up to prime number */
-       if (size < 0)
-               return NULL;
 
        tbl = alloc(st_table);
        tbl->type = type;
-- 
1.8.0

Reply via email to