From a8b323c1eba2cc7c60681b078bda3765c2361b3a Mon Sep 17 00:00:00 2001 From: tomas-nestorovic Date: Mon, 14 Nov 2022 10:23:57 +0100 Subject: [PATCH] [#13] Minor source code improvements (Part 205: Cumulative minor improvements) --- Main/Main.vcxproj | 2 +- Main/src/Greaseweazle.h | 2 +- Main/src/KryoFluxBase.cpp | 6 +++--- Main/src/SpectrumDos.cpp | 2 +- Main/src/Utils.cpp | 2 +- Main/src/Utils.h | 2 +- PropGrid/PropGrid.vcxproj | 1 - PropGrid/src/Editor_Enum.cpp | 4 ++-- PropGrid/src/Editor_Hyperlink.cpp | 2 +- PropGrid/src/Editor_Integer.cpp | 2 +- PropGrid/src/api.cpp | 6 +++--- Tdi/Tdi.vcxproj | 1 - Tdi/src/Tdi.cpp | 4 ++-- 13 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Main/Main.vcxproj b/Main/Main.vcxproj index 7aff06fd..3e19c4d0 100644 --- a/Main/Main.vcxproj +++ b/Main/Main.vcxproj @@ -173,7 +173,7 @@ false false OldStyle - /QIfist /Zc:threadSafeInit- %(AdditionalOptions) + /QIfist %(AdditionalOptions) true StdCall false diff --git a/Main/src/Greaseweazle.h b/Main/src/Greaseweazle.h index 5f309956..79acbc65 100644 --- a/Main/src/Greaseweazle.h +++ b/Main/src/Greaseweazle.h @@ -62,7 +62,7 @@ } driver; const BYTE fddId; const Utils::CCallocPtr dataBuffer; - #pragma pack(1); + #pragma pack(1) struct{ BYTE major, minor, isMainFirmware, maxCmd; DWORD sampleFrequency; diff --git a/Main/src/KryoFluxBase.cpp b/Main/src/KryoFluxBase.cpp index 346a90ab..a95cca46 100644 --- a/Main/src/KryoFluxBase.cpp +++ b/Main/src/KryoFluxBase.cpp @@ -212,7 +212,7 @@ struct TIndexPulse sealed{ - DWORD posInStreamData; + int posInStreamData; DWORD sampleCounter; DWORD indexCounter; }; @@ -365,7 +365,7 @@ badFormat: ::SetLastError(ERROR_BAD_FORMAT); DWORD sampleCounter=0, totalSampleCounter=0; // delta and absolute sample counters PLogTime buffer=result.GetBuffer(),pLogTime=buffer; BYTE nearestIndexPulse=0; - DWORD nearestIndexPulsePos= nIndexPulses>0 ? indexPulses[0].posInStreamData : INT_MAX; + int nearestIndexPulsePos= nIndexPulses>0 ? indexPulses[0].posInStreamData : INT_MAX; for( PCBYTE pis=inStreamData,pLastInStreamData=pis+inStreamDataLength; pis item with the specified ID contains list of integer values (grammar bellow), otherwise False // - elimination of white spaces from the content TCHAR buf[16384], *pEnd=buf; diff --git a/Main/src/Utils.h b/Main/src/Utils.h index 543f1d43..941046fd 100644 --- a/Main/src/Utils.h +++ b/Main/src/Utils.h @@ -263,7 +263,7 @@ namespace Utils{ void SetDlgItemSingleCharUsingFont(WORD id,WCHAR singleChar,LPCTSTR fontFace,int fontPointSize) const; void PopulateDlgComboBoxWithSequenceOfNumbers(WORD cbId,BYTE iStartValue,LPCTSTR strStartValueDesc,BYTE iEndValue,LPCTSTR strEndValueDesc) const; void ConvertDlgButtonToSplitButton(WORD id,PCSplitButtonAction pAction,BYTE nActions) const; - bool GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,UINT nIntsMin=0,UINT nIntsMax=INT_MAX) const; + bool GetDlgItemIntList(WORD id,CIntList &rOutList,const PropGrid::Integer::TUpDownLimits &limits,int nIntsMin=0,int nIntsMax=INT_MAX) const; void SetDlgItemIntList(WORD id,const CIntList &list) const; }; diff --git a/PropGrid/PropGrid.vcxproj b/PropGrid/PropGrid.vcxproj index 0290bf2c..81ef22f8 100644 --- a/PropGrid/PropGrid.vcxproj +++ b/PropGrid/PropGrid.vcxproj @@ -172,7 +172,6 @@ false ProgramDatabase true - /QIfist %(AdditionalOptions) true false false diff --git a/PropGrid/src/Editor_Enum.cpp b/PropGrid/src/Editor_Enum.cpp index 68a862a0..3a6d8ccd 100644 --- a/PropGrid/src/Editor_Enum.cpp +++ b/PropGrid/src/Editor_Enum.cpp @@ -39,7 +39,7 @@ uValue.longValue=0; ::memcpy( &uValue, value.buffer, valueSize ); WCHAR desc[STRING_LENGTH_MAX+1]; - __drawString__( __getValueDescW__( value.param, uValue, desc, sizeof(desc)/sizeof(WCHAR) ), -1, + __drawString__( __getValueDescW__( value.param, uValue, desc, ARRAYSIZE(desc) ), -1, pdis ); } @@ -87,7 +87,7 @@ // string Value WCHAR descW[100]; ComboBox_SetItemData( hComboBox, - ::SendMessageW( hComboBox, CB_ADDSTRING, 0, (LPARAM)__getValueDescW__(value.param,uValue,descW,sizeof(descW)/sizeof(WCHAR)) ), + ::SendMessageW( hComboBox, CB_ADDSTRING, 0, (LPARAM)__getValueDescW__(value.param,uValue,descW,ARRAYSIZE(descW)) ), uValue.longValue ); } diff --git a/PropGrid/src/Editor_Hyperlink.cpp b/PropGrid/src/Editor_Hyperlink.cpp index 7059a330..fd81a0db 100644 --- a/PropGrid/src/Editor_Hyperlink.cpp +++ b/PropGrid/src/Editor_Hyperlink.cpp @@ -45,7 +45,7 @@ if (wideChar) ::lstrcpyW(buf+1,(LPCWSTR)value.buffer); else - ::MultiByteToWideChar( CP_ACP, 0, (LPCSTR)value.buffer,-1, buf+1,sizeof(buf)/sizeof(WCHAR)-1 ); + ::MultiByteToWideChar( CP_ACP, 0, (LPCSTR)value.buffer,-1, buf+1,ARRAYSIZE(buf)-1 ); return ::CreateWindowW( WC_LINK, buf, EDITOR_STYLE, diff --git a/PropGrid/src/Editor_Integer.cpp b/PropGrid/src/Editor_Integer.cpp index 58fb0188..edabec48 100644 --- a/PropGrid/src/Editor_Integer.cpp +++ b/PropGrid/src/Editor_Integer.cpp @@ -49,7 +49,7 @@ // True <=> Editor's current Value is acceptable, otherwise False const HWND hEdit=TEditor::pSingleShown->hMainCtrl; TCHAR buf[16]; - const int nChars=::GetWindowText( hEdit, buf, sizeof(buf)/sizeof(TCHAR) ); + const int nChars=::GetWindowText( hEdit, buf, ARRAYSIZE(buf) ); static_assert( PropGrid::Integer::HEXADECIMAL==1, "PropGrid::Integer::HEXADECIMAL==1" ); const int i=_tcstol( buf, nullptr, 10+6*(features&PropGrid::Integer::HEXADECIMAL) ); const bool outOfRange= features&PropGrid::Integer::HEXADECIMAL diff --git a/PropGrid/src/api.cpp b/PropGrid/src/api.cpp index 144bd51e..f44e2768 100644 --- a/PropGrid/src/api.cpp +++ b/PropGrid/src/api.cpp @@ -55,7 +55,7 @@ HANDLE WINAPI PropGrid::AddPropertyA(HWND hPropGrid,HANDLE category,LPCSTR name,PValue value,PCEditor editor,PCustomParam param){ // creates, adds into PropertyGrid, and returns a new ValueItem with given Name and Value WCHAR bufW[200]; - ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) ); + ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) ); return AddPropertyW( hPropGrid, category, bufW, value, editor, param ); } @@ -70,7 +70,7 @@ HANDLE WINAPI PropGrid::AddDisabledPropertyA(HWND hPropGrid,HANDLE category,LPCSTR name,PValue value,PCEditor editor,PCustomParam param){ // creates, adds into PropertyGrid, and returns a new ValueItem with given Name and Value WCHAR bufW[200]; - ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) ); + ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) ); return AddDisabledPropertyW( hPropGrid, category, bufW, value, editor, param ); } @@ -92,7 +92,7 @@ HANDLE WINAPI PropGrid::AddCategoryA(HWND hPropGrid,HANDLE category,LPCSTR name,bool initiallyExpanded){ // creates, adds into PropertyGrid, and returns a new CategoryItem with given Name WCHAR bufW[200]; - ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, sizeof(bufW)/sizeof(WCHAR) ); + ::MultiByteToWideChar( CP_ACP, 0, name, -1, bufW, ARRAYSIZE(bufW) ); return AddCategoryW( hPropGrid, category, bufW, initiallyExpanded ); } diff --git a/Tdi/Tdi.vcxproj b/Tdi/Tdi.vcxproj index 18073219..e90ddf72 100644 --- a/Tdi/Tdi.vcxproj +++ b/Tdi/Tdi.vcxproj @@ -149,7 +149,6 @@ false Default false - /QIfist %(AdditionalOptions) false 4482;%(DisableSpecificWarnings) diff --git a/Tdi/src/Tdi.cpp b/Tdi/src/Tdi.cpp index 731bbf46..e58da0dc 100644 --- a/Tdi/src/Tdi.cpp +++ b/Tdi/src/Tdi.cpp @@ -31,7 +31,7 @@ : tabId(_tabId) { data.mask = TCIF_PARAM | TCIF_TEXT; data.pszText=caption; - data.cchTextMax=sizeof(caption)/sizeof(TCHAR); + data.cchTextMax=ARRAYSIZE(caption); TabCtrl_GetItem(hTdi,_tabId,&data); TabCtrl_GetItemRect(hTdi,_tabId,&targetArea); } @@ -189,7 +189,7 @@ TCHAR tmpCaption[80]; tmp.mask = TCIF_PARAM | TCIF_TEXT; tmp.pszText=tmpCaption; - tmp.cchTextMax=sizeof(tmpCaption)/sizeof(TCHAR); + tmp.cchTextMax=ARRAYSIZE(tmpCaption); TabCtrl_GetItem( hTdi, iTargetTab, &tmp ); TabCtrl_SetItem( hTdi, iTargetTab, &pDraggedTabInfo->data ); TabCtrl_SetItem( hTdi, pDraggedTabInfo->tabId, &tmp );