Skip to content

Commit 2c26ba8

Browse files
committed
More code review feedbackFix unused buffer RoadOptionsAdjustements based on feedback
1 parent 162e6cb commit 2c26ba8

File tree

8 files changed

+12
-24
lines changed

8 files changed

+12
-24
lines changed

Core/GameEngine/Source/Common/System/Debug.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ void DebugInit(int flags)
392392
}
393393
strlcat(theLogFileNamePrev, ".txt", ARRAY_SIZE(theLogFileNamePrev));
394394

395+
static_assert(ARRAY_SIZE(theLogFileName) >= ARRAY_SIZE(dirbuf), "Incorrect array size");
395396
strcpy(theLogFileName, dirbuf);
396397
strlcat(theLogFileName, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev));
397398
strlcat(theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE(theLogFileNamePrev));

Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload)
264264
WWASSERT(HierarchyName != NULL);
265265
WWASSERT(aheader.HierarchyName != NULL);
266266
WWASSERT(sizeof(HierarchyName) >= W3D_NAME_LEN);
267-
strcpy(HierarchyName,aheader.HierarchyName);
267+
static_assert(ARRAY_SIZE(HierarchyName) >= ARRAY_SIZE(aheader.HierarchyName), "Incorrect array size");
268+
strcpy(HierarchyName, aheader.HierarchyName);
268269

269270
HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName);
270271
if (base_pose == NULL) {

Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload)
151151
static_assert(ARRAY_SIZE(ModelName) >= ARRAY_SIZE(header.Name), "Incorrect array size");
152152
static_assert(ARRAY_SIZE(BasePoseName) >= ARRAY_SIZE(header.HierarchyName), "Incorrect array size");
153153
static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(ModelName), "Incorrect array size");
154-
strcpy(ModelName,header.Name);
155-
strcpy(BasePoseName,header.HierarchyName);
154+
strcpy(ModelName, header.Name);
155+
strcpy(BasePoseName, header.HierarchyName);
156156
strcpy(Name, ModelName);
157157

158158
/*

Generals/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ BOOL PickUnitDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
265265
m_objectTreeView.GetItem(&item);
266266
if (item.lParam >= 0) {
267267
m_currentObjectIndex = item.lParam;
268-
static_assert(ARRAY_SIZE(m_currentObjectName) >= NAME_MAX_LEN, "Incorrect array size");
268+
static_assert(ARRAY_SIZE(m_currentObjectName) >= ARRAY_SIZE(buffer), "Incorrect array size");
269269
strcpy(m_currentObjectName, buffer);
270270
} else if (m_objectTreeView.ItemHasChildren(item.hItem)) {
271271
strcpy(m_currentObjectName, "");

Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,10 @@ BOOL RoadOptions::OnInitDialog()
242242
// load roads from test assets
243243
#ifdef LOAD_TEST_ASSETS
244244
{
245-
char dirBuf[_MAX_PATH];
246-
char findBuf[_MAX_PATH];
247245
char fileBuf[_MAX_PATH];
248246

249-
strcpy(dirBuf, ROAD_DIRECTORY);
250-
int len = strlen(dirBuf);
251-
252-
strlcpy(findBuf, dirBuf, ARRAY_SIZE(dirBuf));
253-
254247
FilenameList filenameList;
255-
TheFileSystem->getFileListInDirectory(AsciiString(findBuf), AsciiString("*.tga"), filenameList, FALSE);
248+
TheFileSystem->getFileListInDirectory(ROAD_DIRECTORY, "*.tga", filenameList, FALSE);
256249

257250
if (filenameList.size() > 0) {
258251
FilenameList::iterator it = filenameList.begin();
@@ -263,7 +256,7 @@ BOOL RoadOptions::OnInitDialog()
263256
++it;
264257
continue;
265258
}
266-
len = filename.getLength();
259+
int len = filename.getLength();
267260
if (len<5) {
268261
++it;
269262
continue;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ Bool W3DBridge::load(BodyDamageType curDamageState)
234234
char section[_MAX_PATH];
235235
char right[_MAX_PATH];
236236

237-
static_assert(ARRAY_SIZE(left) >= ARRAY_SIZE(section), "Incorrect array size");
237+
static_assert(ARRAY_SIZE(left) >= ARRAY_SIZE(modelName), "Incorrect array size");
238238
static_assert(ARRAY_SIZE(section) >= ARRAY_SIZE(modelName), "Incorrect array size");
239239
static_assert(ARRAY_SIZE(right) >= ARRAY_SIZE(modelName), "Incorrect array size");
240240
strcpy(left, modelName);

GeneralsMD/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ BOOL PickUnitDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
265265
m_objectTreeView.GetItem(&item);
266266
if (item.lParam >= 0) {
267267
m_currentObjectIndex = item.lParam;
268-
static_assert(ARRAY_SIZE(m_currentObjectName) >= NAME_MAX_LEN, "Incorrect array size");
268+
static_assert(ARRAY_SIZE(m_currentObjectName) >= ARRAY_SIZE(buffer), "Incorrect array size");
269269
strcpy(m_currentObjectName, buffer);
270270
} else if (m_objectTreeView.ItemHasChildren(item.hItem)) {
271271
strcpy(m_currentObjectName, "");

GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,10 @@ BOOL RoadOptions::OnInitDialog()
242242
// load roads from test assets
243243
#ifdef LOAD_TEST_ASSETS
244244
{
245-
char dirBuf[_MAX_PATH];
246-
char findBuf[_MAX_PATH];
247245
char fileBuf[_MAX_PATH];
248246

249-
strcpy(dirBuf, ROAD_DIRECTORY);
250-
int len = strlen(dirBuf);
251-
252-
strlcpy(findBuf, dirBuf, ARRAY_SIZE(dirBuf));
253-
254247
FilenameList filenameList;
255-
TheFileSystem->getFileListInDirectory(AsciiString(findBuf), AsciiString("*.tga"), filenameList, FALSE);
248+
TheFileSystem->getFileListInDirectory(ROAD_DIRECTORY, "*.tga", filenameList, FALSE);
256249

257250
if (filenameList.size() > 0) {
258251
FilenameList::iterator it = filenameList.begin();
@@ -263,7 +256,7 @@ BOOL RoadOptions::OnInitDialog()
263256
++it;
264257
continue;
265258
}
266-
len = filename.getLength();
259+
int len = filename.getLength();
267260
if (len<5) {
268261
++it;
269262
continue;

0 commit comments

Comments
 (0)