1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Miscellaneous fixes for some PVS static analyser warnings

This commit is contained in:
jules 2017-01-03 17:22:01 +00:00
parent f3be41caba
commit 92f3a1e88f
6 changed files with 24 additions and 18 deletions

View file

@ -369,8 +369,10 @@ bool Time::setSystemTimeToThisTime() const
// do this twice because of daylight saving conversion problems - the // do this twice because of daylight saving conversion problems - the
// first one sets it up, the second one kicks it in. // first one sets it up, the second one kicks it in.
return SetLocalTime (&st) != 0 // NB: the local variable is here to avoid analysers warning about having
&& SetLocalTime (&st) != 0; // two identical sub-expressions in the return statement
bool firstCallToSetTimezone = SetLocalTime (&st) != 0;
return firstCallToSetTimezone && SetLocalTime (&st) != 0;
} }
int SystemStats::getPageSize() int SystemStats::getPageSize()

View file

@ -40,9 +40,11 @@
#if JUCE_WINDOWS #if JUCE_WINDOWS
typedef int juce_socklen_t; typedef int juce_socklen_t;
typedef SOCKET SocketHandle; typedef SOCKET SocketHandle;
static const SocketHandle invalidSocket = INVALID_SOCKET;
#else #else
typedef socklen_t juce_socklen_t; typedef socklen_t juce_socklen_t;
typedef int SocketHandle; typedef int SocketHandle;
static const SocketHandle invalidSocket = -1;
#endif #endif
//============================================================================== //==============================================================================
@ -354,7 +356,7 @@ namespace SocketHelpers
{ {
const SocketHandle newHandle = socket (i->ai_family, i->ai_socktype, 0); const SocketHandle newHandle = socket (i->ai_family, i->ai_socktype, 0);
if (newHandle >= 0) if (newHandle != invalidSocket)
{ {
setSocketBlockingState (newHandle, false); setSocketBlockingState (newHandle, false);
const int result = ::connect (newHandle, i->ai_addr, (socklen_t) i->ai_addrlen); const int result = ::connect (newHandle, i->ai_addr, (socklen_t) i->ai_addrlen);

View file

@ -1030,7 +1030,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
my_mem_ptr mem; my_mem_ptr mem;
long max_to_use; long max_to_use;
int pool; int pool;
size_t test_mac; // size_t test_mac;
cinfo->mem = NULL; /* for safety if init fails */ cinfo->mem = NULL; /* for safety if init fails */
@ -1048,10 +1048,10 @@ jinit_memory_mgr (j_common_ptr cinfo)
* Again, an "unreachable code" warning may be ignored here. * Again, an "unreachable code" warning may be ignored here.
* But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
*/ */
test_mac = (size_t) MAX_ALLOC_CHUNK; // test_mac = (size_t) MAX_ALLOC_CHUNK;
if ((long) test_mac != MAX_ALLOC_CHUNK || // if ((long) test_mac != MAX_ALLOC_CHUNK ||
(MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) // (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0)
ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); // ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */

View file

@ -187,10 +187,12 @@ void DropShadower::updateShadows()
WeakReference<Component> sw (shadowWindows[i]); WeakReference<Component> sw (shadowWindows[i]);
if (sw != nullptr) if (sw != nullptr)
{
sw->setAlwaysOnTop (owner->isAlwaysOnTop()); sw->setAlwaysOnTop (owner->isAlwaysOnTop());
if (sw != nullptr) if (sw == nullptr)
{ return;
switch (i) switch (i)
{ {
case 0: sw->setBounds (x - shadowEdge, y, shadowEdge, h); break; case 0: sw->setBounds (x - shadowEdge, y, shadowEdge, h); break;
@ -199,13 +201,12 @@ void DropShadower::updateShadows()
case 3: sw->setBounds (x, owner->getBottom(), w, shadowEdge); break; case 3: sw->setBounds (x, owner->getBottom(), w, shadowEdge); break;
default: break; default: break;
} }
}
if (sw != nullptr) if (sw == nullptr)
return;
sw->toBehind (i == 3 ? owner : shadowWindows.getUnchecked (i + 1)); sw->toBehind (i == 3 ? owner : shadowWindows.getUnchecked (i + 1));
}
if (sw == nullptr)
return;
} }
} }
else else

View file

@ -91,7 +91,7 @@ public:
if (owner.isCurrentlyBlockedByAnotherModalComponent()) if (owner.isCurrentlyBlockedByAnotherModalComponent())
{ {
if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN
|| lParam == WM_LBUTTONDBLCLK || lParam == WM_LBUTTONDBLCLK) || lParam == WM_LBUTTONDBLCLK || lParam == WM_RBUTTONDBLCLK)
{ {
if (Component* const current = Component::getCurrentlyModalComponent()) if (Component* const current = Component::getCurrentlyModalComponent())
current->inputAttemptWhenModal(); current->inputAttemptWhenModal();

View file

@ -118,8 +118,9 @@ public:
} }
} }
browser->Navigate ((BSTR) (const OLECHAR*) url.toWideCharPointer(), BSTR urlBSTR = SysAllocString ((const OLECHAR*) url.toWideCharPointer());
&headerFlags, &frame, &postDataVar, &headersVar); browser->Navigate (urlBSTR, &headerFlags, &frame, &postDataVar, &headersVar);
SysFreeString (urlBSTR);
if (sa != nullptr) if (sa != nullptr)
SafeArrayDestroy (sa); SafeArrayDestroy (sa);