Skip to content

Commit b77f4ad

Browse files
author
Shu0T1an ChenG
committed
update pull request
1 parent 8e9a889 commit b77f4ad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

portsyncd/linksync.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,24 @@ LinkSync::LinkSync(DBConnector *appl_db, DBConnector *state_db) :
6161
cmd = "cat /sys/class/net/" + key + "/operstate";
6262
try
6363
{
64-
exec(cmd, res);
64+
EXEC_WITH_ERROR_THROW(cmd, res);
6565
}
6666
catch (...)
6767
{
6868
SWSS_LOG_WARN("Failed to get %s oper status", key.c_str());
6969
continue;
7070
}
71+
7172
/* Remove the trailing newline */
72-
if (res.length() > 1 && res.at(res.length() - 1) == '\n')
73+
if (res.length() >= 1 && res.at(res.length() - 1) == '\n')
7374
{
7475
res.erase(res.length() - 1);
7576
/* The value of operstate will be either up or down */
77+
if (res != "up" && res != "down")
78+
{
79+
SWSS_LOG_WARN("Unknown %s oper status %s",
80+
key.c_str(), res.c_str());
81+
}
7682
FieldValueTuple fv("oper_status", res);
7783
vector<FieldValueTuple> fvs;
7884
fvs.push_back(fv);

0 commit comments

Comments
 (0)