Skip to content

Commit

Permalink
chore(userspace/libsinsp): further minor improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dellaluce <[email protected]>
  • Loading branch information
jasondellaluce committed Feb 21, 2024
1 parent b0e6dda commit c7062ea
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions userspace/libsinsp/container_engine/container_engine_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.

#pragma once

#include <memory>

#include <libsinsp/container_engine/container_cache_interface.h>

class sinsp_threadinfo;
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/dns_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include <chrono>
#include <future>
#include <mutex>
#include <memory>
#if !defined(__EMSCRIPTEN__)
#include "tbb/concurrent_unordered_map.h"
#endif
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
#include <optional>
#include <unordered_map>
#include <string_view>
#include <memory>

#include <json/json.h>

Expand Down
12 changes: 6 additions & 6 deletions userspace/libsinsp/eventformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ void sinsp_evt_formatter::set_format(output_format of, const std::string& fmt)

if(last_nontoken_str_start != j)
{
rawstring_check* newtkn = new rawstring_check(lfmt.substr(last_nontoken_str_start, j - last_nontoken_str_start));
m_tokens.emplace_back(std::make_pair("", newtkn));
auto newtkn = std::make_unique<rawstring_check>(lfmt.substr(last_nontoken_str_start, j - last_nontoken_str_start));
m_tokens.emplace_back(std::make_pair("", newtkn.get()));
m_tokenlens.push_back(0);
m_chks_to_free.push_back(std::unique_ptr<sinsp_filter_check>(newtkn));
m_chks_to_free.push_back(std::move(newtkn));
}

if(j == lfmtlen - 1)
Expand Down Expand Up @@ -164,9 +164,9 @@ void sinsp_evt_formatter::set_format(output_format of, const std::string& fmt)

if(last_nontoken_str_start != j)
{
auto chk = new rawstring_check(lfmt.substr(last_nontoken_str_start, j - last_nontoken_str_start));
m_tokens.emplace_back(std::make_pair("", chk));
m_chks_to_free.emplace_back(chk);
auto chk = std::make_unique<rawstring_check>(lfmt.substr(last_nontoken_str_start, j - last_nontoken_str_start));
m_tokens.emplace_back(std::make_pair("", chk.get()));
m_chks_to_free.emplace_back(std::move(chk));
m_tokenlens.push_back(0);
}
}
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/eventformatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
#include <map>
#include <utility>
#include <string>
#include <memory>
#include <json/json.h>

#include <libsinsp/filter_check_list.h>
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ limitations under the License.
#include <set>
#include <string>
#include <vector>
#include <memory>

/** @defgroup filter Filtering events
* Filtering infrastructure.
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/filter_check_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.

#include <string>
#include <vector>
#include <memory>

class sinsp_filter_check;
class filter_check_info;
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/state/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.

#include <functional>
#include <type_traits>
#include <memory>

namespace libsinsp {
namespace state {
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsinsp/test/eventformatter.ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ using namespace std;

TEST(eventformatter, get_field_names)
{
auto inspector = std::make_unique<sinsp>();
sinsp inspector;
sinsp_filter_check_list filterlist;
string output = "this is a sample output %proc.name %fd.type %proc.pid";
sinsp_evt_formatter fmt(inspector.get(), output, filterlist);
sinsp_evt_formatter fmt(&inspector, output, filterlist);
vector<string> output_fields;
fmt.get_field_names(output_fields);
ASSERT_EQ(output_fields.size(), 3);
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsinsp/threadinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ threadinfo_map_t::ptr_t sinsp_thread_manager::get_thread_ref(int64_t tid, bool q
// Done. Add the new thread to the list.
//
add_thread(std::move(newti), false);
sinsp_proc = find_thread(tid, lookup_only);
sinsp_proc = find_thread(tid, lookup_only);
}

return sinsp_proc;
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.

#include <unordered_map>
#include <string>
#include <memory>
#include <libsinsp/container_info.h>
#include <libsinsp/procfs_utils.h>
#include <libscap/scap.h>
Expand Down

0 comments on commit c7062ea

Please sign in to comment.