Hi Anders Widell,
Can you please re-send the v1 patches fixing following three issues , so that I
can proceed for test.
1) build fails with gcc version 4.8.3
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../../.. -I../../../..
-I../../../../osaf/libs/saf/include -I../../../../osaf/libs/core/include
-I../../../../osaf/libs/core/leap/include
-I../../../../osaf/libs/core/mds/include
-I../../../../osaf/libs/core/common/include
-I../../../../osaf/libs/core/cplusplus -std=gnu++11 -Wall
-fno-strict-aliasing -Werror -fPIC -D__STDC_FORMAT_MACROS
-D_FORTIFY_SOURCE=2 -fstack-protector -DINTERNAL_VERSION_ID=\"\" -O2 -g
-m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector
-funwind-tables -fasynchronous-unwind-tables -MT libmds_la-mds_log.lo
-MD -MP -MF .deps/libmds_la-mds_log.Tpo -c mds_log.cc -fPIC -DPIC -o
.libs/libmds_la-mds_log.o
mds_log.cc:37:50: fatal error: osaf/libs/core/cplusplus/base/buffer.h:
No such file or directory
#include "osaf/libs/core/cplusplus/base/buffer.h"
2) [PATCH 3 of 3] need to be re-based It fails on latest stating ( but
applies clean on change-set : 8200 )
3) We can remove pref[50] varible
--- a/osaf/libs/core/mds/mds_main.c
+++ b/osaf/libs/core/mds/mds_main.c
@@ -558,7 +557,7 @@ uint32_t mds_lib_req(NCS_LIB_REQ_INFO *r
char buff[50], pref[50];
-AVM
On 11/2/2016 10:47 AM, A V Mahesh wrote:
> Hi Anders Widell,
>
> I used hg command patches applied cleanly on `change-set : 8200` .
>
> But for your information [PATCH 3 of 3] need to be re-based , it fails
> on latest stating.
>
> =============================================================================
>
> # hg import /avm/2015_1.patch /avm/2015_2.patch /avm/2015_3.patch
> --no-commit
> applying /avm/2015_1.patch
> applying /avm/2015_2.patch
> applied to working directory
> applying /avm/2015_3.patch
> patching file osaf/services/infrastructure/dtms/scripts/osaf-transport.in
> Hunk #1 FAILED at 33
> Hunk #2 FAILED at 99
> 2 out of 2 hunks FAILED -- saving rejects to file
> osaf/services/infrastructure/dtms/scripts/osaf-transport.in.rej
> unable to find 'osaf/services/infrastructure/dtms/transport/Makefile.am'
> for patching
> 2 out of 2 hunks FAILED -- saving rejects to file
> osaf/services/infrastructure/dtms/transport/Makefile.am.rej
> unable to find 'osaf/services/infrastructure/dtms/transport/main.cc' for
> patching
> 2 out of 2 hunks FAILED -- saving rejects to file
> osaf/services/infrastructure/dtms/transport/main.cc.rej
> unable to find
> 'osaf/services/infrastructure/dtms/transport/transport_monitor.cc' for
> patching
> 3 out of 3 hunks FAILED -- saving rejects to file
> osaf/services/infrastructure/dtms/transport/transport_monitor.cc.rej
> unable to find
> 'osaf/services/infrastructure/dtms/transport/transport_monitor.h' for
> patching
> 4 out of 4 hunks FAILED -- saving rejects to file
> osaf/services/infrastructure/dtms/transport/transport_monitor.h.rej
> osaf/services/infrastructure/dtms/transport/Makefile.am: No such file or
> directory
> osaf/services/infrastructure/dtms/transport/main.cc: No such file or
> directory
> osaf/services/infrastructure/dtms/transport/transport_monitor.cc: No
> such file or directory
> osaf/services/infrastructure/dtms/transport/transport_monitor.h: No such
> file or directory
> abort: patch failed to apply
>
> =============================================================================
>
> -AVM
>
> On 11/1/2016 2:50 PM, Anders Widell wrote:
>> Hi!
>>
>> I tried the patches that were sent out on the list, and they apply
>> cleanly for me. Maybe your version of the patch command does not
>> support renaming files? I tried and it works with version 2.7.1 of the
>> patch command. Could you try with patching a newer version of the
>> command, or by using Mercurial instead, e.g. hg qimport; hg qpush ?
>>
>> regards,
>>
>> Anders Widell
>>
>>
>> On 11/01/2016 09:59 AM, A V Mahesh wrote:
>>> Hi Anders Widell,
>>>
>>> It seems you missed to do `hg add osaf/libs/core/mds/mds_log.cc` ,
>>> while trying to apply [PATCH 2 of 3]
>>>
>>> I getting following error , can you please send the updated patch.
>>>
>>> ===========================================================
>>>
>>> # patch -p1 </avm/[PATCH 2 of 3].patch
>>> can't find file to patch at input line 4
>>> Perhaps you used the wrong -p or --strip option?
>>> The text leading up to this was:
>>> --------------------------
>>> |diff --git a/osaf/libs/core/mds/mds_log.cc
>>> b/osaf/libs/core/mds/mds_log.cc
>>> |--- a/osaf/libs/core/mds/mds_log.cc
>>> |+++ b/osaf/libs/core/mds/mds_log.cc
>>> --------------------------
>>> File to patch:
>>>
>>> ===========================================================
>>> -AVM
>>>
>>>
>>> On 10/19/2016 5:18 PM, Anders Widell wrote:
>>>> osaf/libs/core/mds/Makefile.am | 2 +-
>>>> osaf/libs/core/mds/include/mds_dt2c.h | 3 -
>>>> osaf/libs/core/mds/include/mds_log.h | 59 +++--
>>>> osaf/libs/core/mds/mds_dt_tipc.c | 5 +-
>>>> osaf/libs/core/mds/mds_log.cc | 369
>>>> +++++++++++++++++----------------
>>>> osaf/libs/core/mds/mds_main.c | 3 +-
>>>> 6 files changed, 228 insertions(+), 213 deletions(-)
>>>>
>>>>
>>>> Convert the mds_log.c file to C++ so that it can use C++ classes
>>>> without the
>>>> need for any wrappers.
>>>>
>>>> diff --git a/osaf/libs/core/mds/Makefile.am
>>>> b/osaf/libs/core/mds/Makefile.am
>>>> --- a/osaf/libs/core/mds/Makefile.am
>>>> +++ b/osaf/libs/core/mds/Makefile.am
>>>> @@ -37,7 +37,7 @@ libmds_la_SOURCES = \
>>>> mds_papi.c \
>>>> mds_c_sndrcv.c \
>>>> mds_c_api.c \
>>>> - mds_log.c \
>>>> + mds_log.cc \
>>>> ncs_ada.c \
>>>> ncs_mda.c \
>>>> ncs_vda.c
>>>> diff --git a/osaf/libs/core/mds/include/mds_dt2c.h
>>>> b/osaf/libs/core/mds/include/mds_dt2c.h
>>>> --- a/osaf/libs/core/mds/include/mds_dt2c.h
>>>> +++ b/osaf/libs/core/mds/include/mds_dt2c.h
>>>> @@ -316,9 +316,6 @@ typedef struct mds_mbx_evt_info {
>>>> /* ******************************************** */
>>>> /* ******************************************** */
>>>> -/* Initialize Logging */
>>>> -extern uint32_t mds_log_init(char *log_file_name, char *line_prefix);
>>>> -
>>>> /* extern gl_mds_checksum */
>>>> extern uint32_t gl_mds_checksum;
>>>> diff --git a/osaf/libs/core/mds/include/mds_log.h
>>>> b/osaf/libs/core/mds/include/mds_log.h
>>>> --- a/osaf/libs/core/mds/include/mds_log.h
>>>> +++ b/osaf/libs/core/mds/include/mds_log.h
>>>> @@ -22,39 +22,50 @@
>>>> ******************************************************************************
>>>>
>>>> */
>>>> -#ifndef _MDS_LOG_H
>>>> -#define _MDS_LOG_H
>>>> +#ifndef OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_
>>>> +#define OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_
>>>> -#include <ncsgl_defs.h>
>>>> -#include "ncs_lib.h"
>>>> +#include <stdint.h>
>>>> +
>>>> +#ifdef __cplusplus
>>>> +extern "C" {
>>>> +#endif
>>>> /* Logging utility functions - Phani */
>>>> -extern uint32_t gl_mds_log_level;
>>>> +extern int gl_mds_log_level;
>>>> -#define NCSMDS_LC_CRITICAL 1
>>>> -#define NCSMDS_LC_ERR 2
>>>> -#define NCSMDS_LC_NOTIFY 3
>>>> -#define NCSMDS_LC_INFO 4
>>>> -#define NCSMDS_LC_DBG 5
>>>> +enum {
>>>> + NCSMDS_LC_CRITICAL = 1,
>>>> + NCSMDS_LC_ERR = 2,
>>>> + NCSMDS_LC_NOTIFY = 3,
>>>> + NCSMDS_LC_INFO = 4,
>>>> + NCSMDS_LC_DBG = 5
>>>> +};
>>>> -#define m_MDS_LOG_CRITICAL if (gl_mds_log_level <
>>>> NCSMDS_LC_CRITICAL) {} else log_mds_critical
>>>> -
>>>> -#define m_MDS_LOG_ERR if (gl_mds_log_level < NCSMDS_LC_ERR) {} else
>>>> log_mds_err
>>>> -
>>>> -#define m_MDS_LOG_NOTIFY if (gl_mds_log_level < NCSMDS_LC_NOTIFY)
>>>> {} else log_mds_notify
>>>> -
>>>> -#define m_MDS_LOG_INFO if (gl_mds_log_level < NCSMDS_LC_INFO) {}
>>>> else log_mds_info
>>>> -
>>>> -#define m_MDS_LOG_DBG if (gl_mds_log_level < NCSMDS_LC_DBG) {} else
>>>> log_mds_dbg
>>>> +#define m_MDS_LOG_CRITICAL log_mds_critical
>>>> +#define m_MDS_LOG_ERR log_mds_err
>>>> +#define m_MDS_LOG_NOTIFY log_mds_notify
>>>> +#define m_MDS_LOG_INFO log_mds_info
>>>> +#define m_MDS_LOG_DBG log_mds_dbg
>>>> #define m_MDS_ENTER() m_MDS_LOG_DBG(">> %s", __FUNCTION__)
>>>> #define m_MDS_LEAVE() m_MDS_LOG_DBG("<< %s", __FUNCTION__)
>>>> -extern void log_mds_dbg(char *fmt, ...);
>>>> -extern void log_mds_info(char *fmt, ...);
>>>> -extern void log_mds_notify(char *fmt, ...);
>>>> -extern void log_mds_err(char *fmt, ...);
>>>> -extern void log_mds_critical(char *fmt, ...);
>>>> +uint32_t mds_log_init(const char *log_file_name);
>>>> +void log_mds_dbg(const char *fmt, ...)
>>>> + __attribute__ ((format(printf, 1, 2)));
>>>> +void log_mds_info(const char *fmt, ...)
>>>> + __attribute__ ((format(printf, 1, 2)));
>>>> +void log_mds_notify(const char *fmt, ...)
>>>> + __attribute__ ((format(printf, 1, 2)));
>>>> +void log_mds_err(const char *fmt, ...)
>>>> + __attribute__ ((format(printf, 1, 2)));
>>>> +void log_mds_critical(const char *fmt, ...)
>>>> + __attribute__ ((format(printf, 1, 2)));
>>>> +#ifdef __cplusplus
>>>> +}
>>>> #endif
>>>> +
>>>> +#endif // OSAF_LIBS_CORE_MDS_INCLUDE_MDS_LOG_H_
>>>> diff --git a/osaf/libs/core/mds/mds_dt_tipc.c
>>>> b/osaf/libs/core/mds/mds_dt_tipc.c
>>>> --- a/osaf/libs/core/mds/mds_dt_tipc.c
>>>> +++ b/osaf/libs/core/mds/mds_dt_tipc.c
>>>> @@ -31,6 +31,7 @@
>>>> #include "ncssysf_tsk.h"
>>>> #include "ncssysf_mem.h"
>>>> +#include <inttypes.h>
>>>> #include <stdbool.h>
>>>> #include <stdlib.h>
>>>> #include <sched.h>
>>>> @@ -1107,12 +1108,12 @@ static uint32_t mdtm_process_discovery_e
>>>> m_MDS_LOG_INFO("MDTM: Raising the NODE UP event
>>>> for NODE id = %d", node_id);
>>>> uint32_t up_node_id;
>>>> if ((up_node_id =
>>>> m_MDS_GET_NODE_ID_FROM_ADEST(m_MDS_GET_ADEST)) == node_id) {
>>>> - m_MDS_LOG_INFO("MDTM:NODE_UP for
>>>> subtn_ref_val:%lu node_name:%s, node_id:%u addr_family:%d ",
>>>> + m_MDS_LOG_INFO("MDTM:NODE_UP for
>>>> subtn_ref_val:%" PRIu64 " node_name:%s, node_id:%u addr_family:%d ",
>>>> (uint64_t)subtn_ref_val,gl_mds_mcm_cb->node_name, node_id, AF_TIPC);
>>>> return mds_mcm_node_up(svc_hdl, node_id, NULL,
>>>> AF_TIPC, gl_mds_mcm_cb->node_name);
>>>> } else {
>>>> - m_MDS_LOG_INFO("MDTM:NODE_UP for
>>>> subtn_ref_val:%lu node_name:%s, node_id:%u addr_family:%d ",
>>>> + m_MDS_LOG_INFO("MDTM:NODE_UP for
>>>> subtn_ref_val:%" PRIu64 " node_name:%s, node_id:%u addr_family:%d ",
>>>> (uint64_t)subtn_ref_val, "REMOTE_NODE", node_id, AF_TIPC);
>>>> return mds_mcm_node_up(svc_hdl, node_id, NULL,
>>>> AF_TIPC, "REMOTE_NODE");
>>>> }
>>>> diff --git a/osaf/libs/core/mds/mds_log.c
>>>> b/osaf/libs/core/mds/mds_log.cc
>>>> rename from osaf/libs/core/mds/mds_log.c
>>>> rename to osaf/libs/core/mds/mds_log.cc
>>>> --- a/osaf/libs/core/mds/mds_log.c
>>>> +++ b/osaf/libs/core/mds/mds_log.cc
>>>> @@ -19,233 +19,240 @@
>>>> ..............................................................................
>>>>
>>>> DESCRIPTION: MDS LOG APIs
>>>> -******************************************************************************
>>>>
>>>> -*/
>>>> +
>>>> ******************************************************************************
>>>> + */
>>>> -#include "mds_log.h"
>>>> -#include "mds_dt2c.h" /* Include for arch-word definitions */
>>>> +#include "osaf/libs/core/mds/include/mds_log.h"
>>>> +#include <sys/time.h>
>>>> +#include <time.h>
>>>> +#include <unistd.h>
>>>> +#include <cstdarg>
>>>> +#include <cstdio>
>>>> +#include <cstring>
>>>> +#include "osaf/libs/core/include/mds_papi.h"
>>>> +#include "osaf/libs/core/include/ncsgl_defs.h"
>>>> +#include "osaf/libs/core/mds/include/mds_dt2c.h"
>>>> -static char *lf = NULL;
>>>> +constexpr static const size_t kMaxMdsFileNameLen = 256;
>>>> static void log_mds(const char *str);
>>>> +
>>>> +int gl_mds_log_level = 3;
>>>> +static char *lf = nullptr;
>>>> static char process_name[MDS_MAX_PROCESS_NAME_LEN];
>>>> +static char mds_log_fname[kMaxMdsFileNameLen];
>>>> /*****************************************************
>>>> Function NAME: get_process_name()
>>>> Returns : <process_name>[<pid> or <tipc_port_ref>]
>>>> *****************************************************/
>>>> -static void get_process_name(void)
>>>> -{
>>>> - char pid_path[1024];
>>>> - uint32_t process_id = getpid();
>>>> - char *token, *saveptr;
>>>> - char *pid_name = NULL;
>>>> +static void get_process_name() {
>>>> + char pid_path[1024];
>>>> + uint32_t process_id = getpid();
>>>> + char *token, *saveptr;
>>>> + char *pid_name = nullptr;
>>>> - sprintf(pid_path, "/proc/%d/cmdline", process_id);
>>>> - FILE* f = fopen(pid_path,"r");
>>>> - if(f){
>>>> - size_t size;
>>>> - size = fread(pid_path, sizeof(char), 1024, f);
>>>> - if(size>0){
>>>> - if('\n' == pid_path[size-1])
>>>> - pid_path[size-1]='\0';
>>>> - }
>>>> - fclose(f);
>>>> - }
>>>> - token = strtok_r(pid_path, "/", &saveptr);
>>>> - while( token != NULL )
>>>> - {
>>>> - pid_name = token;
>>>> - token = strtok_r(NULL, "/", &saveptr);
>>>> - }
>>>> - snprintf(process_name, MDS_MAX_PROCESS_NAME_LEN, "%s[%d]",
>>>> pid_name, process_id);
>>>> - return;
>>>> + snprintf(pid_path, sizeof(pid_path), "/proc/%d/cmdline",
>>>> process_id);
>>>> + FILE* f = fopen(pid_path, "r");
>>>> + if (f) {
>>>> + size_t size;
>>>> + size = fread(pid_path, sizeof(char), 1024, f);
>>>> + if (size > 0) {
>>>> + if ('\n' == pid_path[size-1])
>>>> + pid_path[size-1] = '\0';
>>>> + }
>>>> + fclose(f);
>>>> + }
>>>> + token = strtok_r(pid_path, "/", &saveptr);
>>>> + while (token != nullptr) {
>>>> + pid_name = token;
>>>> + token = strtok_r(nullptr, "/", &saveptr);
>>>> + }
>>>> + snprintf(process_name, MDS_MAX_PROCESS_NAME_LEN, "%s[%d]", pid_name,
>>>> + process_id);
>>>> + return;
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : mds_log_init
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -#define MAX_MDS_FNAME_LEN 256
>>>> -static char mds_log_fname[MAX_MDS_FNAME_LEN];
>>>> + * Funtion Name : mds_log_init
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +uint32_t mds_log_init(const char *log_file_name) {
>>>> + FILE *fh;
>>>> + memset(process_name, 0, MDS_MAX_PROCESS_NAME_LEN);
>>>> + tzset();
>>>> + get_process_name();
>>>> -uint32_t mds_log_init(char *log_file_name, char *line_prefix)
>>>> -{
>>>> - FILE *fh;
>>>> - memset(process_name, 0, MDS_MAX_PROCESS_NAME_LEN);
>>>> - tzset();
>>>> - get_process_name();
>>>> + if (lf != nullptr)
>>>> + return NCSCC_RC_FAILURE;
>>>> - if (lf != NULL)
>>>> - return NCSCC_RC_FAILURE;
>>>> + if (strlen(log_file_name) >= kMaxMdsFileNameLen)
>>>> + return NCSCC_RC_FAILURE;
>>>> - if (strlen(log_file_name) >= MAX_MDS_FNAME_LEN)
>>>> - return NCSCC_RC_FAILURE;
>>>> + snprintf(mds_log_fname, sizeof(mds_log_fname), "%s", log_file_name);
>>>> - strcpy(mds_log_fname, log_file_name);
>>>> + lf = mds_log_fname;
>>>> - lf = mds_log_fname;
>>>> + if ((fh = fopen(lf, "a+")) != nullptr) {
>>>> + fclose(fh);
>>>> + log_mds_notify("BEGIN MDS LOGGING| PID=<%s> |
>>>> ARCHW=%x|64bit=%zu\n",
>>>> + process_name, MDS_SELF_ARCHWORD,
>>>> MDS_WORD_SIZE_TYPE);
>>>> + }
>>>> - if ((fh = fopen(lf, "a+")) != NULL) {
>>>> - fclose(fh);
>>>> - log_mds_notify("BEGIN MDS LOGGING| PID=<%s> |
>>>> ARCHW=%x|64bit=%ld\n",
>>>> - process_name, MDS_SELF_ARCHWORD,
>>>> (long)MDS_WORD_SIZE_TYPE);
>>>> - }
>>>> -
>>>> - return NCSCC_RC_SUCCESS;
>>>> + return NCSCC_RC_SUCCESS;
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds_critical
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -void log_mds_critical(char *fmt, ...)
>>>> -{
>>>> - char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> - int i;
>>>> - va_list ap;
>>>> + * Funtion Name : log_mds_critical
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +void log_mds_critical(const char *fmt, ...) {
>>>> + if (gl_mds_log_level < NCSMDS_LC_CRITICAL) return;
>>>> + char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> + int i;
>>>> + va_list ap;
>>>> - i = snprintf(str, sizeof(str), "%s CRITICAL |", process_name);
>>>> - va_start(ap, fmt);
>>>> - vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> - va_end(ap);
>>>> - log_mds(str);
>>>> + i = snprintf(str, sizeof(str), "%s CRITICAL |", process_name);
>>>> + va_start(ap, fmt);
>>>> + vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> + va_end(ap);
>>>> + log_mds(str);
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds_err
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -void log_mds_err(char *fmt, ...)
>>>> -{
>>>> - char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> - int i;
>>>> - va_list ap;
>>>> + * Funtion Name : log_mds_err
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +void log_mds_err(const char *fmt, ...) {
>>>> + if (gl_mds_log_level < NCSMDS_LC_ERR) return;
>>>> + char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> + int i;
>>>> + va_list ap;
>>>> - i = snprintf(str, sizeof(str), "%s ERR |", process_name);
>>>> - va_start(ap, fmt);
>>>> - vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> - va_end(ap);
>>>> - log_mds(str);
>>>> + i = snprintf(str, sizeof(str), "%s ERR |", process_name);
>>>> + va_start(ap, fmt);
>>>> + vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> + va_end(ap);
>>>> + log_mds(str);
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds_notify
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -void log_mds_notify(char *fmt, ...)
>>>> -{
>>>> - char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> - int i;
>>>> - va_list ap;
>>>> + * Funtion Name : log_mds_notify
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +void log_mds_notify(const char *fmt, ...) {
>>>> + if (gl_mds_log_level < NCSMDS_LC_NOTIFY) return;
>>>> + char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> + int i;
>>>> + va_list ap;
>>>> - i = snprintf(str, sizeof(str), "%s NOTIFY |", process_name);
>>>> - va_start(ap, fmt);
>>>> - vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> - va_end(ap);
>>>> - log_mds(str);
>>>> + i = snprintf(str, sizeof(str), "%s NOTIFY |", process_name);
>>>> + va_start(ap, fmt);
>>>> + vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> + va_end(ap);
>>>> + log_mds(str);
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds_info
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -void log_mds_info(char *fmt, ...)
>>>> -{
>>>> - char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> - int i;
>>>> - va_list ap;
>>>> + * Funtion Name : log_mds_info
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +void log_mds_info(const char *fmt, ...) {
>>>> + if (gl_mds_log_level < NCSMDS_LC_INFO) return;
>>>> + char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> + int i;
>>>> + va_list ap;
>>>> - i = snprintf(str, sizeof(str), "%s INFO |", process_name);
>>>> - va_start(ap, fmt);
>>>> - vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> - va_end(ap);
>>>> - log_mds(str);
>>>> + i = snprintf(str, sizeof(str), "%s INFO |", process_name);
>>>> + va_start(ap, fmt);
>>>> + vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> + va_end(ap);
>>>> + log_mds(str);
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds_dbg
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : NCSCC_RC_SUCCESS
>>>> -* NCSCC_RC_FAILURE
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -void log_mds_dbg(char *fmt, ...)
>>>> -{
>>>> - char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> - int i;
>>>> - va_list ap;
>>>> + * Funtion Name : log_mds_dbg
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : NCSCC_RC_SUCCESS
>>>> + * NCSCC_RC_FAILURE
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +void log_mds_dbg(const char *fmt, ...) {
>>>> + if (gl_mds_log_level < NCSMDS_LC_DBG) return;
>>>> + char str[MDS_MAX_PROCESS_NAME_LEN + 32];
>>>> + int i;
>>>> + va_list ap;
>>>> - i = snprintf(str, sizeof(str), "%s DBG |", process_name);
>>>> - va_start(ap, fmt);
>>>> - vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> - va_end(ap);
>>>> - log_mds(str);
>>>> + i = snprintf(str, sizeof(str), "%s DBG |", process_name);
>>>> + va_start(ap, fmt);
>>>> + vsnprintf(str + i, sizeof(str) - i, fmt, ap);
>>>> + va_end(ap);
>>>> + log_mds(str);
>>>> }
>>>> /*******************************************************************************
>>>>
>>>> -* Funtion Name : log_mds
>>>> -*
>>>> -* Purpose :
>>>> -*
>>>> -* Return Value : None
>>>> -*
>>>> -*******************************************************************************/
>>>>
>>>> -static void log_mds(const char *str)
>>>> -{
>>>> - FILE *fp;
>>>> - struct tm *tstamp_data, tm_info;
>>>> + * Funtion Name : log_mds
>>>> + *
>>>> + * Purpose :
>>>> + *
>>>> + * Return Value : None
>>>> + *
>>>> +
>>>> *******************************************************************************/
>>>> +static void log_mds(const char *str) {
>>>> + FILE *fp;
>>>> - if (lf != NULL && ((fp = fopen(lf, "a+")) != NULL)) {
>>>> - struct timeval tv;
>>>> - char asc_tod[128];
>>>> - char log_string[512];
>>>> - int i;
>>>> + if (lf != nullptr && ((fp = fopen(lf, "a+")) != nullptr)) {
>>>> + struct tm tm_info;
>>>> + struct timeval tv;
>>>> + char asc_tod[128];
>>>> + char log_string[512];
>>>> + int i;
>>>> - gettimeofday(&tv, NULL);
>>>> - tstamp_data = localtime_r(&tv.tv_sec, &tm_info);
>>>> - osafassert(tstamp_data);
>>>> + gettimeofday(&tv, nullptr);
>>>> + struct tm* tstamp_data = localtime_r(&tv.tv_sec, &tm_info);
>>>> + osafassert(tstamp_data);
>>>> - strftime(asc_tod, sizeof(asc_tod), "%b %e %k:%M:%S",
>>>> tstamp_data);
>>>> - i = snprintf(log_string, sizeof(log_string), "%s.%06ld %s",
>>>> - asc_tod, tv.tv_usec, str);
>>>> + strftime(asc_tod, sizeof(asc_tod), "%b %e %k:%M:%S", tstamp_data);
>>>> + i = snprintf(log_string, sizeof(log_string), "%s.%06ld %s",
>>>> + asc_tod, tv.tv_usec, str);
>>>> - if (i >= sizeof(log_string)) {
>>>> - i = sizeof(log_string);
>>>> - log_string[i - 1] = '\n';
>>>> - } else if (log_string[i - 1] != '\n') {
>>>> - log_string[i] = '\n';
>>>> - i++;
>>>> - }
>>>> + if (i < 0) {
>>>> + i = 1;
>>>> + log_string[i - 1] = '\n';
>>>> + } else if (static_cast<size_t>(i) >= sizeof(log_string)) {
>>>> + i = sizeof(log_string);
>>>> + log_string[i - 1] = '\n';
>>>> + } else if (log_string[i - 1] != '\n') {
>>>> + log_string[i] = '\n';
>>>> + i++;
>>>> + }
>>>> - if (! fwrite(log_string, 1, i, fp)) {
>>>> - fclose(fp);
>>>> - return;
>>>> - }
>>>> + if (fwrite(log_string, 1, i, fp) != static_cast<size_t>(i)) {
>>>> + fclose(fp);
>>>> + return;
>>>> + }
>>>> - fclose(fp);
>>>> - }
>>>> + fclose(fp);
>>>> + }
>>>> }
>>>> -
>>>> -
>>>> diff --git a/osaf/libs/core/mds/mds_main.c
>>>> b/osaf/libs/core/mds/mds_main.c
>>>> --- a/osaf/libs/core/mds/mds_main.c
>>>> +++ b/osaf/libs/core/mds/mds_main.c
>>>> @@ -102,7 +102,6 @@ static void mds_mutex_init_once(void)
>>>> }
>>>> /* global Log level variable */
>>>> -uint32_t gl_mds_log_level = 3;
>>>> uint32_t gl_mds_checksum = 0;
>>>> uint32_t MDS_QUIESCED_TMR_VAL = 80;
>>>> @@ -558,7 +557,7 @@ uint32_t mds_lib_req(NCS_LIB_REQ_INFO *r
>>>> char buff[50], pref[50];
>>>> snprintf(buff, sizeof(buff), PKGLOGDIR "/mds.log");
>>>> memset(pref, 0 ,sizeof(pref));
>>>> - mds_log_init(buff, pref);
>>>> + mds_log_init(buff);
>>>> }
>>>> osaf_mutex_unlock_ordie(&gl_mds_library_mutex);
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Opensaf-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel