Skip to content

Fix Clang warnings #228

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inotifywatchtowerdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <vector>

template <typename Driver>
class ObservedFile;
struct ObservedFile;
template <typename Driver>
class ObservedFileList;

Expand Down
21 changes: 8 additions & 13 deletions src/watchtower.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ class WatchTower {

#include "log.h"

namespace {
bool isSymLink( const std::string& file_name );
std::string directory_path( const std::string& path );
};
inline bool isSymLink( const std::string& file_name );

template <typename Driver>
WatchTower<Driver>::WatchTower()
Expand Down Expand Up @@ -318,18 +315,16 @@ void WatchTower<Driver>::run()
}
}

namespace {
bool isSymLink( const std::string& file_name )
{
bool isSymLink( const std::string& file_name )
{
#ifdef HAVE_SYMLINK
struct stat buf;
struct stat buf;

lstat( file_name.c_str(), &buf );
return ( S_ISLNK(buf.st_mode) );
lstat( file_name.c_str(), &buf );
return ( S_ISLNK(buf.st_mode) );
#else
return false;
return false;
#endif
}
};
}

#endif
26 changes: 11 additions & 15 deletions src/watchtowerlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ class ObservedFileList {
void cleanRefsToExpiredDirs();
};

namespace {
std::string directory_path( const std::string& path );
};
inline std::string directory_path( const std::string& path );

// ObservedFileList class
template <typename Driver>
Expand Down Expand Up @@ -408,21 +406,19 @@ void ObservedFileList<Driver>::cleanRefsToExpiredDirs()
}
}

namespace {
std::string directory_path( const std::string& path )
{
size_t slash_pos = path.rfind( '/' );
std::string directory_path( const std::string& path )
{
size_t slash_pos = path.rfind( '/' );

#ifdef _WIN32
if ( slash_pos == std::string::npos ) {
slash_pos = path.rfind( '\\' );
}
if ( slash_pos == std::string::npos ) {
slash_pos = path.rfind( '\\' );
}

// We need to include the final slash on Windows
++slash_pos;
// We need to include the final slash on Windows
++slash_pos;
#endif

return std::string( path, 0, slash_pos );
}
};
return std::string( path, 0, slash_pos );
}
#endif