* Resolve further warnings on GCC4.

* Enable -Werror on GCC4 builds as well (limited to the same selected targets).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29118 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-02-01 22:12:55 +00:00
parent 702a1e7241
commit 6eb09230ba
22 changed files with 53 additions and 58 deletions
+4 -7
View File
@@ -1033,15 +1033,12 @@ if $(HAIKU_GCC_VERSION[1]) = 2 {
: $(scope) ; : $(scope) ;
} }
} else { } else {
# TODO: Enable after updating to a newer gcc 4 version that supports -Wno-error!
# -Wuninitialized gives too many false positives. # -Wuninitialized gives too many false positives.
# rule EnableWerror dirTokens : scope {
# AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens)
# : -Werror -Wno-error=uninitialized : $(scope) ;
# AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens)
# : -Werror -Wno-error=uninitialized : $(scope) ;
# }
rule EnableWerror dirTokens : scope { rule EnableWerror dirTokens : scope {
AppendToConfigVar CCFLAGS : HAIKU_TOP $(dirTokens)
: -Werror -Wno-error=uninitialized : $(scope) ;
AppendToConfigVar C++FLAGS : HAIKU_TOP $(dirTokens)
: -Werror -Wno-error=uninitialized : $(scope) ;
} }
} }
+1 -1
View File
@@ -42,7 +42,7 @@ struct _oproperty_info_;
struct compound_type { struct compound_type {
struct field_pair { struct field_pair {
#if __GNUC__ > 2 #if __GNUC__ > 2
const const
#endif #endif
char *name; // name of entry in message char *name; // name of entry in message
type_code type; // type_code of entry in message type_code type; // type_code of entry in message
+1 -1
View File
@@ -54,7 +54,7 @@ typedef enum TokenType {
CharacterString, CharacterString,
Integer, Integer,
FloatingPoint FloatingPoint
}; } TokenType;
/*! \brief Returns a NULL-terminated string contating the /*! \brief Returns a NULL-terminated string contating the
name of the given token type name of the given token type
+1 -1
View File
@@ -1498,7 +1498,7 @@ BApplication::_WindowAt(uint32 index, bool includeMenus) const
uint32 count = gLooperList.CountLoopers(); uint32 count = gLooperList.CountLoopers();
for (uint32 i = 0; i < count && index < count; i++) { for (uint32 i = 0; i < count && index < count; i++) {
BWindow* window = dynamic_cast<BWindow*>(gLooperList.LooperAt(i)); BWindow* window = dynamic_cast<BWindow*>(gLooperList.LooperAt(i));
if (window == NULL || window != NULL && window->fOffscreen if (window == NULL || (window != NULL && window->fOffscreen)
|| (!includeMenus && dynamic_cast<BMenuWindow *>(window) != NULL)) { || (!includeMenus && dynamic_cast<BMenuWindow *>(window) != NULL)) {
index++; index++;
continue; continue;
+3 -3
View File
@@ -572,11 +572,11 @@ operator<(const BMessenger &_a, const BMessenger &_b)
// 3. fPreferredTarget // 3. fPreferredTarget
// fTeam is insignificant // fTeam is insignificant
return (a.Port() < b.Port() return (a.Port() < b.Port()
|| a.Port() == b.Port() || (a.Port() == b.Port()
&& (a.Token() < b.Token() && (a.Token() < b.Token()
|| a.Token() == b.Token() || (a.Token() == b.Token()
&& !a.IsPreferredTarget() && !a.IsPreferredTarget()
&& b.IsPreferredTarget())); && b.IsPreferredTarget()))));
} }
+5 -5
View File
@@ -501,15 +501,15 @@ BPropertyInfo::FreeMem()
if (fPropInfo != NULL) { if (fPropInfo != NULL) {
for (i = 0; i < fPropCount; i++) { for (i = 0; i < fPropCount; i++) {
free(fPropInfo[i].name); free((char *)fPropInfo[i].name);
free(fPropInfo[i].usage); free((char *)fPropInfo[i].usage);
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
for (k = 0; k < 5; k++) { for (k = 0; k < 5; k++) {
if (fPropInfo[i].ctypes[j].pairs[k].name == NULL) if (fPropInfo[i].ctypes[j].pairs[k].name == NULL)
break; break;
free(fPropInfo[i].ctypes[j].pairs[k].name); free((char *)fPropInfo[i].ctypes[j].pairs[k].name);
} }
if (fPropInfo[i].ctypes[j].pairs[0].name == NULL) if (fPropInfo[i].ctypes[j].pairs[0].name == NULL)
@@ -523,8 +523,8 @@ BPropertyInfo::FreeMem()
if (fValueInfo != NULL) { if (fValueInfo != NULL) {
for (i = 0; i < fValueCount; i++) { for (i = 0; i < fValueCount; i++) {
free(fValueInfo[i].name); free((char *)fValueInfo[i].name);
free(fValueInfo[i].usage); free((char *)fValueInfo[i].usage);
} }
free(fValueInfo); free(fValueInfo);
fValueInfo = NULL; fValueInfo = NULL;
+4 -4
View File
@@ -250,7 +250,7 @@ inline
uint8 uint8
PaletteConverter::IndexForRGB16(uint16 rgb) const PaletteConverter::IndexForRGB16(uint16 rgb) const
{ {
return fColorMap->index_map[(rgb >> 1) & 0x7fe0 | rgb & 0x1f]; return fColorMap->index_map[((rgb >> 1) & 0x7fe0) | (rgb & 0x1f)];
} }
@@ -487,7 +487,7 @@ ReadRGB24(const uint8 **source, int32 index)
void void
WriteGray8(uint8 **dest, uint8 *data, int32 index) WriteGray8(uint8 **dest, uint8 *data, int32 index)
{ {
**dest = data[2] * 308 + data[1] * 600 + data[0] * 116 >> 10; **dest = (data[2] * 308 + data[1] * 600 + data[0] * 116) >> 10;
// this would boost the speed but is less accurate: // this would boost the speed but is less accurate:
//*dest = (data[2] << 8) + (data[1] << 9) + (data[0] << 8) >> 10; //*dest = (data[2] << 8) + (data[1] << 9) + (data[0] << 8) >> 10;
(*dest)++; (*dest)++;
@@ -584,9 +584,9 @@ ConvertBits(const srcByte *srcBits, dstByte *dstBits, int32 srcBitsLength,
} }
srcBits = (srcByte*)((uint8*)srcBits + (srcOffsetY * srcBitsPerRow + srcOffsetX srcBits = (srcByte*)((uint8*)srcBits + (srcOffsetY * srcBitsPerRow + srcOffsetX
* srcBitsPerPixel >> 3)); * (srcBitsPerPixel >> 3)));
dstBits = (dstByte*)((uint8*)dstBits + (dstOffsetY * dstBitsPerRow + dstOffsetX dstBits = (dstByte*)((uint8*)dstBits + (dstOffsetY * dstBitsPerRow + dstOffsetX
* dstBitsPerPixel >> 3)); * (dstBitsPerPixel >> 3)));
// Ensure that the width fits // Ensure that the width fits
int32 srcWidth = (srcBitsPerRow - srcOffsetX * srcBitsPerPixel) int32 srcWidth = (srcBitsPerRow - srcOffsetX * srcBitsPerPixel)
+1 -1
View File
@@ -1527,7 +1527,7 @@ BListView::_DeselectAll(int32 exceptFrom, int32 exceptTo)
bool bool
BListView::_TryInitiateDrag(BPoint where) BListView::_TryInitiateDrag(BPoint where)
{ {
if (!fTrack->try_drag | fTrack->item_index < 0) if (!fTrack->try_drag || fTrack->item_index < 0)
return false; return false;
BPoint offset = where - fTrack->drag_start; BPoint offset = where - fTrack->drag_start;
+2 -2
View File
@@ -2626,8 +2626,8 @@ BMenu::_OkToProceed(BMenuItem* item)
// TODO: I added the check for BMenuBar to solve a problem with Deskbar. // TODO: I added the check for BMenuBar to solve a problem with Deskbar.
// BeOS seems to do something similar. This could also be a bug in Deskbar, though. // BeOS seems to do something similar. This could also be a bug in Deskbar, though.
if ((buttons != 0 && stickyMode) if ((buttons != 0 && stickyMode)
|| (dynamic_cast<BMenuBar *>(this) == NULL || ((dynamic_cast<BMenuBar *>(this) == NULL
&& (buttons == 0 && !stickyMode) || _HitTestItems(where) != item)) && (buttons == 0 && !stickyMode)) || _HitTestItems(where) != item))
return false; return false;
return true; return true;
+3 -3
View File
@@ -755,7 +755,7 @@ BMenuItem::_DrawShortcutSymbol()
where.x -= fBounds.Height() - 3; where.x -= fBounds.Height() - 3;
const float ascent = MenuPrivate(fSuper).Ascent(); const float ascent = MenuPrivate(fSuper).Ascent();
if (fShortcutChar < B_SPACE && kUTF8ControlMap[fShortcutChar]) if (fShortcutChar < B_SPACE && kUTF8ControlMap[(int)fShortcutChar])
_DrawControlChar(fShortcutChar, where + BPoint(0, ascent)); _DrawControlChar(fShortcutChar, where + BPoint(0, ascent));
else else
fSuper->DrawChar(fShortcutChar, where + BPoint(0, ascent)); fSuper->DrawChar(fShortcutChar, where + BPoint(0, ascent));
@@ -849,8 +849,8 @@ BMenuItem::_DrawControlChar(char shortcut, BPoint where)
// TODO: If needed, take another font for the control characters // TODO: If needed, take another font for the control characters
// (or have font overlays in the app_server!) // (or have font overlays in the app_server!)
const char* symbol = " "; const char* symbol = " ";
if (kUTF8ControlMap[fShortcutChar]) if (kUTF8ControlMap[(int)fShortcutChar])
symbol = kUTF8ControlMap[fShortcutChar]; symbol = kUTF8ControlMap[(int)fShortcutChar];
fSuper->DrawString(symbol, where); fSuper->DrawString(symbol, where);
} }
+4 -2
View File
@@ -874,10 +874,12 @@ BSlider::DrawBar()
barColor.red = (fBarColor.red + no_tint.red) / 2; barColor.red = (fBarColor.red + no_tint.red) / 2;
barColor.green = (fBarColor.green + no_tint.green) / 2; barColor.green = (fBarColor.green + no_tint.green) / 2;
barColor.blue = (fBarColor.blue + no_tint.blue) / 2; barColor.blue = (fBarColor.blue + no_tint.blue) / 2;
barColor.alpha = 255;
fillColor.red = (fFillColor.red + no_tint.red) / 2; fillColor.red = (fFillColor.red + no_tint.red) / 2;
fillColor.green = (fFillColor.green + no_tint.green) / 2; fillColor.green = (fFillColor.green + no_tint.green) / 2;
fillColor.blue = (fFillColor.blue + no_tint.blue) / 2; fillColor.blue = (fFillColor.blue + no_tint.blue) / 2;
fillColor.alpha = 255;
} }
// exclude the block thumb from the bar filling // exclude the block thumb from the bar filling
@@ -1172,8 +1174,8 @@ BSlider::UpdateTextChanged()
const char* oldUpdateText = fUpdateText; const char* oldUpdateText = fUpdateText;
fUpdateText = UpdateText(); fUpdateText = UpdateText();
bool updateTextOnOff = fUpdateText == NULL && oldUpdateText != NULL bool updateTextOnOff = (fUpdateText == NULL && oldUpdateText != NULL)
|| fUpdateText != NULL && oldUpdateText == NULL; || (fUpdateText != NULL && oldUpdateText == NULL);
float newWidth = 0.0; float newWidth = 0.0;
if (fUpdateText != NULL) if (fUpdateText != NULL)
+4 -4
View File
@@ -563,8 +563,8 @@ BSplitLayout::StartDraggingSplitter(BPoint point)
// Things shouldn't be draggable, if we have a >= max layout. // Things shouldn't be draggable, if we have a >= max layout.
BSize size = _SubtractInsets(View()->Frame().Size()); BSize size = _SubtractInsets(View()->Frame().Size());
if (fOrientation == B_HORIZONTAL && size.width >= fMax.width if ((fOrientation == B_HORIZONTAL && size.width >= fMax.width)
|| fOrientation == B_VERTICAL && size.height >= fMax.height) { || (fOrientation == B_VERTICAL && size.height >= fMax.height)) {
return false; return false;
} }
@@ -1133,8 +1133,8 @@ void
BSplitLayout::_InternalGetHeightForWidth(float width, bool realLayout, BSplitLayout::_InternalGetHeightForWidth(float width, bool realLayout,
float* minHeight, float* maxHeight, float* preferredHeight) float* minHeight, float* maxHeight, float* preferredHeight)
{ {
if (realLayout && fHeightForWidthVerticalLayouterWidth != width if ((realLayout && fHeightForWidthVerticalLayouterWidth != width)
|| !realLayout && fCachedHeightForWidthWidth != width) { || (!realLayout && fCachedHeightForWidthWidth != width)) {
// The general strategy is to clone the vertical layouter, which only // The general strategy is to clone the vertical layouter, which only
// knows the general min/max constraints, do a horizontal layout for the // knows the general min/max constraints, do a horizontal layout for the
// given width, and add the children's height for width constraints to // given width, and add the children's height for width constraints to
+1 -1
View File
@@ -1595,7 +1595,7 @@ void
BWindow::SetPulseRate(bigtime_t rate) BWindow::SetPulseRate(bigtime_t rate)
{ {
// TODO: What about locking?!? // TODO: What about locking?!?
if (rate < 0 || (rate == fPulseRate && !(rate == 0 ^ fPulseRunner == NULL))) if (rate < 0 || (rate == fPulseRate && !((rate == 0) ^ (fPulseRunner == NULL))))
return; return;
fPulseRate = rate; fPulseRate = rate;
@@ -172,7 +172,7 @@ TextGapBuffer::SizeGapTo(long inCount)
const char * const char *
TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes) TextGapBuffer::GetString(int32 fromOffset, int32 *_numBytes)
{ {
char *result = ""; char *result = (char *)"";
if (_numBytes == NULL) if (_numBytes == NULL)
return result; return result;
+3 -7
View File
@@ -135,8 +135,8 @@ entry_ref::operator==(const entry_ref &ref) const
return (device == ref.device return (device == ref.device
&& directory == ref.directory && directory == ref.directory
&& (name == ref.name && (name == ref.name
|| name != NULL && ref.name != NULL || (name != NULL && ref.name != NULL
&& strcmp(name, ref.name) == 0)); && strcmp(name, ref.name) == 0)));
} }
/*! \brief Compares the entry_ref with another entry_ref, returning true if they are not equal. /*! \brief Compares the entry_ref with another entry_ref, returning true if they are not equal.
@@ -1095,11 +1095,7 @@ operator<(const entry_ref & a, const entry_ref & b)
|| (a.device == b.device || (a.device == b.device
&& (a.directory < b.directory && (a.directory < b.directory
|| (a.directory == b.directory || (a.directory == b.directory
&& (a.name == NULL && b.name != NULL && ((a.name == NULL && b.name != NULL)
|| (a.name != NULL && b.name != NULL || (a.name != NULL && b.name != NULL
&& strcmp(a.name, b.name) < 0)))))); && strcmp(a.name, b.name) < 0))))));
} }
+2 -2
View File
@@ -390,8 +390,8 @@ BPath::operator==(const BPath &item) const
bool bool
BPath::operator==(const char *path) const BPath::operator==(const char *path) const
{ {
return (InitCheck() != B_OK && path == NULL return ((InitCheck() != B_OK && path == NULL)
|| fName && path && strcmp(fName, path) == 0); || (fName != NULL && path != NULL && strcmp(fName, path) == 0));
} }
//! Performs a simple (string-wise) comparison of paths. //! Performs a simple (string-wise) comparison of paths.
+3 -3
View File
@@ -359,8 +359,8 @@ PathHandler::_EntryCreated(BMessage* message)
} }
// a new directory to watch for us // a new directory to watch for us
if (!entryContained && !_CloserToPath(entry) if ((!entryContained && !_CloserToPath(entry))
|| parentContained && !_WatchRecursively() || (parentContained && !_WatchRecursively())
|| _AddDirectory(entry, true) != B_OK || _AddDirectory(entry, true) != B_OK
|| _WatchFilesOnly()) || _WatchFilesOnly())
notify = parentContained; notify = parentContained;
@@ -446,7 +446,7 @@ PathHandler::_EntryMoved(BMessage* message)
&& (entryContained || _CloserToPath(entry))) { && (entryContained || _CloserToPath(entry))) {
// there is a new directory to watch for us // there is a new directory to watch for us
if (entryContained if (entryContained
|| parentContained && !_WatchRecursively()) { || (parentContained && !_WatchRecursively())) {
_AddDirectory(entry, true); _AddDirectory(entry, true);
// NOTE: entry is toast now! // NOTE: entry is toast now!
} else if (_GetClosest(fPath.Path(), false, } else if (_GetClosest(fPath.Path(), false,
+4 -4
View File
@@ -288,10 +288,10 @@ BResources::SetToImage(const void *codeOrDataPointer, bool clobber)
int32 cookie = 0; int32 cookie = 0;
while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
if ((addr_t)info.text <= address if (((addr_t)info.text <= address
&& address - (addr_t)info.text < (addr_t)info.text_size && address - (addr_t)info.text < (addr_t)info.text_size)
|| (addr_t)info.data <= address || ((addr_t)info.data <= address
&& address - (addr_t)info.data < (addr_t)info.data_size) { && address - (addr_t)info.data < (addr_t)info.data_size)) {
return SetTo(info.name, clobber); return SetTo(info.name, clobber);
} }
} }
+3 -3
View File
@@ -143,9 +143,9 @@ ResourcesContainer::IndexOf(type_code type, const char *name) const
for (int32 i = 0; index == -1 && i < count; i++) { for (int32 i = 0; index == -1 && i < count; i++) {
ResourceItem *item = ResourceAt(i); ResourceItem *item = ResourceAt(i);
const char *itemName = item->Name(); const char *itemName = item->Name();
if (item->Type() == type && (name == NULL && itemName == NULL if (item->Type() == type && ((name == NULL && itemName == NULL)
|| name != NULL && itemName != NULL || (name != NULL && itemName != NULL
&& !strcmp(name, itemName))) { && strcmp(name, itemName) == 0))) {
index = i; index = i;
} }
} }
+1 -1
View File
@@ -493,7 +493,7 @@ BVolume::KnowsQuery(void) const
bool bool
BVolume::operator==(const BVolume &volume) const BVolume::operator==(const BVolume &volume) const
{ {
return (InitCheck() != B_OK && volume.InitCheck() != B_OK return ((InitCheck() != B_OK && volume.InitCheck() != B_OK)
|| fDevice == volume.fDevice); || fDevice == volume.fDevice);
} }
+1 -1
View File
@@ -1543,7 +1543,7 @@ BPartition::_SupportsOperation(uint32 flag, uint32 whileMountedFlag,
bool bool
BPartition::_SupportsChildOperation(const BPartition* child, uint32 flag) const BPartition::_SupportsChildOperation(const BPartition* child, uint32 flag) const
{ {
if (!fDelegate || child && !child->fDelegate) if (!fDelegate || (child && !child->fDelegate))
return false; return false;
uint32 supported = fDelegate->SupportedChildOperations( uint32 supported = fDelegate->SupportedChildOperations(
+1 -1
View File
@@ -260,7 +260,7 @@ TokenStream::SetTo(const std::string &string) {
tsssEscapeOneOctal, tsssEscapeOneOctal,
tsssEscapeTwoOctal, tsssEscapeTwoOctal,
tsssEscapeOneHex, tsssEscapeOneHex,
}; } TokenStreamScannerState;
TokenStreamScannerState state = tsssStart; TokenStreamScannerState state = tsssStart;
TokenStreamScannerState escapedState = tsssStart; TokenStreamScannerState escapedState = tsssStart;