From 26c8b5640f5047ca634ffc47b7df2d579bc4cc2b Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Fri, 26 Feb 2016 10:58:36 -0800 Subject: [PATCH] Fix various lint issues --- include/osquery/hash.h | 2 ++ include/osquery/status.h | 2 +- osquery/filesystem/filesystem.cpp | 2 +- osquery/sql/sqlite_util.h | 3 ++- osquery/tables/applications/browser_utils.h | 2 ++ osquery/tables/events/event_utils.h | 2 ++ osquery/tables/forensic/sleuthkit.cpp | 11 ++++------ osquery/tables/networking/utils.cpp | 23 ++++++++++----------- osquery/tables/system/darwin/iokit_utils.h | 4 +++- osquery/tables/system/darwin/keychain.h | 2 ++ osquery/tables/system/efi_misc.h | 2 ++ osquery/tables/system/smbios_utils.h | 9 +++++--- osquery/tables/system/sysctl_utils.h | 7 +++++-- osquery/tables/system/system_utils.h | 2 ++ osquery/tables/system/user_groups.h | 2 ++ 15 files changed, 47 insertions(+), 28 deletions(-) diff --git a/include/osquery/hash.h b/include/osquery/hash.h index 64a2b66e..2d4ce61b 100644 --- a/include/osquery/hash.h +++ b/include/osquery/hash.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include diff --git a/include/osquery/status.h b/include/osquery/status.h index 6cbe37ef..14276131 100644 --- a/include/osquery/status.h +++ b/include/osquery/status.h @@ -105,7 +105,7 @@ class Status { * } * @endcode */ - operator bool() const { return ok(); } + /* explicit */ operator bool() const { return ok(); } // Below operator implementations useful for testing with gtest diff --git a/osquery/filesystem/filesystem.cpp b/osquery/filesystem/filesystem.cpp index 60a29472..baf2f806 100644 --- a/osquery/filesystem/filesystem.cpp +++ b/osquery/filesystem/filesystem.cpp @@ -72,7 +72,7 @@ Status writeTextFile(const fs::path& path, struct OpenReadableFile { public: - OpenReadableFile(const fs::path& path) { + explicit OpenReadableFile(const fs::path& path) { dropper_ = DropPrivileges::get(); if (dropper_->dropToParent(path)) { // Open the file descriptor and allow caller to perform error checking. diff --git a/osquery/sql/sqlite_util.h b/osquery/sql/sqlite_util.h index f9e63c01..9f6bd5eb 100644 --- a/osquery/sql/sqlite_util.h +++ b/osquery/sql/sqlite_util.h @@ -64,7 +64,8 @@ class SQLiteDBInstance : private boost::noncopyable { private: /// An opaque constructor only used by the DBManager. - SQLiteDBInstance(sqlite3* db) : primary_(true), managed_(true), db_(db) {} + explicit SQLiteDBInstance(sqlite3* db) + : primary_(true), managed_(true), db_(db) {} private: /// Introspection into the database pointer, primary means managed. diff --git a/osquery/tables/applications/browser_utils.h b/osquery/tables/applications/browser_utils.h index 8d5151d9..8c64128f 100644 --- a/osquery/tables/applications/browser_utils.h +++ b/osquery/tables/applications/browser_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include diff --git a/osquery/tables/events/event_utils.h b/osquery/tables/events/event_utils.h index 8f209aaa..3296102d 100644 --- a/osquery/tables/events/event_utils.h +++ b/osquery/tables/events/event_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include diff --git a/osquery/tables/forensic/sleuthkit.cpp b/osquery/tables/forensic/sleuthkit.cpp index 71ef13e8..5090d3df 100644 --- a/osquery/tables/forensic/sleuthkit.cpp +++ b/osquery/tables/forensic/sleuthkit.cpp @@ -29,18 +29,15 @@ namespace osquery { namespace tables { const std::map kTSKTypeNames{ - {TSK_FS_META_TYPE_REG, "regular"}, - {TSK_FS_META_TYPE_DIR, "directory"}, - {TSK_FS_META_TYPE_LNK, "symlink"}, - {TSK_FS_META_TYPE_BLK, "block"}, - {TSK_FS_META_TYPE_CHR, "character"}, - {TSK_FS_META_TYPE_FIFO, "fifo"}, + {TSK_FS_META_TYPE_REG, "regular"}, {TSK_FS_META_TYPE_DIR, "directory"}, + {TSK_FS_META_TYPE_LNK, "symlink"}, {TSK_FS_META_TYPE_BLK, "block"}, + {TSK_FS_META_TYPE_CHR, "character"}, {TSK_FS_META_TYPE_FIFO, "fifo"}, {TSK_FS_META_TYPE_SOCK, "socket"}, }; class DeviceHelper : private boost::noncopyable { public: - DeviceHelper(const std::string& device_path) + explicit DeviceHelper(const std::string& device_path) : image_(std::make_shared()), volume_(std::make_shared()), device_path_(device_path) {} diff --git a/osquery/tables/networking/utils.cpp b/osquery/tables/networking/utils.cpp index b0508f8f..6b509702 100644 --- a/osquery/tables/networking/utils.cpp +++ b/osquery/tables/networking/utils.cpp @@ -11,20 +11,19 @@ #include #include +#if defined(__linux__) || defined(__FreeBSD__) +#include +#include +#include +#include +#endif + +#if defined(__APPLE__) || defined(__FreeBSD__) +#include +#endif + #if defined(__linux__) -#include -#include -#include -#include #define AF_LINK AF_PACKET -#elif defined(__FreeBSD__) -#include -#include -#include -#include -#include -#elif defined(__APPLE__) -#include #endif #include diff --git a/osquery/tables/system/darwin/iokit_utils.h b/osquery/tables/system/darwin/iokit_utils.h index c85f6799..343fb400 100644 --- a/osquery/tables/system/darwin/iokit_utils.h +++ b/osquery/tables/system/darwin/iokit_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include @@ -34,7 +36,7 @@ struct IOKitPCIProperties { std::string driver; /// Populate IOKit PCI device properties from the "compatible" property. - IOKitPCIProperties(const std::string& compatible); + explicit IOKitPCIProperties(const std::string& compatible); }; inline void idToHex(std::string& id) { diff --git a/osquery/tables/system/darwin/keychain.h b/osquery/tables/system/darwin/keychain.h index 406b4f25..6e461641 100644 --- a/osquery/tables/system/darwin/keychain.h +++ b/osquery/tables/system/darwin/keychain.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include #include diff --git a/osquery/tables/system/efi_misc.h b/osquery/tables/system/efi_misc.h index eb6c4807..42968dba 100644 --- a/osquery/tables/system/efi_misc.h +++ b/osquery/tables/system/efi_misc.h @@ -9,6 +9,8 @@ * */ +#pragma once + /** * @brief EFI DevicePath GUIDs, structs, and macros. */ diff --git a/osquery/tables/system/smbios_utils.h b/osquery/tables/system/smbios_utils.h index 0cf612df..37699ad3 100644 --- a/osquery/tables/system/smbios_utils.h +++ b/osquery/tables/system/smbios_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include namespace osquery { @@ -43,9 +45,10 @@ constexpr uint8_t kSMBIOSTypeSystem = 1; class SMBIOSParser : private boost::noncopyable { public: /// Walk the tables and apply a predicate. - virtual void tables(std::function - predicate); + virtual void tables(std::function predicate); public: virtual ~SMBIOSParser() {} diff --git a/osquery/tables/system/sysctl_utils.h b/osquery/tables/system/sysctl_utils.h index ef0de817..ea880f8a 100644 --- a/osquery/tables/system/sysctl_utils.h +++ b/osquery/tables/system/sysctl_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include @@ -35,7 +37,8 @@ void genControlInfo(int* oid, const std::map& config); /// Must be implemented by the platform. -void genControlInfoFromName(const std::string& name, QueryData& results, - const std::map& config); +void genControlInfoFromName(const std::string& name, + QueryData& results, + const std::map& config); } } diff --git a/osquery/tables/system/system_utils.h b/osquery/tables/system/system_utils.h index 326a3af9..045ea63b 100644 --- a/osquery/tables/system/system_utils.h +++ b/osquery/tables/system/system_utils.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include namespace osquery { diff --git a/osquery/tables/system/user_groups.h b/osquery/tables/system/user_groups.h index 220857bf..259ac3be 100644 --- a/osquery/tables/system/user_groups.h +++ b/osquery/tables/system/user_groups.h @@ -8,6 +8,8 @@ * */ +#pragma once + #include #include