GithubHelp home page GithubHelp logo

Miscellaneous Issues about sai-p4-bm HOT 2 OPEN

hesingh avatar hesingh commented on September 27, 2024
Miscellaneous Issues

from sai-p4-bm.

Comments (2)

hesingh avatar hesingh commented on September 27, 2024

The following code changes to SAI-P4-BM/p4-switch/behavioral-model have fixed the build. I wonder why these changes do not exist in this repo's behavioral-model?

diff --git a/include/bm/bm_apps/packet_pipe.h b/include/bm/bm_apps/packet_pipe.h
index 0478b29..c8ed181 100644
--- a/include/bm/bm_apps/packet_pipe.h
+++ b/include/bm/bm_apps/packet_pipe.h
@@ -25,6 +25,7 @@
 #include <thread>
 #include <mutex>
 #include <memory>
+#include <functional>
 
 namespace bm_apps {
 
@@ -33,8 +34,8 @@ class PacketInjectImp;
 class PacketInject {
  public:
   // the library owns the memory, make a copy if you need before returning
-  typedef std::function<void(int port_num, const char *buffer, int len,
-                             void *cookie)> PacketReceiveCb;
+  using PacketReceiveCb = std::function<void(int port_num, const char *buffer,
+                                             int len, void *cookie)>;
 
   explicit PacketInject(const std::string &addr);
 
diff --git a/include/bm/bm_sim/packet_handler.h b/include/bm/bm_sim/packet_handler.h
index 53ae69e..6d5825e 100644
--- a/include/bm/bm_sim/packet_handler.h
+++ b/include/bm/bm_sim/packet_handler.h
@@ -16,12 +16,14 @@
 #ifndef BM_BM_SIM_PACKET_HANDLER_H_
 #define BM_BM_SIM_PACKET_HANDLER_H_
 
+#include <functional>
+
 namespace bm {
 
 class PacketDispatcherIface {
  public:
-  typedef std::function<void(int port_num, const char *buffer,
-                             int len, void* cookie)> PacketHandler;
+  using PacketHandler = std::function<void(int port_num, const char *buffer,
+                                           int len, void* cookie)>;
   enum class ReturnCode {
     SUCCESS,
     UNSUPPORTED,
diff --git a/src/bm_sim/pcap_file.cpp b/src/bm_sim/pcap_file.cpp
index 6c682c5..4b646eb 100644
--- a/src/bm_sim/pcap_file.cpp
+++ b/src/bm_sim/pcap_file.cpp
@@ -150,9 +150,12 @@ PcapFileIn::current() const {
     }
   case State::Opened:
     pcap_fatal_error("Must call moveNext() before calling current()");
+    break;
   case State::AtEnd:
     pcap_fatal_error("Cannot read past end-of-file");
+    break;
   case State::Uninitialized:
+    /* fallthrough */
   default:
     pcap_fatal_error("Unexpected state");
   }
@@ -192,9 +195,9 @@ PcapFilesReader::scan() {
     }
 
     int earliest_index = -1;
-    const struct timeval *earliest_time;
+    const struct timeval *earliest_time = nullptr;
 
-    for (unsigned i=0; i < files.size(); i++) {
+    for (unsigned int i = 0; i < files.size(); i++) {
       auto file = files.at(i).get();
       if (file->atEOF()) continue;
 
@@ -211,7 +214,7 @@ PcapFilesReader::scan() {
       }
     }
 
-    assert(earliest_index >= 0);
+    assert(earliest_index >= 0 && earliest_time != nullptr);
     struct timeval delay;
 
     BMLOG_DEBUG("Pcap reader: first packet to send {}",
diff --git a/third_party/spdlog/bm/spdlog/spdlog.h b/third_party/spdlog/bm/spdlog/spdlog.h
index aef0406..5596ecd 100644
--- a/third_party/spdlog/bm/spdlog/spdlog.h
+++ b/third_party/spdlog/bm/spdlog/spdlog.h
@@ -32,6 +32,8 @@
 #include "common.h"
 #include "logger.h"
 
+#include <functional>
+
 namespace spdlog
 {
 // Return an existing logger or nullptr if a logger with such name doesn't exist.

from sai-p4-bm.

YonatanPitz avatar YonatanPitz commented on September 27, 2024

Hi,

I've changed README with the --recursive flag.
Can you send these other changes in a PR so it will be easier to review?
by the way, I've lately managed to install this repo successfully on a clean ubuntu 16.04 machine

Regarding P4_16, as you understand this repo is not actively maintained at the moment, some of the work to do so was done, but currently we postponed working on this project.

Thanks,
Yonatan

from sai-p4-bm.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.