Merge branch 'warnings'

This commit is contained in:
Pavel Kirienko
2016-08-15 11:11:56 +03:00
77 changed files with 372 additions and 319 deletions
@@ -85,15 +85,15 @@ protected:
enum { InvalidFD = -1 };
FDCacheItem() :
next_(NULL),
next_(UAVCAN_NULLPTR),
last_access_(0),
fd_(InvalidFD),
oflags_(0),
path_(NULL)
path_(UAVCAN_NULLPTR)
{ }
FDCacheItem(int fd, const char* path, int oflags) :
next_(NULL),
next_(UAVCAN_NULLPTR),
last_access_(0),
fd_(fd),
oflags_(oflags),
@@ -111,7 +111,7 @@ protected:
bool valid() const
{
return path_ != NULL;
return path_ != UAVCAN_NULLPTR;
}
int getFD() const
@@ -127,7 +127,7 @@ protected:
std::time_t acessed()
{
using namespace std;
last_access_ = time(NULL);
last_access_ = time(UAVCAN_NULLPTR);
return getAccess();
}
@@ -139,7 +139,7 @@ protected:
bool expired() const
{
using namespace std;
return 0 == last_access_ || (time(NULL) - last_access_) > MaxAgeSeconds;
return 0 == last_access_ || (time(UAVCAN_NULLPTR) - last_access_) > MaxAgeSeconds;
}
bool equals(const char* path, int oflags) const
@@ -165,7 +165,7 @@ protected:
return pi;
}
}
return NULL;
return UAVCAN_NULLPTR;
}
FDCacheItem* find(int fd)
@@ -177,7 +177,7 @@ protected:
return pi;
}
}
return NULL;
return UAVCAN_NULLPTR;
}
FDCacheItem* add(FDCacheItem* pi)
@@ -239,7 +239,7 @@ protected:
public:
FDCache(uavcan::INode& node) :
TimerBase(node),
head_(NULL)
head_(UAVCAN_NULLPTR)
{ }
virtual ~FDCache()
@@ -259,7 +259,7 @@ protected:
FDCacheItem* pi = find(path, oflags);
if (pi != NULL)
if (pi != UAVCAN_NULLPTR)
{
pi->acessed();
}
@@ -281,10 +281,10 @@ protected:
{
/* Allocation worked but clone or path failed */
delete pi;
pi = NULL;
pi = UAVCAN_NULLPTR;
}
if (pi == NULL)
if (pi == UAVCAN_NULLPTR)
{
/*
* If allocation fails no harm just can not cache it
@@ -301,7 +301,7 @@ protected:
virtual int close(int fd, bool done)
{
FDCacheItem* pi = find(fd);
if (pi == NULL)
if (pi == UAVCAN_NULLPTR)
{
/*
* If not found just close it
@@ -318,11 +318,11 @@ protected:
FDCacheBase& getFDCache()
{
if (fdcache_ == NULL)
if (fdcache_ == UAVCAN_NULLPTR)
{
fdcache_ = new FDCache(node_);
if (fdcache_ == NULL)
if (fdcache_ == UAVCAN_NULLPTR)
{
fdcache_ = &fallback_;
}
@@ -435,7 +435,7 @@ protected:
public:
BasicFileServerBackend(uavcan::INode& node) :
fdcache_(NULL),
fdcache_(UAVCAN_NULLPTR),
node_(node)
{ }
@@ -444,7 +444,7 @@ public:
if (fdcache_ != &fallback_)
{
delete fdcache_;
fdcache_ = NULL;
fdcache_ = UAVCAN_NULLPTR;
}
}
};
@@ -184,9 +184,9 @@ class FirmwareVersionChecker : public uavcan::IFirmwareVersionChecker
if (fd >= 0)
{
AppDescriptor* pdescriptor = NULL;
AppDescriptor* pdescriptor = UAVCAN_NULLPTR;
while (pdescriptor == NULL)
while (pdescriptor == UAVCAN_NULLPTR)
{
int len = read(fd, chunk, sizeof(chunk));
@@ -274,15 +274,15 @@ protected:
fname_root[n++] = getPathSeparator();
fname_root[n++] = '\0';
if (fwdir != NULL)
if (fwdir != UAVCAN_NULLPTR)
{
struct dirent* pfile = NULL;
while ((pfile = readdir(fwdir)) != NULL)
struct dirent* pfile = UAVCAN_NULLPTR;
while ((pfile = readdir(fwdir)) != UAVCAN_NULLPTR)
{
if (DIRENT_ISFILE(pfile->d_type))
{
// Open any bin file in there.
if (strstr(pfile->d_name, ".bin") != NULL)
if (strstr(pfile->d_name, ".bin") != UAVCAN_NULLPTR)
{
PathString full_src_path = fname_root;
full_src_path += pfile->d_name;
@@ -107,7 +107,7 @@ public:
int init()
{
return pthread_mutex_init(&mutex_, NULL);
return pthread_mutex_init(&mutex_, UAVCAN_NULLPTR);
}
int deinit()
@@ -77,9 +77,9 @@ namespace
CanIface* ifaces[UAVCAN_STM32_NUM_IFACES] =
{
NULL
UAVCAN_NULLPTR
#if UAVCAN_STM32_NUM_IFACES > 1
, NULL
, UAVCAN_NULLPTR
#endif
};
@@ -91,7 +91,7 @@ inline void handleTxInterrupt(uavcan::uint8_t iface_index)
{
utc_usec--;
}
if (ifaces[iface_index] != NULL)
if (ifaces[iface_index] != UAVCAN_NULLPTR)
{
ifaces[iface_index]->handleTxInterrupt(utc_usec);
}
@@ -109,7 +109,7 @@ inline void handleRxInterrupt(uavcan::uint8_t iface_index, uavcan::uint8_t fifo_
{
utc_usec--;
}
if (ifaces[iface_index] != NULL)
if (ifaces[iface_index] != UAVCAN_NULLPTR)
{
ifaces[iface_index]->handleRxInterrupt(fifo_index, utc_usec);
}
@@ -809,7 +809,7 @@ uavcan::CanSelectMasks CanDriver::makeSelectMasks(const uavcan::CanFrame* (& pen
// Iface 0
msk.read = if0_.isRxBufferEmpty() ? 0 : 1;
if (pending_tx[0] != NULL)
if (pending_tx[0] != UAVCAN_NULLPTR)
{
msk.write = if0_.canAcceptNewTxFrame(*pending_tx[0]) ? 1 : 0;
}
@@ -821,7 +821,7 @@ uavcan::CanSelectMasks CanDriver::makeSelectMasks(const uavcan::CanFrame* (& pen
msk.read |= 1 << 1;
}
if (pending_tx[1] != NULL)
if (pending_tx[1] != UAVCAN_NULLPTR)
{
if (if1_.canAcceptNewTxFrame(*pending_tx[1]))
{
@@ -982,7 +982,7 @@ int CanDriver::init(const uavcan::uint32_t bitrate, const CanIface::OperatingMod
if (res < 0) // a typical race condition.
{
UAVCAN_STM32_LOG("Iface 0 init failed %i", res);
ifaces[0] = NULL;
ifaces[0] = UAVCAN_NULLPTR;
goto fail;
}
@@ -996,7 +996,7 @@ int CanDriver::init(const uavcan::uint32_t bitrate, const CanIface::OperatingMod
if (res < 0)
{
UAVCAN_STM32_LOG("Iface 1 init failed %i", res);
ifaces[1] = NULL;
ifaces[1] = UAVCAN_NULLPTR;
goto fail;
}
#endif
@@ -1017,7 +1017,7 @@ CanIface* CanDriver::getIface(uavcan::uint8_t iface_index)
{
return ifaces[iface_index];
}
return NULL;
return UAVCAN_NULLPTR;
}
bool CanDriver::hadActivity()
@@ -200,7 +200,7 @@ int BusEvent::addPollWaiter(::pollfd* fds)
{
for (unsigned i = 0; i < MaxPollWaiters; i++)
{
if (pollset_[i] == NULL)
if (pollset_[i] == UAVCAN_NULLPTR)
{
pollset_[i] = fds;
return 0;
@@ -215,7 +215,7 @@ int BusEvent::removePollWaiter(::pollfd* fds)
{
if (fds == pollset_[i])
{
pollset_[i] = NULL;
pollset_[i] = UAVCAN_NULLPTR;
return 0;
}
}
@@ -268,7 +268,7 @@ void BusEvent::signalFromInterrupt()
for (unsigned i = 0; i < MaxPollWaiters; i++)
{
::pollfd* const fd = pollset_[i];
if (fd != NULL)
if (fd != UAVCAN_NULLPTR)
{
fd->revents |= fd->events & POLLIN;
if ((fd->revents != 0) && (fd->sem->semcount <= 0))
@@ -31,7 +31,7 @@ void init()
chibios_rt::System::init();
sdStart(&STDOUT_SD, NULL);
sdStart(&STDOUT_SD, nullptr);
}
__attribute__((noreturn))