[Scummvm-git-logs] scummvm master -> 3547918296c9146e8d665cfc7dd6d2d8f71a6602

Strangerke noreply at scummvm.org
Fri May 24 20:34:35 UTC 2024


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
14417d1024 BAGEL: Remove useless null check prior to delete in SBarComputer
630f2f66c0 BAGEL: Use bofCleanAlloc instead of bocAlloc when followed by a memset(0)
3547918296 BAGEL: remove a couple of unused methods in CQueue, fix some more PVS Studio issues


Commit: 14417d1024cdd120a9429f8b21b714dcfabb6212
    https://github.com/scummvm/scummvm/commit/14417d1024cdd120a9429f8b21b714dcfabb6212
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-24T21:33:54+01:00

Commit Message:
BAGEL: Remove useless null check prior to delete in SBarComputer

Changed paths:
    engines/bagel/spacebar/computer.cpp


diff --git a/engines/bagel/spacebar/computer.cpp b/engines/bagel/spacebar/computer.cpp
index 471b3f9b0fc..1bab505e8ee 100644
--- a/engines/bagel/spacebar/computer.cpp
+++ b/engines/bagel/spacebar/computer.cpp
@@ -234,10 +234,8 @@ ErrorCode SBarComputer::readDrnkFile() {
 		return fpDrinkFile.getErrorCode();
 
 	// Check that buffers are null
-	if (_pDrinkBuff) {
-		delete _pDrinkBuff;
-		_pDrinkBuff = nullptr;
-	}
+	delete _pDrinkBuff;
+	_pDrinkBuff = nullptr;
 
 	// Allocate the buffers
 	_pDrinkBuff = (char *)bofAlloc(fpDrinkFile.getLength() + 1);


Commit: 630f2f66c09e334fbfc893ec19b22a4c30cdf3d5
    https://github.com/scummvm/scummvm/commit/630f2f66c09e334fbfc893ec19b22a4c30cdf3d5
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-24T21:33:54+01:00

Commit Message:
BAGEL: Use bofCleanAlloc instead of bocAlloc when followed by a memset(0)

Changed paths:
    engines/bagel/baglib/master_win.cpp
    engines/bagel/boflib/res.cpp
    engines/bagel/boflib/string.cpp
    engines/bagel/spacebar/sraf_computer.cpp


diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index ca612cb9bf4..1753fe584be 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -372,10 +372,8 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
 
 			// Only allocate the object list when we really need it...
 			if (_objList == nullptr) {
-				_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
-
-				// Init to zero (we might not use all slots)
-				memset(_objList, 0, MAX_OBJS * sizeof(StObj));
+				// Allocate a buffer filled with 0s
+				_objList = (StObj *)bofCleanAlloc(MAX_OBJS * sizeof(StObj));
 			}
 
 			_storageDeviceList->saveObjList(_objList, MAX_OBJS); // xxx
@@ -1624,10 +1622,8 @@ void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
 		if (sdevManager != nullptr) {
 			// Restore any extra obj list info (for .WLD swapping)
 			if (_objList == nullptr) {
-				_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
-
-				// Init to nullptr (might not use all slots)
-				memset(_objList, 0, MAX_OBJS * sizeof(StObj));
+				// Allocate a buffer filled with 0s
+				_objList = (StObj *)bofCleanAlloc(MAX_OBJS * sizeof(StObj));
 			}
 
 			memcpy(getObjList(), &saveBuf->_stObjListEx[0], sizeof(StObj) * MAX_OBJS);
diff --git a/engines/bagel/boflib/res.cpp b/engines/bagel/boflib/res.cpp
index b9681a9f827..ff37ba7e01f 100644
--- a/engines/bagel/boflib/res.cpp
+++ b/engines/bagel/boflib/res.cpp
@@ -52,10 +52,8 @@ ErrorCode CBofStringTable::load(const char *pszFileName) {
 
 	assert(_lBufSize > 0);
 
-	// Allocate a buffer to hold entire file
-	_pBuf = (byte *)bofAlloc(_lBufSize + 1);
-
-	memset(_pBuf, 0, _lBufSize + 1);
+	// Allocate a buffer to hold entire file and fill it with 0s
+	_pBuf = (byte *)bofCleanAlloc(_lBufSize + 1);
 
 	// Read in entire file
 	read(_pBuf, _lBufSize);
diff --git a/engines/bagel/boflib/string.cpp b/engines/bagel/boflib/string.cpp
index c89b5b0954a..0f50d8bb4ec 100644
--- a/engines/bagel/boflib/string.cpp
+++ b/engines/bagel/boflib/string.cpp
@@ -103,9 +103,8 @@ void CBofString::allocBuffer(int nLen) {
 
 	// Don't do anything about zero length allocations
 	if (nLen > 0) {
-		_pszData = (char *)bofAlloc(nLen + 1);
-		// Set the entire buffer to nullptr
-		memset(_pszData, '\0', nLen + 1);
+		// Allocate a buffer filled with 0s
+		_pszData = (char *)bofCleanAlloc(nLen + 1);
 	}
 
 	_nLength = 0;
diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index 8f759804e9d..f94d2783993 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -4132,9 +4132,7 @@ void SrafComputer::notifyBoss(CBofString &sSoundFile, int nStafferID) {
 		if (nLength == 0) {
 			reportError(ERR_FREAD, "Unexpected empty file %s", sSoundFile.getBuffer());
 		} else {
-			char *pszBuf = (char *)bofAlloc(nLength + 1);
-
-			memset(pszBuf, 0, nLength + 1);
+			char *pszBuf = (char *)bofCleanAlloc(nLength + 1);
 			fTxtFile.read(pszBuf, nLength);
 
 			// Put it up on the screen


Commit: 3547918296c9146e8d665cfc7dd6d2d8f71a6602
    https://github.com/scummvm/scummvm/commit/3547918296c9146e8d665cfc7dd6d2d8f71a6602
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-24T21:33:54+01:00

Commit Message:
BAGEL: remove a couple of unused methods in CQueue, fix some more PVS Studio issues

Changed paths:
    engines/bagel/boflib/options.cpp
    engines/bagel/boflib/queue.cpp
    engines/bagel/boflib/queue.h


diff --git a/engines/bagel/boflib/options.cpp b/engines/bagel/boflib/options.cpp
index 75d21760b6e..eb3d32d8e7c 100644
--- a/engines/bagel/boflib/options.cpp
+++ b/engines/bagel/boflib/options.cpp
@@ -264,9 +264,7 @@ ErrorCode CBofOptions::readSetting(const char *section, const char *option, int
 
 	Common::sprintf_s(szDefault, "%d", defaultValue);
 	ErrorCode errorCode = readSetting(section, option, szBuf, szDefault, 20);
-
-	if (intValue != nullptr)
-		*intValue = atoi(szBuf);
+	*intValue = atoi(szBuf);
 
 	return errorCode;
 }
diff --git a/engines/bagel/boflib/queue.cpp b/engines/bagel/boflib/queue.cpp
index d88ee107a65..fed88bff89d 100644
--- a/engines/bagel/boflib/queue.cpp
+++ b/engines/bagel/boflib/queue.cpp
@@ -27,33 +27,6 @@ namespace Bagel {
 CQueue::CQueue() {
 }
 
-CQueue::CQueue(void *pObject) {
-	// Validate input
-	assert(pObject != nullptr);
-
-	// Start queue with this object
-	addItem(pObject);
-}
-
-CQueue::CQueue(CQueue *pQueue) {
-	// Validate input queue
-	assert(pQueue != nullptr);
-
-	CLList *pList = pQueue->_pQueueList;
-	while (pList != nullptr) {
-		addItem(pList->getData());
-		pList = pList->getNext();
-	}
-}
-
-CQueue::CQueue(const CQueue &cQueue) {
-	CLList *pList = cQueue._pQueueList;
-	while (pList != nullptr) {
-		addItem(pList->getData());
-		pList = pList->getNext();
-	}
-}
-
 CQueue::~CQueue() {
 	// Can't destruct if we don't exist
 	assert(isValidObject(this));
diff --git a/engines/bagel/boflib/queue.h b/engines/bagel/boflib/queue.h
index 8db31de6d92..0b4414d6948 100644
--- a/engines/bagel/boflib/queue.h
+++ b/engines/bagel/boflib/queue.h
@@ -38,24 +38,6 @@ public:
 	 */
 	CQueue();
 
-	/**
-	 * Constructor that adds a passed object onto the queue
-	 * @param pObject       First object
-	 */
-	CQueue(void *pObject);
-
-	/**
-	 * Constructor that copies an existing queue
-	 * @param pQueue        Source queue
-	 */
-	CQueue(CQueue *pQueue);
-
-	/**
-	 * Constructor that copies an existing queue
-	 * @param cQueue        Source queue
-	*/
-	CQueue(const CQueue &cQueue);
-
 	/**
 	 * Destructor
 	*/




More information about the Scummvm-git-logs mailing list