diff mbox

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

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

Commit Message

Garrett Cooper Dec. 9, 2012, 11:05 a.m. UTC
These branch conditions are always > 0 (or false) and hence not executed
as designed.

Also, enum by definition is always > 0, so the error condition isn't
triggered ever.

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

Comments

Alex Netes Dec. 9, 2012, 5:09 p.m. UTC | #1
Hi Garrett,

> These branch conditions are always > 0 (or false) and hence not executed as
> designed.
> 
> Also, enum by definition is always > 0, so the error condition isn't triggered
> ever.
> 
> Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
> ---
>   libvendor/osm_vendor_ibumad.c | 5 +----
>   opensm/osm_qos_parser_y.y     | 6 ++----
>   opensm/st.c                   | 2 --
>   3 files changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/libvendor/osm_vendor_ibumad.c
> b/libvendor/osm_vendor_ibumad.c index ca320a6..cdb18e9 100644
> --- a/libvendor/osm_vendor_ibumad.c
> +++ b/libvendor/osm_vendor_ibumad.c
> @@ -574,10 +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) {
> -		free(p_vend);
> -		p_vend = NULL;
> -	}
> +	osm_vendor_init(p_vend, p_log, timeout);

I guess it's better to write:

If (osm_vendor_init(p_vend, p_log, timeout) != IB_SUCCESS) { 
--
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..cdb18e9 100644
--- a/libvendor/osm_vendor_ibumad.c
+++ b/libvendor/osm_vendor_ibumad.c
@@ -574,10 +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) {
-		free(p_vend);
-		p_vend = NULL;
-	}
+	osm_vendor_init(p_vend, p_log, timeout);

  Exit:
  	OSM_LOG_EXIT(p_log);
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;