[devel] [PATCH 1 of 1] osaf: Fix compilation errors when building with GCC 4.9.0 [#883]

2014-05-08 Thread Anders Widell
 osaf/libs/core/common/ncs_main_pub.c |   2 +-
 osaf/libs/core/common/ncs_sprr.c |   2 +-
 osaf/libs/core/include/ncssysf_def.h |   4 ++--
 osaf/libs/core/leap/hj_dec.c |   4 ++--
 osaf/libs/core/leap/hj_enc.c |   8 
 osaf/libs/core/leap/hj_hdl.c |  18 +-
 osaf/libs/core/leap/hj_ubaid.c   |   6 +++---
 osaf/libs/core/leap/sysf_ipc.c   |   6 +++---
 osaf/libs/core/leap/sysf_mem.c   |   4 ++--
 osaf/libs/core/leap/sysf_tmr.c   |   2 +-
 osaf/services/infrastructure/fm/fms/fm_mds.c |   2 +-
 osaf/services/saf/clmsv/clms/clms_mbcsv.c|   2 +-
 osaf/services/saf/cpsv/cpd/cpd_amf.c |   4 ++--
 osaf/services/saf/cpsv/cpd/cpd_mds.c |   2 +-
 osaf/services/saf/glsv/gld/gld_evt.c |   2 +-
 osaf/services/saf/logsv/lgs/lgs_mbcsv.c  |   2 +-
 osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c|   2 +-
 17 files changed, 36 insertions(+), 36 deletions(-)


OpenSAF did not build successfully with GCC 4.9.0, due to a new warning:

In file included from ncs_sprr.c:37:0:
ncs_sprr.c: In function 'ncs_splr_api':
../../../../osaf/libs/core/include/ncssysf_def.h:105:54: error: right-hand 
operand of comma expression has no effect [-Werror=unused-value]
 #define m_LEAP_DBG_SINK(r) (TRACE("IN LEAP_DBG_SINK"), r)
  ^
ncs_sprr.c:46:58: note: in expansion of macro 'm_LEAP_DBG_SINK'
 #define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
  ^
ncs_sprr.c:237:9: note: in expansion of macro 'm_NCS_SPRR_DBG_SINK'
rc = m_NCS_SPRR_DBG_SINK(NCSCC_RC_DUPLICATE_ENTRY, "SPLR duplication 
attempted");

The warning actually pointed out a rather tricky bug in ncs_sprr.c, that is not
obvious the first time you look at the code. The bug is that the comma operator
is used within a C preprocessor macro, without surrounding parentheses. When
this macro is used in an assignment statement, the code does not do what you
would expect, since the comma operator has lower precedence than the assignment
operator in the C language.

By adding parentheses around the macro definition, this bug is solved.

diff --git a/osaf/libs/core/common/ncs_main_pub.c 
b/osaf/libs/core/common/ncs_main_pub.c
--- a/osaf/libs/core/common/ncs_main_pub.c
+++ b/osaf/libs/core/common/ncs_main_pub.c
@@ -759,7 +759,7 @@ void ncs_get_sys_params_arg(NCS_SYS_PARA
if (m_NCS_GET_PHYINFO_FROM_NODE_ID(sys_params->node_id, 
&sys_params->shelf_id,
   &sys_params->slot_id, &sub_slot_id) 
!= NCSCC_RC_SUCCESS) {
 
-   m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
+   m_LEAP_DBG_SINK_VOID;
return;
}
 
diff --git a/osaf/libs/core/common/ncs_sprr.c b/osaf/libs/core/common/ncs_sprr.c
--- a/osaf/libs/core/common/ncs_sprr.c
+++ b/osaf/libs/core/common/ncs_sprr.c
@@ -43,7 +43,7 @@
 #ifdef NDEBUG
 #define m_NCS_SPRR_DBG_SINK(x,y)  (x)
 #else
-#define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
+#define m_NCS_SPRR_DBG_SINK(x,y)  (printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x))
 #endif
 
 #define m_NCSSPRR_TRACE_ARG2(x,y)
diff --git a/osaf/libs/core/include/ncssysf_def.h 
b/osaf/libs/core/include/ncssysf_def.h
--- a/osaf/libs/core/include/ncssysf_def.h
+++ b/osaf/libs/core/include/ncssysf_def.h
@@ -91,8 +91,8 @@ void opensaf_reboot(unsigned node_id, co
  ** **
  /
 
-#define m_KEY_CHK_FMT(k,f)  { if (k.fmat != f) m_LEAP_DBG_SINK(0);}
-#define m_KEY_CHK_LEN(l){ if (l > SYSF_MAX_KEY_LEN) m_LEAP_DBG_SINK(0); }
+#define m_KEY_CHK_FMT(k,f)  { if (k.fmat != f) m_LEAP_DBG_SINK_VOID;}
+#define m_KEY_CHK_LEN(l){ if (l > SYSF_MAX_KEY_LEN) m_LEAP_DBG_SINK_VOID; }
 #define m_KEY_CHK_SLEN(s)   { uint32_t l = m_NCS_STRLEN(s); m_KEY_CHK_LEN(l); }
 
 /*
diff --git a/osaf/libs/core/leap/hj_dec.c b/osaf/libs/core/leap/hj_dec.c
--- a/osaf/libs/core/leap/hj_dec.c
+++ b/osaf/libs/core/leap/hj_dec.c
@@ -68,7 +68,7 @@ USRBUF *ncs_decode_n_octets(USRBUF *u, u
**/
if ((s = m_MMGR_DATA_AT_START(u, count, (char *)os)) != (char *)os) {
if (s == 0) {
-   m_LEAP_DBG_SINK(0);
+   m_LEAP_DBG_SINK_VOID;
return (USRBUF *)0;
}
memcpy(os, s, (size_t)count);
@@ -84,7 +84,7 @@ USRBUF *ncs_decode_n_octets(USRBUF *u, u
 uint8_t *ncs_flatten_n_octets(USRBUF *u, uint8_t *os, uint32_t count)
 {
if (u == BNULL) {
-   m_LEAP_DBG_SINK(0);
+   m_LEAP_DBG_SINK_VOID;
return NULL;
}
 
diff --git a/osaf/libs/core/leap/hj_enc.c b/osaf/libs/core/leap/hj_enc.c
--- a/osaf/libs/core/leap/hj_enc.c
+++ b/osaf/libs/core/leap/hj_enc.c

Re: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when building with GCC 4.9.0 [#883]

2014-05-08 Thread Hans Feldt
Why not just replace with trace?
/Hans

> -Original Message-
> From: Anders Widell [mailto:anders.wid...@ericsson.com]
> Sent: den 8 maj 2014 15:04
> To: ramesh.bet...@oracle.com
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when building 
> with GCC 4.9.0 [#883]
> 
>  osaf/libs/core/common/ncs_main_pub.c |   2 +-
>  osaf/libs/core/common/ncs_sprr.c |   2 +-
>  osaf/libs/core/include/ncssysf_def.h |   4 ++--
>  osaf/libs/core/leap/hj_dec.c |   4 ++--
>  osaf/libs/core/leap/hj_enc.c |   8 
>  osaf/libs/core/leap/hj_hdl.c |  18 +-
>  osaf/libs/core/leap/hj_ubaid.c   |   6 +++---
>  osaf/libs/core/leap/sysf_ipc.c   |   6 +++---
>  osaf/libs/core/leap/sysf_mem.c   |   4 ++--
>  osaf/libs/core/leap/sysf_tmr.c   |   2 +-
>  osaf/services/infrastructure/fm/fms/fm_mds.c |   2 +-
>  osaf/services/saf/clmsv/clms/clms_mbcsv.c|   2 +-
>  osaf/services/saf/cpsv/cpd/cpd_amf.c |   4 ++--
>  osaf/services/saf/cpsv/cpd/cpd_mds.c |   2 +-
>  osaf/services/saf/glsv/gld/gld_evt.c |   2 +-
>  osaf/services/saf/logsv/lgs/lgs_mbcsv.c  |   2 +-
>  osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c|   2 +-
>  17 files changed, 36 insertions(+), 36 deletions(-)
> 
> 
> OpenSAF did not build successfully with GCC 4.9.0, due to a new warning:
> 
> In file included from ncs_sprr.c:37:0:
> ncs_sprr.c: In function 'ncs_splr_api':
> ../../../../osaf/libs/core/include/ncssysf_def.h:105:54: error: right-hand 
> operand of comma expression has no effect [-
> Werror=unused-value]
>  #define m_LEAP_DBG_SINK(r) (TRACE("IN LEAP_DBG_SINK"), r)
>   ^
> ncs_sprr.c:46:58: note: in expansion of macro 'm_LEAP_DBG_SINK'
>  #define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
>   ^
> ncs_sprr.c:237:9: note: in expansion of macro 'm_NCS_SPRR_DBG_SINK'
> rc = m_NCS_SPRR_DBG_SINK(NCSCC_RC_DUPLICATE_ENTRY, "SPLR duplication 
> attempted");
> 
> The warning actually pointed out a rather tricky bug in ncs_sprr.c, that is 
> not
> obvious the first time you look at the code. The bug is that the comma 
> operator
> is used within a C preprocessor macro, without surrounding parentheses. When
> this macro is used in an assignment statement, the code does not do what you
> would expect, since the comma operator has lower precedence than the 
> assignment
> operator in the C language.
> 
> By adding parentheses around the macro definition, this bug is solved.
> 
> diff --git a/osaf/libs/core/common/ncs_main_pub.c 
> b/osaf/libs/core/common/ncs_main_pub.c
> --- a/osaf/libs/core/common/ncs_main_pub.c
> +++ b/osaf/libs/core/common/ncs_main_pub.c
> @@ -759,7 +759,7 @@ void ncs_get_sys_params_arg(NCS_SYS_PARA
>   if (m_NCS_GET_PHYINFO_FROM_NODE_ID(sys_params->node_id, 
> &sys_params->shelf_id,
>  &sys_params->slot_id, &sub_slot_id) 
> != NCSCC_RC_SUCCESS) {
> 
> - m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
> + m_LEAP_DBG_SINK_VOID;
>   return;
>   }
> 
> diff --git a/osaf/libs/core/common/ncs_sprr.c 
> b/osaf/libs/core/common/ncs_sprr.c
> --- a/osaf/libs/core/common/ncs_sprr.c
> +++ b/osaf/libs/core/common/ncs_sprr.c
> @@ -43,7 +43,7 @@
>  #ifdef NDEBUG
>  #define m_NCS_SPRR_DBG_SINK(x,y)  (x)
>  #else
> -#define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
> +#define m_NCS_SPRR_DBG_SINK(x,y)  (printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x))
>  #endif
> 
>  #define m_NCSSPRR_TRACE_ARG2(x,y)
> diff --git a/osaf/libs/core/include/ncssysf_def.h 
> b/osaf/libs/core/include/ncssysf_def.h
> --- a/osaf/libs/core/include/ncssysf_def.h
> +++ b/osaf/libs/core/include/ncssysf_def.h
> @@ -91,8 +91,8 @@ void opensaf_reboot(unsigned node_id, co
>   ** 
> **
>   
> /
> 
> -#define m_KEY_CHK_FMT(k,f)  { if (k.fmat != f) m_LEAP_DBG_SINK(0);}
> -#define m_KEY_CHK_LEN(l){ if (l > SYSF_MAX_KEY_LEN) m_LEAP_DBG_SINK(0); }
> +#define m_KEY_CHK_FMT(k,f)  { if (k.fmat != f) m_LEAP_DBG_SINK_VOID;}
> +#define m_KEY_CHK_LEN(l){ if (l > SYSF_MAX_KEY_LEN) 
> m_LEAP_DBG_SINK_VOID; }
>  #define m_KEY_CHK_SLEN(s)   { uint32_t l = m_NCS_STRLE

Re: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when building with GCC 4.9.0 [#883]

2014-05-08 Thread Anders Widell
Yes that should ALSO be done. :-) There are probably several more places 
where we have printf.

This patch just fixes the missing parentheses. I could fix the printf 
too, while touching that line.

/ Anders Widell

On 05/08/2014 03:33 PM, Hans Feldt wrote:
> Why not just replace with trace?
> /Hans
>
>> -Original Message-
>> From: Anders Widell [mailto:anders.wid...@ericsson.com]
>> Sent: den 8 maj 2014 15:04
>> To: ramesh.bet...@oracle.com
>> Cc: opensaf-devel@lists.sourceforge.net
>> Subject: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when building 
>> with GCC 4.9.0 [#883]
>>
>>   osaf/libs/core/common/ncs_main_pub.c |   2 +-
>>   osaf/libs/core/common/ncs_sprr.c |   2 +-
>>   osaf/libs/core/include/ncssysf_def.h |   4 ++--
>>   osaf/libs/core/leap/hj_dec.c |   4 ++--
>>   osaf/libs/core/leap/hj_enc.c |   8 
>>   osaf/libs/core/leap/hj_hdl.c |  18 +-
>>   osaf/libs/core/leap/hj_ubaid.c   |   6 +++---
>>   osaf/libs/core/leap/sysf_ipc.c   |   6 +++---
>>   osaf/libs/core/leap/sysf_mem.c   |   4 ++--
>>   osaf/libs/core/leap/sysf_tmr.c   |   2 +-
>>   osaf/services/infrastructure/fm/fms/fm_mds.c |   2 +-
>>   osaf/services/saf/clmsv/clms/clms_mbcsv.c|   2 +-
>>   osaf/services/saf/cpsv/cpd/cpd_amf.c |   4 ++--
>>   osaf/services/saf/cpsv/cpd/cpd_mds.c |   2 +-
>>   osaf/services/saf/glsv/gld/gld_evt.c |   2 +-
>>   osaf/services/saf/logsv/lgs/lgs_mbcsv.c  |   2 +-
>>   osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c|   2 +-
>>   17 files changed, 36 insertions(+), 36 deletions(-)
>>
>>
>> OpenSAF did not build successfully with GCC 4.9.0, due to a new warning:
>>
>> In file included from ncs_sprr.c:37:0:
>> ncs_sprr.c: In function 'ncs_splr_api':
>> ../../../../osaf/libs/core/include/ncssysf_def.h:105:54: error: right-hand 
>> operand of comma expression has no effect [-
>> Werror=unused-value]
>>   #define m_LEAP_DBG_SINK(r) (TRACE("IN LEAP_DBG_SINK"), r)
>>^
>> ncs_sprr.c:46:58: note: in expansion of macro 'm_LEAP_DBG_SINK'
>>   #define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
>>^
>> ncs_sprr.c:237:9: note: in expansion of macro 'm_NCS_SPRR_DBG_SINK'
>>  rc = m_NCS_SPRR_DBG_SINK(NCSCC_RC_DUPLICATE_ENTRY, "SPLR duplication 
>> attempted");
>>
>> The warning actually pointed out a rather tricky bug in ncs_sprr.c, that is 
>> not
>> obvious the first time you look at the code. The bug is that the comma 
>> operator
>> is used within a C preprocessor macro, without surrounding parentheses. When
>> this macro is used in an assignment statement, the code does not do what you
>> would expect, since the comma operator has lower precedence than the 
>> assignment
>> operator in the C language.
>>
>> By adding parentheses around the macro definition, this bug is solved.
>>
>> diff --git a/osaf/libs/core/common/ncs_main_pub.c 
>> b/osaf/libs/core/common/ncs_main_pub.c
>> --- a/osaf/libs/core/common/ncs_main_pub.c
>> +++ b/osaf/libs/core/common/ncs_main_pub.c
>> @@ -759,7 +759,7 @@ void ncs_get_sys_params_arg(NCS_SYS_PARA
>>  if (m_NCS_GET_PHYINFO_FROM_NODE_ID(sys_params->node_id, 
>> &sys_params->shelf_id,
>> &sys_params->slot_id, &sub_slot_id) 
>> != NCSCC_RC_SUCCESS) {
>>
>> -m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
>> +m_LEAP_DBG_SINK_VOID;
>>  return;
>>  }
>>
>> diff --git a/osaf/libs/core/common/ncs_sprr.c 
>> b/osaf/libs/core/common/ncs_sprr.c
>> --- a/osaf/libs/core/common/ncs_sprr.c
>> +++ b/osaf/libs/core/common/ncs_sprr.c
>> @@ -43,7 +43,7 @@
>>   #ifdef NDEBUG
>>   #define m_NCS_SPRR_DBG_SINK(x,y)  (x)
>>   #else
>> -#define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", y),m_LEAP_DBG_SINK(x)
>> +#define m_NCS_SPRR_DBG_SINK(x,y)  (printf("SPRR:%s\n", 
>> y),m_LEAP_DBG_SINK(x))
>>   #endif
>>
>>   #define m_NCSSPRR_TRACE_ARG2(x,y)
>> diff --git a/osaf/libs/core/include/ncssysf_def.h 
>> b/osaf/libs/core/include/ncssysf_def.h
>> --- a/osaf/libs/core/include/ncssysf_def.h
>> +++ b/osaf/libs/core/include/ncssysf_def.h
>> @@ -91,8 +91,8 @@ void opensaf_re

Re: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when building with GCC 4.9.0 [#883]

2014-05-08 Thread Ramesh Betham
Hi Anders,

Ack.  I hope Hans comment is been taken care.
While reviewing this patch, I see the necessity of doing one more round 
of code cleanup in some legacy files. If not completely, let me see what 
I can do in 4.5 release.

Thanks and Regards,
Ramesh.

On 5/8/2014 8:12 PM, Anders Widell wrote:
> Yes that should ALSO be done. :-) There are probably several more 
> places where we have printf.
>
> This patch just fixes the missing parentheses. I could fix the printf 
> too, while touching that line.
>
> / Anders Widell
>
> On 05/08/2014 03:33 PM, Hans Feldt wrote:
>> Why not just replace with trace?
>> /Hans
>>
>>> -Original Message-
>>> From: Anders Widell [mailto:anders.wid...@ericsson.com]
>>> Sent: den 8 maj 2014 15:04
>>> To: ramesh.bet...@oracle.com
>>> Cc: opensaf-devel@lists.sourceforge.net
>>> Subject: [devel] [PATCH 1 of 1] osaf: Fix compilation errors when 
>>> building with GCC 4.9.0 [#883]
>>>
>>>   osaf/libs/core/common/ncs_main_pub.c |   2 +-
>>>   osaf/libs/core/common/ncs_sprr.c |   2 +-
>>>   osaf/libs/core/include/ncssysf_def.h |   4 ++--
>>>   osaf/libs/core/leap/hj_dec.c |   4 ++--
>>>   osaf/libs/core/leap/hj_enc.c |   8 
>>>   osaf/libs/core/leap/hj_hdl.c |  18 +-
>>>   osaf/libs/core/leap/hj_ubaid.c   |   6 +++---
>>>   osaf/libs/core/leap/sysf_ipc.c   |   6 +++---
>>>   osaf/libs/core/leap/sysf_mem.c   |   4 ++--
>>>   osaf/libs/core/leap/sysf_tmr.c   |   2 +-
>>>   osaf/services/infrastructure/fm/fms/fm_mds.c |   2 +-
>>>   osaf/services/saf/clmsv/clms/clms_mbcsv.c|   2 +-
>>>   osaf/services/saf/cpsv/cpd/cpd_amf.c |   4 ++--
>>>   osaf/services/saf/cpsv/cpd/cpd_mds.c |   2 +-
>>>   osaf/services/saf/glsv/gld/gld_evt.c |   2 +-
>>>   osaf/services/saf/logsv/lgs/lgs_mbcsv.c  |   2 +-
>>>   osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c|   2 +-
>>>   17 files changed, 36 insertions(+), 36 deletions(-)
>>>
>>>
>>> OpenSAF did not build successfully with GCC 4.9.0, due to a new 
>>> warning:
>>>
>>> In file included from ncs_sprr.c:37:0:
>>> ncs_sprr.c: In function 'ncs_splr_api':
>>> ../../../../osaf/libs/core/include/ncssysf_def.h:105:54: error: 
>>> right-hand operand of comma expression has no effect [-
>>> Werror=unused-value]
>>>   #define m_LEAP_DBG_SINK(r) (TRACE("IN LEAP_DBG_SINK"), r)
>>>^
>>> ncs_sprr.c:46:58: note: in expansion of macro 'm_LEAP_DBG_SINK'
>>>   #define m_NCS_SPRR_DBG_SINK(x,y)  printf("SPRR:%s\n", 
>>> y),m_LEAP_DBG_SINK(x)
>>>^
>>> ncs_sprr.c:237:9: note: in expansion of macro 'm_NCS_SPRR_DBG_SINK'
>>>  rc = m_NCS_SPRR_DBG_SINK(NCSCC_RC_DUPLICATE_ENTRY, "SPLR 
>>> duplication attempted");
>>>
>>> The warning actually pointed out a rather tricky bug in ncs_sprr.c, 
>>> that is not
>>> obvious the first time you look at the code. The bug is that the 
>>> comma operator
>>> is used within a C preprocessor macro, without surrounding 
>>> parentheses. When
>>> this macro is used in an assignment statement, the code does not do 
>>> what you
>>> would expect, since the comma operator has lower precedence than the 
>>> assignment
>>> operator in the C language.
>>>
>>> By adding parentheses around the macro definition, this bug is solved.
>>>
>>> diff --git a/osaf/libs/core/common/ncs_main_pub.c 
>>> b/osaf/libs/core/common/ncs_main_pub.c
>>> --- a/osaf/libs/core/common/ncs_main_pub.c
>>> +++ b/osaf/libs/core/common/ncs_main_pub.c
>>> @@ -759,7 +759,7 @@ void ncs_get_sys_params_arg(NCS_SYS_PARA
>>>   if (m_NCS_GET_PHYINFO_FROM_NODE_ID(sys_params->node_id, 
>>> &sys_params->shelf_id,
>>>  &sys_params->slot_id, &sub_slot_id) != 
>>> NCSCC_RC_SUCCESS) {
>>>
>>> -m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);
>>> +m_LEAP_DBG_SINK_VOID;
>>>   return;
>>>   }
>>>
>>> diff --git a/osaf/libs/core/common/ncs_sprr.c 
>>> b/osaf/libs/core/common/ncs_sprr.c
>>> --- a/osaf/libs/core/common/ncs_sprr.c
>>