[PATCH infiniband-diags] perfquery.c: Fix smp_query_via return value checks

2015-10-12 Thread Hal Rosenstock

smp_query_via returns pointer so < 0 comparison is wrong:
src/perfquery.c: In function ?is_rsfec_mode_active?:
src/perfquery.c:481: warning: ordered comparison of pointer with integer zero
src/perfquery.c: In function ?main?:
src/perfquery.c:919: warning: ordered comparison of pointer with integer zero
src/perfquery.c:928: warning: ordered comparison of pointer with integer zero
 
Reported-by: David Binderman  
Signed-off-by: Hal Rosenstock 
---
Fix for OFA Bugzilla #2572

diff --git a/src/perfquery.c b/src/perfquery.c
index 9e3a307..948ce52 100644
--- a/src/perfquery.c
+++ b/src/perfquery.c
@@ -477,8 +477,8 @@ static uint8_t is_rsfec_mode_active(ib_portid_t * portid, 
int port,
return 0;
}
 
-   if (smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
- srcport) < 0)
+   if (!smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
+  srcport))
IBEXIT("smp query portinfo extended failed");
 
mad_decode_field(data, IB_PORT_EXT_CAPMASK_F, _capmask);
@@ -915,8 +915,8 @@ int main(int argc, char **argv)
 
 
if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) 
{
-   if (smp_query_via(data, , IB_ATTR_NODE_INFO, 0, 0,
- srcport) < 0)
+   if (!smp_query_via(data, , IB_ATTR_NODE_INFO, 0, 0,
+  srcport))
IBEXIT("smp query nodeinfo failed");
node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
mad_decode_field(data, IB_NODE_NPORTS_F, _ports);
@@ -924,8 +924,8 @@ int main(int argc, char **argv)
IBEXIT("smp query nodeinfo: num ports invalid");
 
if (node_type == IB_NODE_SWITCH) {
-   if (smp_query_via(data, , IB_ATTR_SWITCH_INFO,
- 0, 0, srcport) < 0)
+   if (!smp_query_via(data, , IB_ATTR_SWITCH_INFO,
+  0, 0, srcport))
IBEXIT("smp query nodeinfo failed");
enhancedport0 =
mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH infiniband-diags] perfquery.c: Fix smp_query_via return value checks

2015-10-12 Thread ira.weiny
On Mon, Oct 12, 2015 at 08:30:31AM -0400, Hal Rosenstock wrote:
> 
> smp_query_via returns pointer so < 0 comparison is wrong:
> src/perfquery.c: In function ?is_rsfec_mode_active?:
> src/perfquery.c:481: warning: ordered comparison of pointer with integer zero
> src/perfquery.c: In function ?main?:
> src/perfquery.c:919: warning: ordered comparison of pointer with integer zero
> src/perfquery.c:928: warning: ordered comparison of pointer with integer zero
>  
> Reported-by: David Binderman  
> Signed-off-by: Hal Rosenstock 

There is also a call in ibdiag_common.c which is wrong:

diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
index 54248455bac4..5ec0167f87de 100644
--- a/src/ibdiag_common.c
+++ b/src/ibdiag_common.c
@@ -507,7 +507,7 @@ int is_port_info_extended_supported(ib_portid_t * dest, int
port,
uint32_t cap_mask;
uint16_t cap_mask2;
 
-   if (smp_query_via(data, dest, IB_ATTR_PORT_INFO, port, 0, srcport) < 0)
+   if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, port, 0, srcport))
IBEXIT("port info query failed");
 
mad_decode_field(data, IB_PORT_CAPMASK_F, _mask);


I went ahead and added this chunk to this patch and accepted.

Thanks,
Ira


> ---
> Fix for OFA Bugzilla #2572
> 
> diff --git a/src/perfquery.c b/src/perfquery.c
> index 9e3a307..948ce52 100644
> --- a/src/perfquery.c
> +++ b/src/perfquery.c
> @@ -477,8 +477,8 @@ static uint8_t is_rsfec_mode_active(ib_portid_t * portid, 
> int port,
>   return 0;
>   }
>  
> - if (smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
> -   srcport) < 0)
> + if (!smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
> +srcport))
>   IBEXIT("smp query portinfo extended failed");
>  
>   mad_decode_field(data, IB_PORT_EXT_CAPMASK_F, _capmask);
> @@ -915,8 +915,8 @@ int main(int argc, char **argv)
>  
>  
>   if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) 
> {
> - if (smp_query_via(data, , IB_ATTR_NODE_INFO, 0, 0,
> -   srcport) < 0)
> + if (!smp_query_via(data, , IB_ATTR_NODE_INFO, 0, 0,
> +srcport))
>   IBEXIT("smp query nodeinfo failed");
>   node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
>   mad_decode_field(data, IB_NODE_NPORTS_F, _ports);
> @@ -924,8 +924,8 @@ int main(int argc, char **argv)
>   IBEXIT("smp query nodeinfo: num ports invalid");
>  
>   if (node_type == IB_NODE_SWITCH) {
> - if (smp_query_via(data, , IB_ATTR_SWITCH_INFO,
> -   0, 0, srcport) < 0)
> + if (!smp_query_via(data, , IB_ATTR_SWITCH_INFO,
> +0, 0, srcport))
>   IBEXIT("smp query nodeinfo failed");
>   enhancedport0 =
>   mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html