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

Fixes for some clang static analysis warnings.

This commit is contained in:
jules 2013-06-25 10:18:35 +01:00
parent f04f16e60b
commit 78aac0995a
16 changed files with 62 additions and 17 deletions

View file

@ -728,6 +728,7 @@ String ComponentLayout::getComponentMemberVariableName (Component* comp) const
void ComponentLayout::setComponentMemberVariableName (Component* comp, const String& newName)
{
jassert (comp != nullptr);
const String oldName (getComponentMemberVariableName (comp));
comp->getProperties().set ("memberName", String::empty);
@ -782,6 +783,7 @@ String ComponentLayout::getComponentVirtualClassName (Component* comp) const
void ComponentLayout::setComponentVirtualClassName (Component* comp, const String& newName)
{
jassert (comp != nullptr);
const String name (CodeHelpers::makeValidIdentifier (newName, false, false, true));
if (name != getComponentVirtualClassName (comp))

View file

@ -96,6 +96,7 @@ public:
}
else if (mode == imageBrush)
{
jassert (document != nullptr);
loadImage (document);
Rectangle<int> r (imageAnchor.getRectangle (parentArea, document->getComponentLayout()));

View file

@ -977,7 +977,10 @@ bool PaintElementPath::getPoint (int index, int pointNumber, double& x, double&
const PathPoint* const p = points [index];
if (p == nullptr)
{
x = y = 0;
return false;
}
jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo);
jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo);

View file

@ -215,6 +215,8 @@ void ComponentLayoutEditor::refreshAllComponents()
for (int i = layout.getNumComponents(); --i >= 0;)
{
Component* const c = layout.getComponent (i);
jassert (c != nullptr);
ComponentOverlayComponent* overlay = getOverlayCompFor (c);
bool isNewOverlay = false;

View file

@ -218,6 +218,8 @@ void EditingPanelBase::setZoom (double newScale, int anchorX, int anchorY)
magnifier->setScaleFactor (newScale);
resized();
jassert (viewport != nullptr);
anchor = viewport->getLocalPoint (editor, anchor);
viewport->setViewPosition (jlimit (0, jmax (0, viewport->getViewedComponent()->getWidth() - viewport->getViewWidth()),

View file

@ -161,6 +161,7 @@ int ResourceEditorPanel::getColumnAutoSizeWidth (int columnId)
for (int i = document.getResources().size(); --i >= 0;)
{
const BinaryResources::BinaryResource* const r = document.getResources() [i];
jassert (r != nullptr);
String text;
if (columnId == 1)

View file

@ -2660,7 +2660,7 @@ void update_metadata_(const FLAC__StreamEncoder *encoder)
b[3] = (FLAC__byte)xx; xx >>= 8;
b[2] = (FLAC__byte)xx; xx >>= 8;
b[1] = (FLAC__byte)xx; xx >>= 8;
b[0] = (FLAC__byte)xx; xx >>= 8;
b[0] = (FLAC__byte)xx; //xx >>= 8;
xx = encoder->private_->seek_table->points[i].stream_offset;
b[15] = (FLAC__byte)xx; xx >>= 8;
b[14] = (FLAC__byte)xx; xx >>= 8;
@ -2669,10 +2669,10 @@ void update_metadata_(const FLAC__StreamEncoder *encoder)
b[11] = (FLAC__byte)xx; xx >>= 8;
b[10] = (FLAC__byte)xx; xx >>= 8;
b[9] = (FLAC__byte)xx; xx >>= 8;
b[8] = (FLAC__byte)xx; xx >>= 8;
b[8] = (FLAC__byte)xx; //xx >>= 8;
x = encoder->private_->seek_table->points[i].frame_samples;
b[17] = (FLAC__byte)x; x >>= 8;
b[16] = (FLAC__byte)x; x >>= 8;
b[16] = (FLAC__byte)x; //x >>= 8;
if(encoder->private_->write_callback(encoder, b, 18, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
return;

View file

@ -471,7 +471,7 @@ static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1,
xb+= x0;
yb+= *y0;
x2b+= x0 * x0;
y2b+= *y0 * *y0;
//y2b+= *y0 * *y0;
xyb+= *y0 * x0;
bn++;
}
@ -480,7 +480,7 @@ static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1,
xb+= x1;
yb+= *y1;
x2b+= x1 * x1;
y2b+= *y1 * *y1;
//y2b+= *y1 * *y1;
xyb+= *y1 * x1;
bn++;
}

View file

@ -853,7 +853,7 @@ static int _fetch_and_process_packet(OggVorbis_File *vf,
if(ret)return(ret);
vf->current_serialno=vf->os.serialno;
vf->current_link++;
link=0;
//link=0;
}
}
}
@ -1561,6 +1561,7 @@ int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){
break;
}else
result=ogg_stream_packetout(&vf->os,NULL);
(void) result;
}
}
}
@ -2158,6 +2159,8 @@ static void _ov_getlap(OggVorbis_File *vf,vorbis_info *vi,vorbis_dsp_state *vd,
memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples);
lapcount+=samples;
}
(void) lapcount;
}
}

View file

@ -235,8 +235,14 @@ public:
ElementType operator[] (const int index) const
{
const ScopedLockType lock (getLock());
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
: ElementType();
if (isPositiveAndBelow (index, numUsed))
{
jassert (data.elements != nullptr);
return data.elements [index];
}
return ElementType();
}
/** Returns one of the elements in the array, without checking the index passed in.
@ -251,7 +257,7 @@ public:
inline ElementType getUnchecked (const int index) const
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
return data.elements [index];
}
@ -267,7 +273,7 @@ public:
inline ElementType& getReference (const int index) const noexcept
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
return data.elements [index];
}
@ -388,6 +394,7 @@ public:
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
if (isPositiveAndBelow (indexToInsertAt, numUsed))
{

View file

@ -108,6 +108,8 @@ public:
{
if (minNumElements > numAllocated)
setAllocatedSize ((minNumElements + minNumElements / 2 + 8) & ~7);
jassert (numAllocated <= 0 || elements != nullptr);
}
/** Minimises the amount of storage allocated so that it's no more than

View file

@ -129,8 +129,13 @@ public:
inline ObjectClass* operator[] (const int index) const noexcept
{
const ScopedLockType lock (getLock());
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
: static_cast <ObjectClass*> (nullptr);
if (isPositiveAndBelow (index, numUsed))
{
jassert (data.elements != nullptr);
return data.elements [index];
}
return nullptr;
}
/** Returns a pointer to the object at this index in the array, without checking whether the index is in-range.
@ -141,7 +146,7 @@ public:
inline ObjectClass* getUnchecked (const int index) const noexcept
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
jassert (isPositiveAndBelow (index, numUsed) && data.elements != nullptr);
return data.elements [index];
}
@ -248,6 +253,7 @@ public:
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
data.elements [numUsed++] = const_cast <ObjectClass*> (newObject);
}
@ -279,6 +285,7 @@ public:
indexToInsertAt = numUsed;
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
ObjectClass** const e = data.elements + indexToInsertAt;
const int numToMove = numUsed - indexToInsertAt;
@ -431,6 +438,7 @@ public:
numElementsToAdd = arrayToAddFrom.size() - startIndex;
data.ensureAllocatedSize (numUsed + numElementsToAdd);
jassert (data.elements != nullptr);
while (--numElementsToAdd >= 0)
{
@ -471,6 +479,7 @@ public:
numElementsToAdd = arrayToAddFrom.size() - startIndex;
data.ensureAllocatedSize (numUsed + numElementsToAdd);
jassert (data.elements != nullptr);
while (--numElementsToAdd >= 0)
{

View file

@ -297,6 +297,7 @@ public:
{
const ScopedLockType lock (getLock());
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
data.elements [numUsed++] = newObject;
if (newObject != nullptr)
@ -327,6 +328,7 @@ public:
indexToInsertAt = numUsed;
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
ObjectClass** const e = data.elements + indexToInsertAt;
const int numToMove = numUsed - indexToInsertAt;
@ -393,6 +395,7 @@ public:
else
{
data.ensureAllocatedSize (numUsed + 1);
jassert (data.elements != nullptr);
data.elements [numUsed++] = newObject;
}
}

View file

@ -83,6 +83,16 @@
#define juce_breakDebugger { __asm int 3 }
#endif
#if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN)
#if __has_feature (attribute_analyzer_noreturn)
inline void __attribute__((analyzer_noreturn)) juce_assert_noreturn() {}
#define JUCE_ANALYZER_NORETURN juce_assert_noreturn();
#endif
#endif
#ifndef JUCE_ANALYZER_NORETURN
#define JUCE_ANALYZER_NORETURN
#endif
//==============================================================================
#if JUCE_DEBUG || DOXYGEN
@ -97,7 +107,7 @@
It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled for your build).
@see jassert
*/
#define jassertfalse { juce_LogCurrentAssertion; if (juce::juce_isRunningUnderDebugger()) juce_breakDebugger; }
#define jassertfalse { juce_LogCurrentAssertion; if (juce::juce_isRunningUnderDebugger()) juce_breakDebugger; JUCE_ANALYZER_NORETURN }
//==============================================================================
/** Platform-independent assertion macro.

View file

@ -200,7 +200,7 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
"Application built with libpng-");
pos = png_safecat(m, (sizeof m), pos, user_png_ver);
pos = png_safecat(m, (sizeof m), pos, " but running with ");
pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);
png_safecat(m, (sizeof m), pos, png_libpng_ver);
png_warning(png_ptr, m);
#endif
@ -1720,7 +1720,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
}
# endif
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */
pos = png_safecat(message, (sizeof message), pos, reason);
png_safecat(message, (sizeof message), pos, reason);
/* This is recoverable, but make it unconditionally an app_error on write to
* avoid writing invalid ICC profiles into PNG files. (I.e. we handle them

View file

@ -3862,7 +3862,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
if (pb < pa) pa = pb, a = b;
if (pc < pa) a = c;
c = b;
//c = b;
a += *row;
*row++ = (png_byte)a;
}