Skip to content

Commit

Permalink
cleanup(libsinsp): substitute static g_screen_w
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Nov 15, 2023
1 parent 4dd9c8a commit bd9b04b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ class SINSP_PUBLIC sinsp : public capture_stats_source
const std::string& get_host_root() const { return m_host_root; }
void set_host_root(const std::string& s) { m_host_root = s; }

const int32_t& get_quantization_interval() const { return m_quantization_interval; }
void set_quantization_interval(const int32_t& v) { m_quantization_interval = v; }

void set_observer(sinsp_observer* observer) { m_observer = observer; }
sinsp_observer* get_observer() const { return m_observer; }

Expand Down Expand Up @@ -1113,6 +1116,8 @@ VISIBILITY_PRIVATE

std::string m_host_root;

int32_t m_quantization_interval = -1;

public:
sinsp_thread_manager* m_thread_manager;

Expand Down
3 changes: 1 addition & 2 deletions userspace/libsinsp/sinsp_filtercheck_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ limitations under the License.
using namespace std;

extern sinsp_evttables g_infotables;
static int32_t g_screen_w = -1;

#define RETURN_EXTRACT_VAR(x) do { \
*len = sizeof((x)); \
Expand Down Expand Up @@ -784,7 +783,7 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
llatency = 11;
}

m_u64val = (uint64_t)(llatency * g_screen_w / 11) + 1;
m_u64val = (uint64_t)(llatency * m_inspector->get_quantization_interval() / 11) + 1;

RETURN_EXTRACT_VAR(m_u64val);
}
Expand Down
4 changes: 1 addition & 3 deletions userspace/libsinsp/sinsp_filtercheck_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ limitations under the License.

using namespace std;

static int32_t g_screen_w = -1;

#define RETURN_EXTRACT_VAR(x) do { \
*len = sizeof((x)); \
return (uint8_t*) &(x); \
Expand Down Expand Up @@ -590,7 +588,7 @@ uint8_t* sinsp_filter_check_tracer::extract(sinsp_evt *evt, OUT uint32_t* len, b
lduration = 11;
}

m_s64val = (uint64_t)(lduration * g_screen_w / 11) + 1;
m_s64val = (uint64_t)(lduration * m_inspector->get_quantization_interval() / 11) + 1;

RETURN_EXTRACT_VAR(m_s64val);
}
Expand Down

0 comments on commit bd9b04b

Please sign in to comment.