Bug 735975 - Get rid of UNEXPECTED_ERROR codes from updater error handling. r=ehsan

This commit is contained in:
Brian R. Bondy 2012-06-21 19:40:47 -04:00
parent 7393218c0a
commit e2564e9daa
6 changed files with 35 additions and 25 deletions

View File

@ -19,7 +19,7 @@
#define PARSE_ERROR 5
#define READ_ERROR 6
#define WRITE_ERROR 7
#define UNEXPECTED_ERROR 8
// #define UNEXPECTED_ERROR 8 // Replaced with errors 38-42
#define ELEVATION_CANCELED 9
#define READ_STRINGS_MEM_ERROR 10
#define ARCHIVE_READER_MEM_ERROR 11
@ -56,6 +56,11 @@
#define WRITE_ERROR_ACCESS_DENIED 35
#define WRITE_ERROR_SHARING_VIOLATION 36
#define WRITE_ERROR_CALLBACK_APP 37
#define INVALID_UPDATER_STATUS_CODE 38
#define UNEXPECTED_BZIP_ERROR 39
#define UNEXPECTED_MAR_ERROR 40
#define UNEXPECTED_BSPATCH_ERROR 41
#define UNEXPECTED_FILE_OPERATION_ERROR 42
// The following error codes are only used by updater.exe
// when a fallback key exists and XPCShell tests are being run.

View File

@ -111,7 +111,7 @@ const STATE_FAILED = "failed";
// From updater/errors.h:
const WRITE_ERROR = 7;
const UNEXPECTED_ERROR = 8;
// const UNEXPECTED_ERROR = 8; // Replaced with errors 38-42
const ELEVATION_CANCELED = 9;
// Windows service specific errors
@ -126,9 +126,14 @@ const SERVICE_UPDATER_NOT_FIXED_DRIVE = 31;
const SERVICE_COULD_NOT_LOCK_UPDATER = 32;
const SERVICE_INSTALLDIR_ERROR = 33;
const WRITE_ERROR_ACCESS_DENIED = 35;
const WRITE_ERROR_SHARING_VIOLATION = 36;
const WRITE_ERROR_CALLBACK_APP = 37;
const WRITE_ERROR_ACCESS_DENIED = 35;
const WRITE_ERROR_SHARING_VIOLATION = 36;
const WRITE_ERROR_CALLBACK_APP = 37;
const INVALID_UPDATER_STATUS_CODE = 38;
const UNEXPECTED_BZIP_ERROR = 39;
const UNEXPECTED_MAR_ERROR = 40;
const UNEXPECTED_BSPATCH_ERROR = 41;
const UNEXPECTED_FILE_OPERATION_ERROR = 42;
const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100;
const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101;
@ -1754,7 +1759,7 @@ UpdateService.prototype = {
}
let result = 0; // 0 means success
if (parts.length > 1) {
result = parseInt(parts[1]) || UNEXPECTED_ERROR;
result = parseInt(parts[1]) || INVALID_UPDATER_STATUS_CODE;
}
Services.telemetry.getHistogramById("UPDATER_STATUS_CODES").add(result);
} catch(e) {

View File

@ -182,5 +182,5 @@ FINISH REMOVEFILE a/b/3/3text1
backup_restore: backup file doesn't exist: a/b/3/3text1.moz-backup
FINISH REMOVEFILE a/b/3/3text0
backup_restore: backup file doesn't exist: a/b/3/3text0.moz-backup
failed: 8
failed: 42
calling QuitProgressUI

View File

@ -312,12 +312,12 @@ ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
memset(&strm, 0, sizeof(strm));
if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK)
return UNEXPECTED_ERROR;
return UNEXPECTED_BZIP_ERROR;
offset = 0;
for (;;) {
if (!item->length) {
ret = UNEXPECTED_ERROR;
ret = UNEXPECTED_MAR_ERROR;
break;
}
@ -335,7 +335,7 @@ ArchiveReader::ExtractItemToStream(const MarItem *item, FILE *fp)
ret = BZ2_bzDecompress(&strm);
if (ret != BZ_OK && ret != BZ_STREAM_END) {
ret = UNEXPECTED_ERROR;
ret = UNEXPECTED_BZIP_ERROR;
break;
}

View File

@ -75,13 +75,13 @@ MBS_ReadHeader(FILE* file, MBSPatchHeader *header)
return READ_ERROR;
if (memcmp(header->tag, "MBDIFF10", 8) != 0)
return UNEXPECTED_ERROR;
return UNEXPECTED_BSPATCH_ERROR;
if (sizeof(MBSPatchHeader) +
header->cblen +
header->difflen +
header->extralen != PRUint32(hs.st_size))
return UNEXPECTED_ERROR;
return UNEXPECTED_BSPATCH_ERROR;
return OK;
}
@ -142,7 +142,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
if (fbuffer + ctrlsrc->x > fbufend ||
diffsrc + ctrlsrc->x > diffend) {
rv = UNEXPECTED_ERROR;
rv = UNEXPECTED_BSPATCH_ERROR;
goto end;
}
for (PRUint32 i = 0; i < ctrlsrc->x; ++i) {
@ -158,7 +158,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
/* Copy y bytes from the extra block */
if (extrasrc + ctrlsrc->y > extraend) {
rv = UNEXPECTED_ERROR;
rv = UNEXPECTED_BSPATCH_ERROR;
goto end;
}
if ((PRUint32) fwrite(extrasrc, 1, ctrlsrc->y, file) != ctrlsrc->y) {
@ -170,7 +170,7 @@ MBS_ApplyPatch(const MBSPatchHeader *header, FILE* patchFile,
/* "seek" forwards in oldfile by z bytes */
if (fbuffer + ctrlsrc->z > fbufend) {
rv = UNEXPECTED_ERROR;
rv = UNEXPECTED_BSPATCH_ERROR;
goto end;
}
fbuffer += ctrlsrc->z;

View File

@ -750,7 +750,7 @@ static int rename_file(const NS_tchar *spath, const NS_tchar *dpath,
if (allowDirs && !S_ISDIR(spathInfo.st_mode)) {
LOG(("rename_file: path present, but not a file: " LOG_S ", err: %d\n",
spath, errno));
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
} else {
LOG(("rename_file: proceeding to rename the directory\n"));
}
@ -937,7 +937,7 @@ RemoveFile::Prepare()
if (!S_ISREG(fileInfo.st_mode)) {
LOG(("path present, but not a file: " LOG_S "\n", mFile));
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
}
NS_tchar *slash = (NS_tchar *) NS_tstrrchr(mFile, NS_T('/'));
@ -1046,7 +1046,7 @@ RemoveDir::Prepare()
if (!S_ISDIR(dirInfo.st_mode)) {
LOG(("path present, but not a directory: " LOG_S "\n", mDir));
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
}
rv = NS_taccess(mDir, W_OK);
@ -1238,7 +1238,7 @@ PatchFile::LoadSourceFile(FILE* ofile)
if (PRUint32(os.st_size) != header.slen) {
LOG(("LoadSourceFile: destination file size %d does not match expected size %d\n",
PRUint32(os.st_size), header.slen));
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
}
buf = (unsigned char *) malloc(header.slen);
@ -2938,7 +2938,7 @@ ActionList::Prepare()
// actually done. See bug 327140.
if (mCount == 0) {
LOG(("empty action list\n"));
return UNEXPECTED_ERROR;
return UNEXPECTED_MAR_ERROR;
}
Action *a = mFirst;
@ -3098,7 +3098,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
if (!dir) {
LOG(("add_dir_entries error on opendir: " LOG_S ", err: %d\n", searchpath,
errno));
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
}
while (readdir_r(dir, (dirent *)&ent_buf, &ent) == 0 && ent) {
@ -3112,7 +3112,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
int test = stat64(foundpath, &st_buf);
if (test) {
closedir(dir);
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
}
if (S_ISDIR(st_buf.st_mode)) {
NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]),
@ -3185,7 +3185,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
if (!(ftsdir = fts_open(pathargv,
FTS_PHYSICAL | FTS_NOSTAT | FTS_XDEV | FTS_NOCHDIR,
NULL)))
return UNEXPECTED_ERROR;
return UNEXPECTED_FILE_OPERATION_ERROR;
while ((ftsdirEntry = fts_read(ftsdir)) != NULL) {
NS_tchar foundpath[MAXPATHLEN];
@ -3249,13 +3249,13 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list)
// Fall through
case FTS_ERR:
rv = UNEXPECTED_ERROR;
rv = UNEXPECTED_FILE_OPERATION_ERROR;
LOG(("add_dir_entries: fts_read() error: " LOG_S ", err: %d\n",
ftsdirEntry->fts_path, ftsdirEntry->fts_errno));
break;
case FTS_DC:
rv = UNEXPECTED_ERROR;
rv = UNEXPECTED_FILE_OPERATION_ERROR;
LOG(("add_dir_entries: fts_read() returned FT_DC: " LOG_S "\n",
ftsdirEntry->fts_path));
break;