From dd0efa24104cecd854370e8d88dfb74e84bfff94 Mon Sep 17 00:00:00 2001 From: Nikolaj Schlej Date: Sun, 17 Apr 2016 01:48:07 +0200 Subject: [PATCH] Static analysis FTW - a bit of leftovers for previous commit found by static analyzer --- common/Tiano/EfiTianoCompressLegacy.c | 21 ++++++++++++++------- common/types.cpp | 10 +++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/common/Tiano/EfiTianoCompressLegacy.c b/common/Tiano/EfiTianoCompressLegacy.c index 7142ca8..11e071c 100644 --- a/common/Tiano/EfiTianoCompressLegacy.c +++ b/common/Tiano/EfiTianoCompressLegacy.c @@ -529,17 +529,24 @@ STATIC { UINT32 Index; - mText = malloc (WNDSIZ * 2 + MAXMATCH); + mText = malloc (WNDSIZ * 2 + MAXMATCH); + if (!mText) return EFI_OUT_OF_RESOURCES; for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) { mText[Index] = 0; } - mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); - mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); - mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); - mParent = malloc (WNDSIZ * 2 * sizeof (*mParent)); - mPrev = malloc (WNDSIZ * 2 * sizeof (*mPrev)); - mNext = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext)); + mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel)); + if (!mLevel) return EFI_OUT_OF_RESOURCES; + mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount)); + if (!mChildCount) return EFI_OUT_OF_RESOURCES; + mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition)); + if (!mPosition) return EFI_OUT_OF_RESOURCES; + mParent = malloc (WNDSIZ * 2 * sizeof (*mParent)); + if (!mParent) return EFI_OUT_OF_RESOURCES; + mPrev = malloc (WNDSIZ * 2 * sizeof (*mPrev)); + if (!mPrev) return EFI_OUT_OF_RESOURCES; + mNext = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext)); + if (!mNext) return EFI_OUT_OF_RESOURCES; mBufSiz = BLKSIZ; mBuf = malloc (mBufSiz); diff --git a/common/types.cpp b/common/types.cpp index 1c36bd4..613e787 100644 --- a/common/types.cpp +++ b/common/types.cpp @@ -30,6 +30,8 @@ QString regionTypeToQString(const UINT8 type) case Subtypes::EcRegion: return QObject::tr("EC"); case Subtypes::Reserved4Region: return QObject::tr("Reserved4"); }; + + return QObject::tr("Unknown"); } QString itemTypeToQString(const UINT8 type) @@ -59,6 +61,8 @@ QString itemTypeToQString(const UINT8 type) case Types::Microcode: return QObject::tr("Microcode"); case Types::SlicData: return QObject::tr("SLIC data"); } + + return QObject::tr("Unknown"); } QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype) @@ -128,6 +132,8 @@ QString itemSubtypeToQString(const UINT8 type, const UINT8 subtype) if (subtype == Subtypes::AmdMicrocode) return QObject::tr("AMD"); break; } + + return QObject::tr("Unknown"); } QString compressionTypeToQString(const UINT8 algorithm) @@ -141,7 +147,7 @@ QString compressionTypeToQString(const UINT8 algorithm) case COMPRESSION_ALGORITHM_IMLZMA: return QObject::tr("Intel modified LZMA"); } - return QObject::tr("Unknown"); + return QObject::tr("Unknown"); } QString actionTypeToQString(const UINT8 action) @@ -155,4 +161,6 @@ QString actionTypeToQString(const UINT8 action) case Actions::Rebuild: return QObject::tr("Rebuild"); case Actions::Rebase: return QObject::tr("Rebase"); } + + return QObject::tr("Unknown"); } \ No newline at end of file