Skip to content

Commit 6cf7dfd

Browse files
committed
Addressed review comments
1 parent 6c4d633 commit 6cf7dfd

File tree

4 files changed

+31
-28
lines changed

4 files changed

+31
-28
lines changed

common/errorlistener.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2019 Broadcom Inc.
2+
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
3+
* its subsidiaries.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -62,8 +63,11 @@ namespace swss {
6263
json j = json::parse(data);
6364

6465
// Filter the error notifications that the caller is not interested in.
65-
if (!(((m_errorFlags & ERR_NOTIFY_POSITIVE_ACK) && (j["rc"] == "SWSS_RC_SUCCESS")) ||
66-
((m_errorFlags & ERR_NOTIFY_FAIL) && (j["rc"] != "SWSS_RC_SUCCESS"))))
66+
if ((j["rc"] == "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_POSITIVE_ACK))
67+
{
68+
return -1;
69+
}
70+
if ((j["rc"] != "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_FAIL))
6771
{
6872
return -1;
6973
}

common/errorlistener.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2019 Broadcom Inc.
2+
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
3+
* its subsidiaries.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
2021
#include "notificationconsumer.h"
2122
#include "selectable.h"
2223
#include "table.h"
23-
#include <dbconnector.h>
24+
#include "dbconnector.h"
2425

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

4041
static std::string getErrorChannelName(std::string& appTableName)
4142
{
42-
std::string errorChnl = "ERROR_";
43-
errorChnl += appTableName + "_CHANNEL";
43+
std::string errorChannel = "ERROR_";
44+
errorChannel += appTableName + "_CHANNEL";
4445

45-
return errorChnl;
46+
return errorChannel;
4647
}
4748

4849
int getFd() { return m_errorNotificationConsumer->getFd(); }

common/errormap.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2019 Broadcom Inc.
2+
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
3+
* its subsidiaries.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -23,16 +24,17 @@ namespace swss {
2324
ErrorMap::~ErrorMap() { }
2425

2526
const ErrorMap::SwssStrToRCMap ErrorMap::m_swssStrToRC = {
26-
{ std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) },
27-
{ std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) },
28-
{ std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) },
29-
{ std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) },
30-
{ std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) },
31-
{ std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) },
32-
{ std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) },
33-
{ std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) },
34-
{ std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) },
35-
{ std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) }
27+
{ std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) },
28+
{ std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) },
29+
{ std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) },
30+
{ std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) },
31+
{ std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) },
32+
{ std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) },
33+
{ std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) },
34+
{ std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) },
35+
{ std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) },
36+
{ std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) },
37+
{ std::make_pair("SWSS_RC_INVALID_OBJECT_ID", SWSS_RC_INVALID_OBJECT_ID)}
3638
};
3739

3840
const ErrorMap::SaiToSwssRCMap ErrorMap::m_saiToSwssRC = {
@@ -45,15 +47,10 @@ namespace swss {
4547
{ "SAI_STATUS_TABLE_FULL", "SWSS_RC_TABLE_FULL" },
4648
{ "SAI_STATUS_OBJECT_IN_USE", "SWSS_RC_IN_USE" },
4749
{ "SAI_STATUS_NOT_IMPLEMENTED", "SWSS_RC_NOT_IMPLEMENTED" },
48-
{ "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" }
50+
{ "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" },
51+
{ "SAI_STATUS_INVALID_OBJECT_ID", "SWSS_RC_INVALID_OBJECT_ID" }
4952
};
5053

51-
ErrorMap &ErrorMap::getInstance()
52-
{
53-
static ErrorMap m_errorMap;
54-
return m_errorMap;
55-
}
56-
5754
std::string ErrorMap::getSwssRCStr(const std::string &saiRCStr)
5855
{
5956
std::string swssRCStr;

common/errormap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright 2019 Broadcom Inc.
2+
* Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
3+
* its subsidiaries.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -38,6 +39,7 @@ namespace swss {
3839
SWSS_RC_IN_USE,
3940
SWSS_RC_NOT_IMPLEMENTED,
4041
SWSS_RC_FAILURE,
42+
SWSS_RC_INVALID_OBJECT_ID,
4143
SWSS_RC_UNKNOWN
4244
};
4345

@@ -47,7 +49,6 @@ namespace swss {
4749
static const SwssStrToRCMap m_swssStrToRC;
4850
static const SaiToSwssRCMap m_saiToSwssRC;
4951

50-
static ErrorMap &getInstance();
5152
static std::string getSwssRCStr(const std::string &saiRCStr);
5253
static SwssRC getSwssRC(const std::string &swssRCStr);
5354
static std::string getSaiRCStr(SwssRC rc);

0 commit comments

Comments
 (0)