409760 "You've been warned:" zero-tolerance for warnings in mozilla/camino. I got asked why I gave such a few warnings. There are no compiler warnings in mozilla/camino at all, and we now build everything with -Wall -Werror. r=smorgan r=ardissone a/1.6b1=me

This commit is contained in:
mark%moxienet.com 2007-12-30 23:57:49 +00:00
Родитель 504fbeb90f
Коммит 9e0111adfd
22 изменённых файлов: 87 добавлений и 68 удалений

Просмотреть файл

@ -47,8 +47,6 @@
#include "nsILocalFileMac.h"
#include "nsDirectoryServiceDefs.h"
const int kDefaultExpireDays = 9;
// handly stack-based class to start and stop an Internet Config session
class StInternetConfigSession
{

Просмотреть файл

@ -48,7 +48,12 @@
#import "General.h"
const int kDefaultExpireDays = 9;
static const char kHomepagePrefName[] = "browser.startup.homepage";
static const char kNewPageActionPrefName[] = "browser.startup.page";
static const char kNewTabActionPrefName[] = "browser.tabs.startPage";
static const char kCheckDefaultBrowserPrefName[] = "camino.check_default_browser";
static const char kWarnWhenClosingPrefName[] = "camino.warn_when_closing";
static const char kRememberWindowStatePrefName[] = "camino.remember_window_state";
@interface OrgMozillaCaminoPreferenceGeneral(Private)
@ -87,19 +92,19 @@ const int kDefaultExpireDays = 9;
// 0: blank page. 1: home page. 2: last page visited. Our behaviour here should
// match what the browser does when the prefs don't exist.
if (([self getIntPref:"browser.startup.page" withSuccess:&gotPref] == 1) || !gotPref)
if (([self getIntPref:kNewPageActionPrefName withSuccess:&gotPref] == 1) || !gotPref)
[checkboxNewWindowBlank setState:NSOnState];
if (([self getIntPref:"browser.tabs.startPage" withSuccess:&gotPref] == 1))
if (([self getIntPref:kNewTabActionPrefName withSuccess:&gotPref] == 1))
[checkboxNewTabBlank setState:NSOnState];
if ([self getBooleanPref:"camino.check_default_browser" withSuccess:&gotPref] || !gotPref)
if ([self getBooleanPref:kCheckDefaultBrowserPrefName withSuccess:&gotPref] || !gotPref)
[checkboxCheckDefaultBrowserOnLaunch setState:NSOnState];
if ([self getBooleanPref:"camino.warn_when_closing" withSuccess:&gotPref])
if ([self getBooleanPref:kWarnWhenClosingPrefName withSuccess:&gotPref])
[checkboxWarnWhenClosing setState:NSOnState];
if ([self getBooleanPref:"camino.remember_window_state" withSuccess:&gotPref])
if ([self getBooleanPref:kRememberWindowStatePrefName withSuccess:&gotPref])
[checkboxRememberWindowState setState:NSOnState];
if ([[NSUserDefaults standardUserDefaults] integerForKey:SUScheduledCheckIntervalKey] > 0)
@ -125,11 +130,11 @@ const int kDefaultExpireDays = 9;
if (!mPrefService)
return;
[self setPref:"browser.startup.homepage" toString:[textFieldHomePage stringValue]];
[self setPref:kHomepagePrefName toString:[textFieldHomePage stringValue]];
// ensure that the prefs exist
[self setPref:"browser.startup.page" toInt:[checkboxNewWindowBlank state] ? 1 : 0];
[self setPref:"browser.tabs.startPage" toInt:[checkboxNewTabBlank state] ? 1 : 0];
[self setPref:kNewPageActionPrefName toInt:[checkboxNewWindowBlank state] ? 1 : 0];
[self setPref:kNewTabActionPrefName toInt:[checkboxNewTabBlank state] ? 1 : 0];
}
- (IBAction)checkboxStartPageClicked:(id)sender
@ -137,11 +142,11 @@ const int kDefaultExpireDays = 9;
if (!mPrefService)
return;
char *prefName = NULL;
const char* prefName = NULL;
if (sender == checkboxNewTabBlank)
prefName = "browser.tabs.startPage";
prefName = kNewTabActionPrefName;
else if (sender == checkboxNewWindowBlank)
prefName = "browser.startup.page";
prefName = kNewPageActionPrefName;
if (prefName)
[self setPref:prefName toInt: [sender state] ? 1 : 0];
@ -150,19 +155,19 @@ const int kDefaultExpireDays = 9;
- (IBAction)warningCheckboxClicked:(id)sender
{
if (sender == checkboxWarnWhenClosing)
[self setPref:"camino.warn_when_closing" toBoolean:([sender state] == NSOnState)];
[self setPref:kWarnWhenClosingPrefName toBoolean:([sender state] == NSOnState)];
}
- (IBAction)rememberWindowStateCheckboxClicked:(id)sender
{
if (sender == checkboxRememberWindowState)
[self setPref:"camino.remember_window_state" toBoolean:([sender state] == NSOnState)];
[self setPref:kRememberWindowStatePrefName toBoolean:([sender state] == NSOnState)];
}
- (IBAction)checkDefaultBrowserOnLaunchClicked:(id)sender
{
if (sender == checkboxCheckDefaultBrowserOnLaunch)
[self setPref:"camino.check_default_browser" toBoolean:([sender state] == NSOnState)];
[self setPref:kCheckDefaultBrowserPrefName toBoolean:([sender state] == NSOnState)];
}
- (IBAction)autoUpdateCheckboxClicked:(id)sender
@ -182,7 +187,7 @@ const int kDefaultExpireDays = 9;
- (NSString*)currentHomePage
{
BOOL gotPref;
return [self getStringPref:"browser.startup.homepage" withSuccess:&gotPref];
return [self getStringPref:kHomepagePrefName withSuccess:&gotPref];
}
// called when the users changes the selection in the default browser menu

Просмотреть файл

@ -46,7 +46,7 @@
#include "nsIBrowserHistory.h"
#include "nsICacheService.h"
const int kDefaultExpireDays = 9;
static const int kDefaultExpireDays = 9;
// A formatter for the history duration that only accepts integers >= 0
@interface NonNegativeIntegerFormatter : NSFormatter

Просмотреть файл

@ -99,7 +99,8 @@ const int kOpenExternalLinksInNewTab = 1;
}
else if (sender == mSingleWindowMode) {
[sender setAllowsMixedState:NO];
int newState = ([sender state] == NSOnState) ? nsIBrowserDOMWindow::OPEN_NEWTAB : nsIBrowserDOMWindow::OPEN_NEWWINDOW;
// Cast to avoid "enumeral mismatch" warning - thanks a lot, xpidl.
int newState = ([sender state] == NSOnState) ? (int)nsIBrowserDOMWindow::OPEN_NEWTAB : (int)nsIBrowserDOMWindow::OPEN_NEWWINDOW;
[self setPref:"browser.link.open_newwindow" toInt:newState];
}

Просмотреть файл

@ -18,6 +18,7 @@ HEADER_SEARCH_PATHS = ../dist/include/ ../dist/include/appcomps ../dist/include/
FRAMEWORK_SEARCH_PATHS = sparkle/build/Release
// Warning settings
GCC_TREAT_WARNINGS_AS_ERRORS = YES
GCC_WARN_SIGN_COMPARE = YES
WARNING_FLAGS = -Wall -Wno-four-char-constants
WARNING_CFLAGS = -Wall -Wno-four-char-constants
OTHER_CPLUSPLUSFLAGS = $(OTHER_CPLUSPLUSFLAGS) -Wno-non-virtual-dtor

Просмотреть файл

@ -11,6 +11,7 @@ GCC_ENABLE_CPP_RTTI = NO
GCC_PREPROCESSOR_DEFINITIONS = OSTYPE=Darwin1.4 OSARCH=Darwin MOZILLA_INTERNAL_API=1
OTHER_CFLAGS = -fshort-wchar
GCC_TREAT_WARNINGS_AS_ERRORS = YES
GCC_WARN_SIGN_COMPARE = YES
WARNING_CFLAGS = -Wall -Wno-four-char-constants
OTHER_CPLUSPLUSFLAGS = $(OTHER_CPLUSPLUSFLAGS) -Wno-non-virtual-dtor

Просмотреть файл

@ -43,8 +43,8 @@
#import "BookmarkManager.h"
#import "BookmarkFolder.h"
#import "Bookmark.h"
@class AutoCompleteWindow;
@class BrowserWindowController;
#import "AutoCompleteTextField.h"
#import "BrowserWindowController.h"
// This file adds scripting support to various classes.
@ -144,7 +144,7 @@
return [[BookmarkManager sharedBookmarkManager] valueForKey:key];
}
else {
[super valueForKey:key];
return [super valueForKey:key];
}
}

Просмотреть файл

@ -101,3 +101,7 @@ extern NSString* const kWillShowFeedMenu;
- (void)setFeedIconContextMenu:(NSMenu*)inMenu;
@end
@interface AutoCompleteWindow : NSWindow
- (BOOL)isKeyWindow;
@end

Просмотреть файл

@ -114,10 +114,6 @@ NSString* const kWillShowFeedMenu = @"WillShowFeedMenu";
#pragma mark -
@interface AutoCompleteWindow : NSWindow
- (BOOL)isKeyWindow;
@end
@implementation AutoCompleteWindow
- (BOOL)isKeyWindow

Просмотреть файл

@ -67,6 +67,7 @@
#import "PreferenceManager.h"
#import "BrowserTabView.h"
#import "BrowserTabViewItem.h"
#import "TabButtonView.h"
#import "UserDefaults.h"
#import "PageProxyIcon.h"
#import "AutoCompleteTextField.h"

Просмотреть файл

@ -231,8 +231,8 @@ class nsIArray;
// CHBrowserListener messages
- (void)onLoadingStarted;
- (void)onLoadingCompleted:(BOOL)succeeded;
- (void)onResourceLoadingStarted:(NSNumber*)resourceIdentifier;
- (void)onResourceLoadingCompleted:(NSNumber*)resourceIdentifier;
- (void)onResourceLoadingStarted:(NSValue*)resourceIdentifier;
- (void)onResourceLoadingCompleted:(NSValue*)resourceIdentifier;
- (void)onProgressChange64:(long long)currentBytes outOf:(long long)maxBytes;
- (void)onProgressChange:(long)currentBytes outOf:(long)maxBytes;
- (void)onLocationChange:(NSString*)urlSpec isNewPage:(BOOL)newPage requestSucceeded:(BOOL)requestOK;

Просмотреть файл

@ -539,12 +539,12 @@ enum StatusPriority {
}
}
- (void)onResourceLoadingStarted:(NSNumber*)resourceIdentifier
- (void)onResourceLoadingStarted:(NSValue*)resourceIdentifier
{
[mLoadingResources addObject:resourceIdentifier];
}
- (void)onResourceLoadingCompleted:(NSNumber*)resourceIdentifier
- (void)onResourceLoadingCompleted:(NSValue*)resourceIdentifier
{
if ([mLoadingResources containsObject:resourceIdentifier])
{

Просмотреть файл

@ -206,12 +206,13 @@ nsresult RemoteURILoadManager::RequestURILoad(const nsAString& inURI, id<RemoteL
mLoadGroup = do_CreateInstance(NS_LOADGROUP_CONTRACTID);
nsCOMPtr<nsISupports> loaderContext = new StreamLoaderContext(loadListener, userData, target, inURI, allowNetworking);
nsLoadFlags loadFlags = (allowNetworking) ? nsIRequest::LOAD_NORMAL : nsIRequest::LOAD_FROM_CACHE;
loadFlags |= nsIRequest::LOAD_BACKGROUND; // don't show progress or cookie dialogs
if (!allowNetworking)
loadFlags |= nsICachingChannel::LOAD_ONLY_FROM_CACHE;
// Don't show progress or cookie dialogs. Cast to avoid "enumeral
// mismatch" - thanks a lot, xpidl.
nsLoadFlags loadFlags = (nsLoadFlags)nsIRequest::LOAD_BACKGROUND |
(allowNetworking ? (nsLoadFlags)nsIRequest::LOAD_NORMAL :
((nsLoadFlags)nsIRequest::LOAD_FROM_CACHE |
(nsLoadFlags)nsICachingChannel::LOAD_ONLY_FROM_CACHE));
// we have to make a channel ourselves for the streamloader, so that we can
// do the nsICachingChannel stuff.

Просмотреть файл

@ -199,7 +199,8 @@ static NSString* const kFileDescriptorKey = @"fdes";
@try {
struct kevent event;
int n = kevent(mQueueFileDesc, NULL, 0, &event, 1, &timeInterval);
int n = kevent(mQueueFileDesc, NULL, 0, &event, 1,
(const struct timespec*)&timeInterval);
if (n > 0 && event.filter == EVFILT_VNODE && event.fflags) {
[self directoryChanged:(NSString*)event.udata];
}

Просмотреть файл

@ -681,7 +681,7 @@ CHBrowserListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequ
[obj onLoadingStarted];
}
while ((obj = [enumerator nextObject]))
[obj onResourceLoadingStarted:[NSNumber numberWithUnsignedLongLong:(unsigned long long)aRequest]];
[obj onResourceLoadingStarted:[NSValue valueWithPointer:aRequest]];
}
else if (aStateFlags & nsIWebProgressListener::STATE_STOP) {
if (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) {
@ -689,7 +689,7 @@ CHBrowserListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequ
[obj onLoadingCompleted:(NS_SUCCEEDED(aStatus))];
}
while ((obj = [enumerator nextObject]))
[obj onResourceLoadingCompleted:[NSNumber numberWithUnsignedLongLong:(unsigned long long)aRequest]];
[obj onResourceLoadingCompleted:[NSValue valueWithPointer:aRequest]];
}
return NS_OK;

Просмотреть файл

@ -71,8 +71,8 @@ class nsIFocusController;
- (void)onLoadingCompleted:(BOOL)succeeded;
// Called when each resource on a page (the main HTML plus any subsidiary
// resources such as images and style sheets) starts ond finishes.
- (void)onResourceLoadingStarted:(NSNumber*)resourceIdentifier;
- (void)onResourceLoadingCompleted:(NSNumber*)resourceIdentifier;
- (void)onResourceLoadingStarted:(NSValue*)resourceIdentifier;
- (void)onResourceLoadingCompleted:(NSValue*)resourceIdentifier;
// Invoked regularly as data associated with a page streams
// in. If the total number of bytes expected is unknown,
// maxBytes is -1.

Просмотреть файл

@ -1049,7 +1049,8 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
{
nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
if (commandMgr) {
nsresult rv = commandMgr->DoCommand(commandName, nsnull, nsnull);
nsresult rv;
rv = commandMgr->DoCommand(commandName, nsnull, nsnull);
#if DEBUG
if (NS_FAILED(rv))
NSLog(@"DoCommand failed");
@ -1067,7 +1068,8 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
PRBool isEnabled = PR_FALSE;
nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
if (commandMgr) {
nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull, &isEnabled);
nsresult rv;
rv = commandMgr->IsCommandEnabled(commandName, nsnull, &isEnabled);
#if DEBUG
if (NS_FAILED(rv))
NSLog(@"IsCommandEnabled failed");

Просмотреть файл

@ -162,7 +162,7 @@ static OSStatus MenuEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef
- (NSMenuItem*)itemWithTarget:(id)anObject andAction:(SEL)actionSelector
{
int itemIndex = [self indexOfItemWithTarget:anObject andAction:actionSelector];
return (itemIndex == -1) ? nil : [self itemAtIndex:itemIndex];
return (itemIndex == -1) ? (NSMenuItem*)nil : [self itemAtIndex:itemIndex];
}
- (void)removeItemsAfterItem:(NSMenuItem*)inItem

Просмотреть файл

@ -180,7 +180,8 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused)
mKeychainCacheTimers = [[NSMutableDictionary alloc] init];
// load the keychain.nib file with our dialogs in it
BOOL success = [NSBundle loadNibNamed:@"Keychain" owner:self];
BOOL success;
success = [NSBundle loadNibNamed:@"Keychain" owner:self];
NS_ASSERTION(success, "can't load keychain prompt dialogs");
}
return self;
@ -1347,11 +1348,11 @@ KeychainFormSubmitObserver::Notify(nsIDOMHTMLFormElement* formNode, nsIDOMWindow
{
}
- (void)onResourceLoadingStarted:(NSNumber*)resourceIdentifier
- (void)onResourceLoadingStarted:(NSValue*)resourceIdentifier
{
}
- (void)onResourceLoadingCompleted:(NSNumber*)resourceIdentifier
- (void)onResourceLoadingCompleted:(NSValue*)resourceIdentifier
{
}

Просмотреть файл

@ -240,7 +240,7 @@ MOZ_DECL_CTOR_COUNTER(wallet_MapElement)
class wallet_MapElement {
public:
wallet_MapElement()
: itemList(nsnull), item1(nsnull), item2(nsnull)
: item1(nsnull), item2(nsnull), itemList(nsnull)
{
MOZ_COUNT_CTOR(wallet_MapElement);
}
@ -1243,15 +1243,18 @@ wallet_PutLine(nsIOutputStream* strm, const char* line) {
wallet_EndLine(strm);
}
#if UNUSED
static void
wallet_PutHeader(nsIOutputStream* strm) {
/* format revision number */
wallet_PutLine(strm, HEADER_VERSION);
}
#endif // UNUSED
#define WALLET_NULL(_ptr) (!(_ptr) || !(_ptr)[0])
#if UNUSED
/*
* write contents of designated list into designated file
*/
@ -1322,6 +1325,7 @@ wallet_WriteToFile(const char * filename, nsVoidArray* list) {
}
}
}
#endif // UNUSED
/*
* Read contents of designated file into designated list
@ -1498,7 +1502,9 @@ static void wallet_InitListFromAppleAddressBook(nsVoidArray** inList)
static PRBool wallet_tablesInitialized = PR_FALSE;
static PRBool wallet_ValuesReadIn = PR_FALSE;
static PRBool namesInitialized = PR_FALSE;
#if UNUSED
static PRBool wallet_URLListInitialized = PR_FALSE;
#endif // UNUSED
static void
wallet_Initialize(PRBool unlockDatabase)
@ -2554,6 +2560,7 @@ wallet_Size(nsVoidArray * list) {
#endif
#if UNUSED
static void
wallet_InitializeURLList() {
if (!wallet_URLListInitialized) {
@ -2562,6 +2569,7 @@ wallet_InitializeURLList() {
wallet_URLListInitialized = PR_TRUE;
}
}
#endif // UNUSED
/*
* initialization for current URL
@ -2582,6 +2590,7 @@ wallet_InitializeCurrentURL(nsIDocument * doc) {
}
#if UNUSED
#define SEPARATOR "#*%$"
static nsresult
@ -2594,6 +2603,7 @@ wallet_GetNextInString(const nsString& str, nsString& head, nsString& tail) {
str.Mid(tail, separator+sizeof(SEPARATOR)-1, str.Length() - (separator+sizeof(SEPARATOR)-1));
return NS_OK;
}
#endif // UNUSED
@ -2624,6 +2634,7 @@ WLLT_GetPrefillListForViewer(nsAString& aPrefillList)
aPrefillList = buffer;
}
#if UNUSED
static void
wallet_FreeURL(wallet_MapElement *url) {
@ -2633,6 +2644,7 @@ wallet_FreeURL(wallet_MapElement *url) {
wallet_URL_list->RemoveElement(url);
PR_Free(url);
}
#endif // UNUSED
#if UNUSED

Просмотреть файл

@ -189,13 +189,6 @@ matchHostCallback(nsIMdbRow *row, void *aClosure)
return hostInfo->history->MatchHost(row, hostInfo);
}
static PRBool
matchQueryCallback(nsIMdbRow *row, void *aClosure)
{
MatchQueryData *query = (MatchQueryData*)aClosure;
return query->history->RowMatches(row, query->query);
}
static PRBool HasCell(nsIMdbEnv *aEnv, nsIMdbRow* aRow, mdb_column aCol)
{
mdbYarn yarn;
@ -329,13 +322,11 @@ public:
nsMdbTableAllRowsEnumerator(nsSimpleGlobalHistory* inHistory,
nsIMdbTable* aTable,
mdb_column inHiddenColumnToken)
: mHiddenColumnToken(inHiddenColumnToken),
nsHistoryMdbTableEnumerator(inHistory, aTable)
: nsHistoryMdbTableEnumerator(inHistory, aTable),
mHiddenColumnToken(inHiddenColumnToken)
{}
virtual ~nsMdbTableAllRowsEnumerator()
{
}
{}
protected:
virtual PRBool IsResult(nsIMdbRow* aRow)
@ -451,10 +442,10 @@ nsHistoryItem::GetID(nsACString& outIDString)
nsSimpleGlobalHistory::nsSimpleGlobalHistory()
: mExpireDays(9), // make default be nine days
mAutocompleteOnlyTyped(PR_FALSE),
mBatchesInProgress(0),
mDirty(PR_FALSE),
mPagesRemoved(PR_FALSE),
mAutocompleteOnlyTyped(PR_FALSE),
mEnv(nsnull),
mStore(nsnull),
mTable(nsnull)
@ -2712,8 +2703,8 @@ nsSimpleGlobalHistory::AutoCompleteSearch(const nsACString& aSearchString,
void
nsSimpleGlobalHistory::AutoCompleteGetExcludeInfo(const nsACString& aURL, AutocompleteExcludeData* aExclude)
{
aExclude->schemePrefix = -1;
aExclude->hostnamePrefix = -1;
aExclude->schemePrefix = -1U;
aExclude->hostnamePrefix = -1U;
PRInt32 index = 0;
PRInt32 i;

Просмотреть файл

@ -43,7 +43,6 @@
#import "nsCOMPtr.h"
#import "nsString.h"
#import "nsIMutableArray.h"
#import "nsArrayUtils.h"
#import "nsIX509Cert.h"
#import "nsIX509CertValidity.h"
@ -164,7 +163,9 @@ NSString* const CertificateChangedNotificationName = @"CertificateChangedNotific
for (PRUint32 i = 0; i < chainLength; i ++)
{
nsCOMPtr<nsIX509Cert> thisCert = do_QueryElementAt(parentChain, i);
nsCOMPtr<nsIX509Cert> thisCert;
parentChain->QueryElementAt(i, NS_GET_IID(nsIX509Cert),
getter_AddRefs(thisCert));
if (!thisCert) continue;
PRBool isSameCert;
@ -716,7 +717,10 @@ NSString* const CertificateChangedNotificationName = @"CertificateChangedNotific
objectsArray->GetLength(&numObjects);
for (PRUint32 i = 0; i < numObjects; i ++)
{
nsCOMPtr<nsIASN1Object> thisObject = do_QueryElementAt(objectsArray, i);
nsCOMPtr<nsIASN1Object> thisObject;
objectsArray->QueryElementAt(i, NS_GET_IID(nsIASN1Object),
getter_AddRefs(thisObject));
if (!thisObject) continue;
nsAutoString displayName;
thisObject->GetDisplayName(displayName);