Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential defects #2516

Merged
merged 1 commit into from
Jan 23, 2023
Merged

Conversation

Liran-Ar
Copy link
Contributor

@Liran-Ar Liran-Ar commented Nov 13, 2022

What I did
Fix the following potential risks:

  • Uncaught exceptions in /src/nvos-swss/orchagent/main.cpp and /src/nvos-swss/portsyncd/portsyncd.cpp
  • Uninitialized scalar fields in /src/nvos-swss/orchagent/port.h
  • Unchecked return value in /src/nvos-swss/orchagent/portsorch.cpp
  • Pointer to local outside scope in /src/nvos-swss/orchagent/portsorch.cpp

How I did it

  • Add "catch" to the uncaught exceptions
  • Add initialization value to the uninitialized fields
  • Add a check to the unchecked return value
  • Delete an unnecessary comma

How I verified it

  • Inspection and sanity tests

Signed-off-by: Liran Artzi <[email protected]>
DBConnector appl_db("APPL_DB", 0);
DBConnector state_db("STATE_DB", 0);
ProducerStateTable p(&appl_db, APP_PORT_TABLE_NAME);
DBConnector cfgDb("CONFIG_DB", 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are unexpected diffs due to tab space. Can you fix the spacing diff in this PR and have only the relevant ones?

Copy link
Contributor Author

@Liran-Ar Liran-Ar Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, these indents were done on purpose since the code was inserted under the "try" block, stated on line 49.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @prsunny , the PR merging is blocked due to coverage check failure (only 4 code lines are missing to reach the minimum threshold).
We've tried to expand existing unit tests or create new ones but found out that covering the missing lines via unit tests is very complex because it is called only from main() function.
Therefore, and because I didn't add any new functionality, I would ask for a waiver on the coverage check for this very unique case, Is it possible?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @prsunny , the PR merging is blocked due to coverage check failure (only 4 code lines are missing to reach the minimum threshold). We've tried to expand existing unit tests or create new ones but found out that covering the missing lines via unit tests is very complex because it is called only from main() function. Therefore, and because I didn't add any new functionality, I would ask for a waiver on the coverage check for this very unique case, Is it possible?

@prsunny could you please refer to this question?

@liat-grozovik liat-grozovik changed the title Fix potential risks Fix potential defects: Uncaught exceptions, Uninitialized scalar, Unchecked return value and Pointer to local outside scope Nov 28, 2022
@liat-grozovik
Copy link
Collaborator

@Liran-Ar please review the coverage report of the PR and check what type of tests need to be added on code changes.

@Liran-Ar Liran-Ar closed this Dec 7, 2022
@Liran-Ar Liran-Ar reopened this Dec 7, 2022
@Liran-Ar
Copy link
Contributor Author

Liran-Ar commented Dec 7, 2022

/AzurePipelines run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 2516 in repo sonic-net/sonic-swss

@liat-grozovik
Copy link
Collaborator

@prsunny could you please review the latest comment to understand if we can move forward with this merge?

@liat-grozovik
Copy link
Collaborator

/azp run Azure.sonic-swss

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@prsunny
Copy link
Collaborator

prsunny commented Jan 17, 2023

@qiluo-msft for viz

@liat-grozovik liat-grozovik merged commit 7f03db2 into sonic-net:master Jan 23, 2023
@liat-grozovik liat-grozovik changed the title Fix potential defects: Uncaught exceptions, Uninitialized scalar, Unchecked return value and Pointer to local outside scope Fix potential defects Jan 23, 2023
@qiluo-msft
Copy link
Contributor

LGTM

dprital added a commit to dprital/sonic-buildimage that referenced this pull request Jan 30, 2023
Update sonic-swss submodule pointer to include the following:
* a2a483d [acl] Add new ACL key BTH_OPCODE and AETH_SYNDROME  ([sonic-net#2617](sonic-net/sonic-swss#2617))
* 9d1f66b [bfdorch] add local discriminator to state DB ([sonic-net#2629](sonic-net/sonic-swss#2629))
* c54b3d1 Vxlan tunnel endpoint custom monitoring APPL DB table. ([sonic-net#2589](sonic-net/sonic-swss#2589))
* 7f03db2 Fix potential risks ([sonic-net#2516](sonic-net/sonic-swss#2516))
* 383ee68 [refactor]Refactoring sai handle status ([sonic-net#2621](sonic-net/sonic-swss#2621))
* cd95972 Fix issue 13341 ARP entry can be out of sync between kernel and APPL_DB if multiple updates are received from RTNL ([sonic-net#2619](sonic-net/sonic-swss#2619))
* a01470f Remove TODO comments that are no longer relevant ([sonic-net#2622](sonic-net/sonic-swss#2622))
* d058390 Changed the BFD default detect multiplier to 10x ([sonic-net#2614](sonic-net/sonic-swss#2614))
* d78b528 [MuxOrch] Enabling neighbor when adding in active state ([sonic-net#2601](sonic-net/sonic-swss#2601))
* 4ebdad1 [routesync] Fix for stale dynamic neighbor ([sonic-net#2553](sonic-net/sonic-swss#2553))
* 8857f92 Added new attributes for Vnet and Vxlan ecmp configurations. ([sonic-net#2584](sonic-net/sonic-swss#2584))
* b6bbc3e Revert [voq][chassis]Add show fabric counters port/queue commands (2522) ([sonic-net#2611](sonic-net/sonic-swss#2611))
* 52406e2 Add missing parameter to on_switch_shutdown_request method. ([sonic-net#2567](sonic-net/sonic-swss#2567))
* 4ac9ad9 Increase diff coverage to 80% ([sonic-net#2599](sonic-net/sonic-swss#2599))
* 8a0bb36 Handle Mac address 'none' ([sonic-net#2593](sonic-net/sonic-swss#2593))
* f496ab3 [vstest] Only collect stdout of orchagent_restart_check in vstest ([sonic-net#2597](sonic-net/sonic-swss#2597))
* 1dab495 Avoid aborting orchagent when setting TUNNEL attributes ([sonic-net#2591](sonic-net/sonic-swss#2591))
* 4395cea Fix neighbor doesn't update all attribute ([sonic-net#2577](sonic-net/sonic-swss#2577))

Signed-off-by: dprital <[email protected]>
liat-grozovik pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Feb 1, 2023
Update sonic-swss submodule pointer to include the following:
* a2a483d [acl] Add new ACL key BTH_OPCODE and AETH_SYNDROME  ([#2617](sonic-net/sonic-swss#2617))
* 9d1f66b [bfdorch] add local discriminator to state DB ([#2629](sonic-net/sonic-swss#2629))
* c54b3d1 Vxlan tunnel endpoint custom monitoring APPL DB table. ([#2589](sonic-net/sonic-swss#2589))
* 7f03db2 Fix potential risks ([#2516](sonic-net/sonic-swss#2516))
* 383ee68 [refactor]Refactoring sai handle status ([#2621](sonic-net/sonic-swss#2621))
* cd95972 Fix issue 13341 ARP entry can be out of sync between kernel and APPL_DB if multiple updates are received from RTNL ([#2619](sonic-net/sonic-swss#2619))
* a01470f Remove TODO comments that are no longer relevant ([#2622](sonic-net/sonic-swss#2622))
* d058390 Changed the BFD default detect multiplier to 10x ([#2614](sonic-net/sonic-swss#2614))
* d78b528 [MuxOrch] Enabling neighbor when adding in active state ([#2601](sonic-net/sonic-swss#2601))
* 4ebdad1 [routesync] Fix for stale dynamic neighbor ([#2553](sonic-net/sonic-swss#2553))
* 8857f92 Added new attributes for Vnet and Vxlan ecmp configurations. ([#2584](sonic-net/sonic-swss#2584))
* b6bbc3e Revert [voq][chassis]Add show fabric counters port/queue commands (2522) ([#2611](sonic-net/sonic-swss#2611))
* 52406e2 Add missing parameter to on_switch_shutdown_request method. ([#2567](sonic-net/sonic-swss#2567))
* 4ac9ad9 Increase diff coverage to 80% ([#2599](sonic-net/sonic-swss#2599))
* 8a0bb36 Handle Mac address 'none' ([#2593](sonic-net/sonic-swss#2593))
* f496ab3 [vstest] Only collect stdout of orchagent_restart_check in vstest ([#2597](sonic-net/sonic-swss#2597))
* 1dab495 Avoid aborting orchagent when setting TUNNEL attributes ([#2591](sonic-net/sonic-swss#2591))
* 4395cea Fix neighbor doesn't update all attribute ([#2577](sonic-net/sonic-swss#2577))

Signed-off-by: dprital <[email protected]>
StormLiangMS pushed a commit that referenced this pull request Feb 10, 2023
- What I did
Fix the following potential risks:

Uncaught exceptions in /src/nvos-swss/orchagent/main.cpp and /src/nvos-swss/portsyncd/portsyncd.cpp
Uninitialized scalar fields in /src/nvos-swss/orchagent/port.h
Unchecked return value in /src/nvos-swss/orchagent/portsorch.cpp
Pointer to local outside scope in /src/nvos-swss/orchagent/portsorch.cpp

- How I did it
Add "catch" to the uncaught exceptions
Add initialization value to the uninitialized fields
Add a check to the unchecked return value
Delete an unnecessary comma

- How I verified it
Inspection and sanity tests
Signed-off-by: Liran Artzi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants