Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sivamukka committed Dec 10, 2019
1 parent 6c4d633 commit 6cf7dfd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
10 changes: 7 additions & 3 deletions common/errorlistener.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2019 Broadcom Inc.
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
* its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,8 +63,11 @@ namespace swss {
json j = json::parse(data);

// Filter the error notifications that the caller is not interested in.
if (!(((m_errorFlags & ERR_NOTIFY_POSITIVE_ACK) && (j["rc"] == "SWSS_RC_SUCCESS")) ||
((m_errorFlags & ERR_NOTIFY_FAIL) && (j["rc"] != "SWSS_RC_SUCCESS"))))
if ((j["rc"] == "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_POSITIVE_ACK))
{
return -1;
}
if ((j["rc"] != "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_FAIL))
{
return -1;
}
Expand Down
11 changes: 6 additions & 5 deletions common/errorlistener.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2019 Broadcom Inc.
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
* its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +21,7 @@
#include "notificationconsumer.h"
#include "selectable.h"
#include "table.h"
#include <dbconnector.h>
#include "dbconnector.h"

// Error notifications of interest to the error listener
typedef enum
Expand All @@ -39,10 +40,10 @@ namespace swss {

static std::string getErrorChannelName(std::string& appTableName)
{
std::string errorChnl = "ERROR_";
errorChnl += appTableName + "_CHANNEL";
std::string errorChannel = "ERROR_";
errorChannel += appTableName + "_CHANNEL";

return errorChnl;
return errorChannel;
}

int getFd() { return m_errorNotificationConsumer->getFd(); }
Expand Down
33 changes: 15 additions & 18 deletions common/errormap.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2019 Broadcom Inc.
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
* its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,16 +24,17 @@ namespace swss {
ErrorMap::~ErrorMap() { }

const ErrorMap::SwssStrToRCMap ErrorMap::m_swssStrToRC = {
{ std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) },
{ std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) },
{ std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) },
{ std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) },
{ std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) },
{ std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) },
{ std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) },
{ std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) },
{ std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) },
{ std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) }
{ std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) },
{ std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) },
{ std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) },
{ std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) },
{ std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) },
{ std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) },
{ std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) },
{ std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) },
{ std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) },
{ std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) },
{ std::make_pair("SWSS_RC_INVALID_OBJECT_ID", SWSS_RC_INVALID_OBJECT_ID)}
};

const ErrorMap::SaiToSwssRCMap ErrorMap::m_saiToSwssRC = {
Expand All @@ -45,15 +47,10 @@ namespace swss {
{ "SAI_STATUS_TABLE_FULL", "SWSS_RC_TABLE_FULL" },
{ "SAI_STATUS_OBJECT_IN_USE", "SWSS_RC_IN_USE" },
{ "SAI_STATUS_NOT_IMPLEMENTED", "SWSS_RC_NOT_IMPLEMENTED" },
{ "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" }
{ "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" },
{ "SAI_STATUS_INVALID_OBJECT_ID", "SWSS_RC_INVALID_OBJECT_ID" }
};

ErrorMap &ErrorMap::getInstance()
{
static ErrorMap m_errorMap;
return m_errorMap;
}

std::string ErrorMap::getSwssRCStr(const std::string &saiRCStr)
{
std::string swssRCStr;
Expand Down
5 changes: 3 additions & 2 deletions common/errormap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2019 Broadcom Inc.
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
* its subsidiaries.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,6 +39,7 @@ namespace swss {
SWSS_RC_IN_USE,
SWSS_RC_NOT_IMPLEMENTED,
SWSS_RC_FAILURE,
SWSS_RC_INVALID_OBJECT_ID,
SWSS_RC_UNKNOWN
};

Expand All @@ -47,7 +49,6 @@ namespace swss {
static const SwssStrToRCMap m_swssStrToRC;
static const SaiToSwssRCMap m_saiToSwssRC;

static ErrorMap &getInstance();
static std::string getSwssRCStr(const std::string &saiRCStr);
static SwssRC getSwssRC(const std::string &swssRCStr);
static std::string getSaiRCStr(SwssRC rc);
Expand Down

0 comments on commit 6cf7dfd

Please sign in to comment.