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 range-loop-construct warnings #1089

Merged
merged 1 commit into from
Feb 9, 2022
Merged

Conversation

rst0git
Copy link
Member

@rst0git rst0git commented Feb 9, 2022

This pull request fixes the following warnings reported by g++ (GCC) 11:

P4Objects.cpp:656:21: warning: loop variable 'cfg_field' creates a copy from type 'const Json::Value' [-Wrange-loop-construct]
  656 |     for (const auto cfg_field : cfg_fields) {
      |                     ^~~~~~~~~
P4Objects.cpp:656:21: note: use reference type to prevent copying
  656 |     for (const auto cfg_field : cfg_fields) {
      |                     ^~~~~~~~~
      |                     &
simple_pre.cpp:187:19: warning: loop variable 'p' creates a copy from type 'const std::pair<const long unsigned int, bm::McSimplePre::MgidEntry>' [-Wrange-loop-construct]
  187 |   for (const auto p : mgid_entries) {
      |                   ^
simple_pre.cpp:187:19: note: use reference type to prevent copying
  187 |   for (const auto p : mgid_entries) {
      |                   ^
      |                   &
simple_pre.cpp:215:19: warning: loop variable 'p' creates a copy from type 'const std::pair<const long unsigned int, bm::McSimplePre::L2Entry>' [-Wrange-loop-construct]
  215 |   for (const auto p : l2_entries) {
      |                   ^
simple_pre.cpp:215:19: note: use reference type to prevent copying
  215 |   for (const auto p : l2_entries) {
      |                   ^
      |                   &

This patch fixes the following warnings reported by g++ (GCC) 11

P4Objects.cpp:656:21: warning: loop variable 'cfg_field' creates a copy from type 'const Json::Value' [-Wrange-loop-construct]
  656 |     for (const auto cfg_field : cfg_fields) {
      |                     ^~~~~~~~~
P4Objects.cpp:656:21: note: use reference type to prevent copying
  656 |     for (const auto cfg_field : cfg_fields) {
      |                     ^~~~~~~~~
      |                     &

simple_pre.cpp:187:19: warning: loop variable 'p' creates a copy from type 'const std::pair<const long unsigned int, bm::McSimplePre::MgidEntry>' [-Wrange-loop-construct]
  187 |   for (const auto p : mgid_entries) {
      |                   ^
simple_pre.cpp:187:19: note: use reference type to prevent copying
  187 |   for (const auto p : mgid_entries) {
      |                   ^
      |                   &

simple_pre.cpp:215:19: warning: loop variable 'p' creates a copy from type 'const std::pair<const long unsigned int, bm::McSimplePre::L2Entry>' [-Wrange-loop-construct]
  215 |   for (const auto p : l2_entries) {
      |                   ^
simple_pre.cpp:215:19: note: use reference type to prevent copying
  215 |   for (const auto p : l2_entries) {
      |                   ^
      |                   &

Signed-off-by: Radostin Stoyanov <[email protected]>
@antoninbas
Copy link
Member

Build failure seems unrelated. I'll open a separate PR for it.

@antoninbas antoninbas merged commit ed36d8b into p4lang:main Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants