From e4ebafaa4ba75e0db0bed5681c317dbbcb05e5d6 Mon Sep 17 00:00:00 2001 From: "darin%meer.net" Date: Wed, 12 Nov 2003 20:09:05 +0000 Subject: [PATCH] fix uninitialized variable warning, bug 204503, patch by alfredkayser@nl.ibm.com, r+sr=darin --- modules/libjar/nsJARChannel.cpp | 61 ++++++++++------------- netwerk/protocol/jar/src/nsJARChannel.cpp | 61 ++++++++++------------- 2 files changed, 52 insertions(+), 70 deletions(-) diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index e4b123b6dad7..85e6fd4424ae 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -470,44 +470,35 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo) NS_IMETHODIMP nsJARChannel::GetContentType(nsACString &result) { - nsresult rv; - - if (!mContentType.IsEmpty()) { - result = mContentType; - return NS_OK; - } - - // - // generate content type and set it - // - if (mJarEntry.IsEmpty()) { - LOG(("mJarEntry is empty!\n")); - return NS_ERROR_NOT_AVAILABLE; - } - - const char *ext = nsnull, *fileName = mJarEntry.get(); - PRInt32 len = mJarEntry.Length(); - for (PRInt32 i = len-1; i >= 0; i--) { - if (fileName[i] == '.') { - ext = &fileName[i + 1]; - break; + if (mContentType.IsEmpty()) { + // + // generate content type and set it + // + if (mJarEntry.IsEmpty()) { + LOG(("mJarEntry is empty!\n")); + return NS_ERROR_NOT_AVAILABLE; } - } - if (ext) { - nsIMIMEService *mimeServ = gJarHandler->MimeService(); - if (mimeServ) { - nsXPIDLCString mimeType; - rv = mimeServ->GetTypeFromExtension(ext, getter_Copies(mimeType)); - if (NS_SUCCEEDED(rv)) - mContentType = mimeType; + + const char *ext = nsnull, *fileName = mJarEntry.get(); + PRInt32 len = mJarEntry.Length(); + for (PRInt32 i = len-1; i >= 0; i--) { + if (fileName[i] == '.') { + ext = &fileName[i + 1]; + break; + } } + if (ext) { + nsIMIMEService *mimeServ = gJarHandler->MimeService(); + if (mimeServ) { + nsXPIDLCString mimeType; + nsresult rv = mimeServ->GetTypeFromExtension(ext, getter_Copies(mimeType)); + if (NS_SUCCEEDED(rv)) + mContentType = mimeType; + } + } + if (mContentType.IsEmpty()) + mContentType = NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE); } - else - rv = NS_ERROR_NOT_AVAILABLE; - - if (NS_FAILED(rv) || mContentType.IsEmpty()) - mContentType = NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE); - result = mContentType; return NS_OK; } diff --git a/netwerk/protocol/jar/src/nsJARChannel.cpp b/netwerk/protocol/jar/src/nsJARChannel.cpp index e4b123b6dad7..85e6fd4424ae 100644 --- a/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -470,44 +470,35 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo) NS_IMETHODIMP nsJARChannel::GetContentType(nsACString &result) { - nsresult rv; - - if (!mContentType.IsEmpty()) { - result = mContentType; - return NS_OK; - } - - // - // generate content type and set it - // - if (mJarEntry.IsEmpty()) { - LOG(("mJarEntry is empty!\n")); - return NS_ERROR_NOT_AVAILABLE; - } - - const char *ext = nsnull, *fileName = mJarEntry.get(); - PRInt32 len = mJarEntry.Length(); - for (PRInt32 i = len-1; i >= 0; i--) { - if (fileName[i] == '.') { - ext = &fileName[i + 1]; - break; + if (mContentType.IsEmpty()) { + // + // generate content type and set it + // + if (mJarEntry.IsEmpty()) { + LOG(("mJarEntry is empty!\n")); + return NS_ERROR_NOT_AVAILABLE; } - } - if (ext) { - nsIMIMEService *mimeServ = gJarHandler->MimeService(); - if (mimeServ) { - nsXPIDLCString mimeType; - rv = mimeServ->GetTypeFromExtension(ext, getter_Copies(mimeType)); - if (NS_SUCCEEDED(rv)) - mContentType = mimeType; + + const char *ext = nsnull, *fileName = mJarEntry.get(); + PRInt32 len = mJarEntry.Length(); + for (PRInt32 i = len-1; i >= 0; i--) { + if (fileName[i] == '.') { + ext = &fileName[i + 1]; + break; + } } + if (ext) { + nsIMIMEService *mimeServ = gJarHandler->MimeService(); + if (mimeServ) { + nsXPIDLCString mimeType; + nsresult rv = mimeServ->GetTypeFromExtension(ext, getter_Copies(mimeType)); + if (NS_SUCCEEDED(rv)) + mContentType = mimeType; + } + } + if (mContentType.IsEmpty()) + mContentType = NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE); } - else - rv = NS_ERROR_NOT_AVAILABLE; - - if (NS_FAILED(rv) || mContentType.IsEmpty()) - mContentType = NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE); - result = mContentType; return NS_OK; }