diff mbox

[v2,1/3] Fix -Wtautological-compare warnings with clang

Message ID alpine.BSF.2.00.1212091205060.64779@toaster.local (mailing list archive)
State Accepted
Delegated to: Alex Netes
Headers show

Commit Message

Garrett Cooper Dec. 9, 2012, 8:14 p.m. UTC
From 1f91aeca2d9fecd1301d6fe2731a79d8640b2072 Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yanegomi@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 <yanegomi@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(-)

Comments

Alex Netes Jan. 30, 2013, 5:49 p.m. UTC | #1
Hi Garret,

On 12:14 Sun 09 Dec     , Garrett Cooper wrote:
> From 1f91aeca2d9fecd1301d6fe2731a79d8640b2072 Mon Sep 17 00:00:00 2001
> From: Garrett Cooper <yanegomi@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 <yanegomi@gmail.com>
> ---

Applied the series. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Garrett Cooper Jan. 31, 2013, 1:25 a.m. UTC | #2
On Jan 30, 2013, at 9:49 AM, Alex Netes <alexne@mellanox.com> wrote:

> Hi Garret,
> 
> On 12:14 Sun 09 Dec     , Garrett Cooper wrote:
>> From 1f91aeca2d9fecd1301d6fe2731a79d8640b2072 Mon Sep 17 00:00:00 2001
>> From: Garrett Cooper <yanegomi@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 <yanegomi@gmail.com>
>> ---
> 
> Applied the series. Thanks.

Thanks!
-Garrett
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;