fix uninitialized variable warning, bug 204503, patch by alfredkayser@nl.ibm.com, r+sr=darin

This commit is contained in:
darin%meer.net 2003-11-12 20:09:05 +00:00
parent dc195dfd03
commit e4ebafaa4b
2 changed files with 52 additions and 70 deletions

View File

@ -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;
}

View File

@ -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;
}