From ad968e32b30ee6262574bc3e02b20d5b117f5b88 Mon Sep 17 00:00:00 2001 From: Nable 80 Date: Sat, 3 Jan 2015 21:47:51 +0100 Subject: Fix to make clang happy POSIX states that 'd_name' in 'struct dirent' is char[], so it cannot be NULL. This will result in the compiler complainting about an expression which always evaluates to true ... for this compiler (clang). But in some implementations 'd_name' is a 'char*' that's why it's better to keep the check for possible NULL. --- src/FbTk/FileUtil.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/FbTk/FileUtil.cc b/src/FbTk/FileUtil.cc index c92b336..5ae2bc0 100644 --- a/src/FbTk/FileUtil.cc +++ b/src/FbTk/FileUtil.cc @@ -112,9 +112,11 @@ struct dirent *Directory::read() { std::string Directory::readFilename() { dirent *ent = read(); - if (ent == 0) - return ""; - return (ent->d_name ? ent->d_name : ""); + const char* name = 0; + if (ent) { + name = ent->d_name; + } + return (name ? name : ""); } void Directory::close() { -- cgit v0.11.2