[Scummvm-git-logs] scummvm master -> c2727b1d1d28afdf26131a206d85b6b97414ac91
Strangerke
noreply at scummvm.org
Sun May 19 12:25:33 UTC 2024
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a17658a6f4 BAGEL: More work on useless null checks
c2727b1d1d BAGEL: Change the type pour CBagSoundObject::newSound to avoid an unused return value
Commit: a17658a6f45b4ef469a3acb8926318a8bea4a87f
https://github.com/scummvm/scummvm/commit/a17658a6f45b4ef469a3acb8926318a8bea4a87f
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T13:24:35+01:00
Commit Message:
BAGEL: More work on useless null checks
Changed paths:
engines/bagel/baglib/rp_object.cpp
engines/bagel/baglib/sound_object.cpp
engines/bagel/baglib/sprite_object.cpp
engines/bagel/baglib/storage_dev_win.cpp
engines/bagel/baglib/text_object.cpp
engines/bagel/baglib/time_object.cpp
diff --git a/engines/bagel/baglib/rp_object.cpp b/engines/bagel/baglib/rp_object.cpp
index d328632fd11..ab16d275f1e 100644
--- a/engines/bagel/baglib/rp_object.cpp
+++ b/engines/bagel/baglib/rp_object.cpp
@@ -218,9 +218,7 @@ ParseCodes CBagRPObject::setInfo(CBagIfstream &istr) {
istr.eatWhite();
if ((char)istr.peek() == '(') {
px = new CBagExpression();
- if (px) {
- px->setInfo(istr);
- }
+ px->setInfo(istr);
}
// add this to the correct list.
@@ -332,7 +330,7 @@ ParseCodes CBagRPObject::setInfo(CBagIfstream &istr) {
nObjectUpdated = true;
_pDescObj = new CBagTextObject();
- if (_pDescObj && _pDescObj->setInfo(istr) == PARSING_DONE) {
+ if (_pDescObj->setInfo(istr) == PARSING_DONE) {
return PARSING_DONE;
}
} else {
@@ -479,10 +477,7 @@ void CBagRPObject::setTouchedDos(CBofString &s, CBagExpression *x) {
_pTouchedList = new CBofList<DossierObj *>;
}
- assert(_pTouchedList != nullptr);
-
DossierObj *pDosObj = new DossierObj();
- assert(pDosObj != nullptr);
// Just store the name for now, we'll get the pointer to the dossier in
// the attach code.
@@ -499,10 +494,7 @@ void CBagRPObject::setUntouchedDos(CBofString &s, CBagExpression *x) {
_pUntouchedList = new CBofList<DossierObj *>;
}
- assert(_pUntouchedList != nullptr);
-
DossierObj *pDosObj = new DossierObj();
- assert(pDosObj != nullptr);
// Store the expression and the dossier string.
pDosObj->_sDossier = s;
diff --git a/engines/bagel/baglib/sound_object.cpp b/engines/bagel/baglib/sound_object.cpp
index 124e6bb5b51..4818f724f77 100644
--- a/engines/bagel/baglib/sound_object.cpp
+++ b/engines/bagel/baglib/sound_object.cpp
@@ -69,13 +69,8 @@ ErrorCode CBagSoundObject::newSound(CBofWindow *pWin) {
killSound();
_pSound = new CBofSound(pWin, getFileName(), _wFlags, _nLoops);
- if (_pSound != nullptr) {
- _pSound->setVolume(_nVol);
- _pSound->setQSlot(getState());
-
- } else {
- errorCode = ERR_MEMORY;
- }
+ _pSound->setVolume(_nVol);
+ _pSound->setQSlot(getState());
return errorCode;
}
diff --git a/engines/bagel/baglib/sprite_object.cpp b/engines/bagel/baglib/sprite_object.cpp
index 03c4dcf4e62..6b943251624 100644
--- a/engines/bagel/baglib/sprite_object.cpp
+++ b/engines/bagel/baglib/sprite_object.cpp
@@ -54,8 +54,6 @@ ErrorCode CBagSpriteObject::attach() {
assert(_xSprite == nullptr);
_xSprite = new CBofSprite();
- if (_xSprite == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate sprite");
if (_xSprite->loadSprite(getFileName(), getCels()) != false && (_xSprite->width() != 0) && (_xSprite->height() != 0)) {
if (isTransparent()) {
diff --git a/engines/bagel/baglib/storage_dev_win.cpp b/engines/bagel/baglib/storage_dev_win.cpp
index 1d9303eeecd..e38480714ca 100644
--- a/engines/bagel/baglib/storage_dev_win.cpp
+++ b/engines/bagel/baglib/storage_dev_win.cpp
@@ -716,11 +716,10 @@ ErrorCode CBagStorageDev::loadFileFromStream(CBagIfstream &fpInput, const CBofSt
// Added a bPrevNeg to keep track of nested else-if's
CBagExpression *pExp = new CBagExpression(pActiveExpr, bPrevNeg);
- assert(pExp != nullptr);
pExp->setInfo(fpInput);
if (!_pExpressionList)
_pExpressionList = new CBofList<CBagExpression * >;
- assert(_pExpressionList != nullptr);
+
_pExpressionList->addToTail(pExp);
pActiveExpr = pExp;
} else if (!sWorkStr.find("ELSE")) {
@@ -971,7 +970,7 @@ ErrorCode CBagStorageDev::attach() {
if (!_sBackgroundName.isEmpty()) {
CBofBitmap *pBmp = new CBofBitmap(_sBackgroundName);
- if ((pBmp != nullptr) && !pBmp->errorOccurred()) {
+ if (!pBmp->errorOccurred()) {
setBackground(pBmp);
errorCode = attachActiveObjects();
} else {
@@ -1181,7 +1180,7 @@ ErrorCode CBagStorageDevWnd::attach() {
CBofBitmap *pBmp = new CBofBitmap(getBackgroundName());
- if ((pBmp == nullptr) || (pBmp->height() <= 0) || (pBmp->width() <= 0)) {
+ if ((pBmp->height() <= 0) || (pBmp->width() <= 0)) {
reportError(ERR_FOPEN, "BarComputer Background Opened Failed");
} else {
diff --git a/engines/bagel/baglib/text_object.cpp b/engines/bagel/baglib/text_object.cpp
index 8393b2bdff6..afe777f49f8 100644
--- a/engines/bagel/baglib/text_object.cpp
+++ b/engines/bagel/baglib/text_object.cpp
@@ -135,36 +135,35 @@ ErrorCode CBagTextObject::attach() {
// Allocate a new string
_psText = new CBofString;
- if (_psText != nullptr) {
- CBofFile fpTextFile(getFileName());
- if (!fpTextFile.errorOccurred()) {
- // Allocate the buffers
- uint32 nFileLen = fpTextFile.getLength();
- char *pTextBuff = (char *)bofCAlloc(nFileLen + 1, 1);
- if (pTextBuff == nullptr)
- fatalError(ERR_MEMORY, "Unable to allocate a Text buffer of %u bytes", nFileLen + 1);
+ CBofFile fpTextFile(getFileName());
- // Read the text file into buffers
- fpTextFile.read(pTextBuff, nFileLen);
- fpTextFile.close();
+ if (!fpTextFile.errorOccurred()) {
+ // Allocate the buffers
+ uint32 nFileLen = fpTextFile.getLength();
+ char *pTextBuff = (char *)bofCAlloc(nFileLen + 1, 1);
+ if (pTextBuff == nullptr)
+ fatalError(ERR_MEMORY, "Unable to allocate a Text buffer of %u bytes", nFileLen + 1);
- *_psText += pTextBuff;
+ // Read the text file into buffers
+ fpTextFile.read(pTextBuff, nFileLen);
+ fpTextFile.close();
- if (_psInitInfo != nullptr) {
- CBagVar *pVar = g_VarManager->getVariable(*_psInitInfo);
+ *_psText += pTextBuff;
- if (pVar != nullptr) {
- _bReAttach = true;
- _psText->replaceStr("%s", pVar->getValue());
- }
+ if (_psInitInfo != nullptr) {
+ CBagVar *pVar = g_VarManager->getVariable(*_psInitInfo);
+
+ if (pVar != nullptr) {
+ _bReAttach = true;
+ _psText->replaceStr("%s", pVar->getValue());
}
+ }
- bofFree(pTextBuff);
+ bofFree(pTextBuff);
- } else {
- reportError(ERR_FOPEN, "Failed to create a CBofFile for %s", getFileName().getBuffer());
- }
+ } else {
+ reportError(ERR_FOPEN, "Failed to create a CBofFile for %s", getFileName().getBuffer());
}
if (isCaption()) {
@@ -179,9 +178,6 @@ ErrorCode CBagTextObject::attach() {
// Allocate a new string
_psText = new CBofString;
- if (_psText == nullptr)
- fatalError(ERR_MEMORY, "Unable to allocate a CBofString");
-
*_psText = getFileName();
// Replace any underscores with spaces
diff --git a/engines/bagel/baglib/time_object.cpp b/engines/bagel/baglib/time_object.cpp
index 58ae49df2e3..3c1ea38e84f 100644
--- a/engines/bagel/baglib/time_object.cpp
+++ b/engines/bagel/baglib/time_object.cpp
@@ -47,8 +47,6 @@ ErrorCode CBagTimeObject::attach() {
CBofPoint p = CBagObject::getPosition();
_xDig1 = new CBofSprite();
- if (_xDig1 == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate Dig1 sprite");
if (_xDig1->loadSprite(getFileName(), getCels()) != 0 && (_xDig1->width() != 0) && (_xDig1->height() != 0)) {
_xDig1->setAnimated(false);
@@ -61,8 +59,6 @@ ErrorCode CBagTimeObject::attach() {
}
_xDig2 = new CBofSprite();
- if (_xDig2 == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate Dig2 sprite");
if (_xDig2->loadSprite(getFileName(), getCels()) != 0 && (_xDig2->width() != 0) && (_xDig2->height() != 0)) {
_xDig2->setAnimated(false);
@@ -73,8 +69,6 @@ ErrorCode CBagTimeObject::attach() {
}
_xColon = new CBofSprite();
- if (_xColon == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate Colon sprite");
if (_xColon->loadSprite(getFileName(), getCels()) != 0 && (_xColon->width() != 0) && (_xColon->height() != 0)) {
_xColon->setAnimated(false);
@@ -88,8 +82,6 @@ ErrorCode CBagTimeObject::attach() {
}
_xDig3 = new CBofSprite();
- if (_xDig3 == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate Dig3 sprite");
if (_xDig3->loadSprite(getFileName(), getCels()) != 0 && (_xDig3->width() != 0) && (_xDig3->height() != 0)) {
_xDig3->setAnimated(false);
@@ -100,8 +92,6 @@ ErrorCode CBagTimeObject::attach() {
}
_xDig4 = new CBofSprite();
- if (_xDig4 == nullptr)
- fatalError(ERR_MEMORY, "Could not allocate Dig4 sprite");
if (_xDig4->loadSprite(getFileName(), getCels()) != 0 && (_xDig4->width() != 0) && (_xDig4->height() != 0)) {
_xDig4->setAnimated(false);
Commit: c2727b1d1d28afdf26131a206d85b6b97414ac91
https://github.com/scummvm/scummvm/commit/c2727b1d1d28afdf26131a206d85b6b97414ac91
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-19T13:25:27+01:00
Commit Message:
BAGEL: Change the type pour CBagSoundObject::newSound to avoid an unused return value
Changed paths:
engines/bagel/baglib/sound_object.cpp
engines/bagel/baglib/sound_object.h
diff --git a/engines/bagel/baglib/sound_object.cpp b/engines/bagel/baglib/sound_object.cpp
index 4818f724f77..ec3b65e6f49 100644
--- a/engines/bagel/baglib/sound_object.cpp
+++ b/engines/bagel/baglib/sound_object.cpp
@@ -62,17 +62,12 @@ ErrorCode CBagSoundObject::attach(CBofWindow *pWnd) {
return CBagObject::attach();
}
-ErrorCode CBagSoundObject::newSound(CBofWindow *pWin) {
- // assume no error
- ErrorCode errorCode = ERR_NONE;
-
+void CBagSoundObject::newSound(CBofWindow *pWin) {
killSound();
_pSound = new CBofSound(pWin, getFileName(), _wFlags, _nLoops);
_pSound->setVolume(_nVol);
_pSound->setQSlot(getState());
-
- return errorCode;
}
void CBagSoundObject::killSound() {
diff --git a/engines/bagel/baglib/sound_object.h b/engines/bagel/baglib/sound_object.h
index 250abdbc09f..b0f6bd11275 100644
--- a/engines/bagel/baglib/sound_object.h
+++ b/engines/bagel/baglib/sound_object.h
@@ -50,7 +50,7 @@ public:
static void initialize();
void killSound();
- ErrorCode newSound(CBofWindow *pWin);
+ void newSound(CBofWindow *pWin);
// Return true if the Object had members that are properly initialized/de-initialized
ErrorCode attach() override {
More information about the Scummvm-git-logs
mailing list