Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Servers/IIS/AspNetCoreModuleV2/IISLib/acache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ ALLOC_CACHE_HANDLER::IsPageheapEnabled(

if ( fLockedHeap )
{
fLockedHeap = FALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an analyzer warning about setting a local without ever reading it again? Not sure how I feel about that in the general case 😆
For this file it's fine since we don't touch it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I hit that while trying out clang-tidy locally and fixed it in this super obvious case.

DBG_REQUIRE( ::HeapUnlock( hHeap ) );
}

Expand Down
173 changes: 0 additions & 173 deletions src/Servers/IIS/AspNetCoreModuleV2/IISLib/multisz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
#include "precomp.h"
#include "multisz.h"

//
// Private Definitions
//

#define MAXULONG 4294967295
#define ISWHITE( ch ) ((ch) == L' ' || (ch) == L'\t' || (ch) == L'\r')

//
// When appending data, this is the extra amount we request to avoid
Expand Down Expand Up @@ -44,74 +39,6 @@ MULTISZ::CalcLength( const WCHAR * str,
} // MULTISZ::CalcLength


BOOL
MULTISZ::FindString( const WCHAR * str ) const
{
//
// Sanity check.
//

DBG_ASSERT( QueryStr() != nullptr );
DBG_ASSERT( str != nullptr );
DBG_ASSERT( *str != '\0' );

//
// Scan it.
//

WCHAR* multisz = QueryStr();

while( *multisz != '\0' ) {

if( !::wcscmp( multisz, str ) ) {

return TRUE;

}

multisz += ::wcslen( multisz ) + 1;

}

return FALSE;

} // MULTISZ::FindString


BOOL
MULTISZ::FindStringNoCase( const WCHAR * str ) const
{
//
// Sanity check.
//

DBG_ASSERT( QueryStr() != nullptr );
DBG_ASSERT( str != nullptr );
DBG_ASSERT( *str != '\0' );

//
// Scan it.
//

WCHAR* multisz = QueryStr();

while( *multisz != '\0' ) {

if( !_wcsicmp( multisz, str ) ) {

return TRUE;

}

multisz += wcslen( multisz ) + 1;

}

return FALSE;

} // MULTISZ::FindStringNoCase


VOID
MULTISZ::AuxInit( const WCHAR * pInit )
{
Expand Down Expand Up @@ -361,104 +288,4 @@ MULTISZ::Equals(
return TRUE;
}

HRESULT
SplitCommaDelimitedString(
PCWSTR pszList,
BOOL fTrimEntries,
BOOL fRemoveEmptyEntries,
MULTISZ * pmszList
)
/*++

Routine Description:

Split comma delimited string into a multisz. Additional leading empty
entries after the first are discarded.

Arguments:

pszList - List to split up
fTrimEntries - Whether each entry should be trimmed before added to multisz
fRemoveEmptyEntries - Whether empty entires should be discarded
pmszList - Filled with MULTISZ list

Return Value:

HRESULT

--*/
{
HRESULT hr = S_OK;

if ( pszList == nullptr ||
pmszList == nullptr )
{
DBG_ASSERT( FALSE );
hr = HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
goto Finished;
}

pmszList->Reset();

/*
pszCurrent: start of the current entry which may be the comma that
precedes the next entry if the entry is empty

pszNext: the comma that precedes the next entry. If
pszCurrent == pszNext, then the entry is empty

pszEnd: just past the end of the current entry
*/

for ( PCWSTR pszCurrent = pszList,
pszNext = wcschr( pszCurrent, L',' )
;
;
pszCurrent = pszNext + 1,
pszNext = wcschr( pszCurrent, L',' ) )
{
PCWSTR pszEnd = nullptr;

if ( pszNext != nullptr )
{
pszEnd = pszNext;
}
else
{
pszEnd = pszCurrent + wcslen( pszCurrent );
}

if ( fTrimEntries )
{
while ( pszCurrent < pszEnd && ISWHITE( pszCurrent[ 0 ] ) )
{
pszCurrent++;
}

while ( pszEnd > pszCurrent && ISWHITE( pszEnd[ -1 ] ) )
{
pszEnd--;
}
}

if ( pszCurrent != pszEnd || !fRemoveEmptyEntries )
{
if ( !pmszList->Append( pszCurrent, (DWORD) ( pszEnd - pszCurrent ) ) )
{
hr = HRESULT_FROM_WIN32( GetLastError() );
goto Finished;
}
}

if ( pszNext == nullptr )
{
break;
}
}

Finished:

return hr;
}

#pragma warning(default:4267)
91 changes: 5 additions & 86 deletions src/Servers/IIS/AspNetCoreModuleV2/IISLib/multisz.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#include "ntassert.h"
#include <CodeAnalysis/Warnings.h>

#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )

/*++
class MULTISZ:

Expand All @@ -20,9 +17,6 @@
This object is derived from BUFFER class.
It maintains following state:

m_fValid - whether this object is valid -
used only by MULTISZ() init functions
* NYI: I need to kill this someday *
m_cchLen - string length cached when we update the string.
m_cStrings - number of strings.

Expand Down Expand Up @@ -65,26 +59,13 @@ class MULTISZ : public BUFFER
m_cStrings(0)
{ AuxInit( str.QueryStr()); }

// BOOL IsValid(VOID) const { return ( BUFFER::IsValid()) ; }
//
// Checks and returns TRUE if this string has no valid data else FALSE
//
BOOL IsEmpty() const { return ( *QueryStr() == L'\0'); }

BOOL Append( const WCHAR * pchInit ) {
return ((pchInit != NULL) ? (AuxAppend( pchInit,
return ((pchInit != nullptr) ? (AuxAppend( pchInit,
static_cast<DWORD>(wcslen(pchInit)) * sizeof(WCHAR)
)) :
TRUE);
}


BOOL Append( const WCHAR * pchInit, DWORD cchLen ) {
return ((pchInit != NULL) ? (AuxAppend( pchInit,
cchLen * sizeof(WCHAR))) :
TRUE);
}

BOOL Append( STRU & str )
{ return AuxAppend( str.QueryStr(),
(str.QueryCCH()) * sizeof(WCHAR)); }
Expand All @@ -100,7 +81,7 @@ class MULTISZ : public BUFFER

BOOL Copy( const WCHAR * pchInit, IN DWORD cbLen ) {
if ( QueryPtr() ) { Reset(); }
return ( (pchInit != NULL) ?
return ( (pchInit != nullptr) ?
AuxAppend( pchInit, cbLen, FALSE ):
TRUE);
}
Expand All @@ -120,12 +101,6 @@ class MULTISZ : public BUFFER
//
UINT QueryCCH() const { return (m_cchLen); }

//
// Returns # of strings in the multisz.
//

DWORD QueryStringCount() const { return m_cStrings; }

//
// Makes a copy of the stored string in given buffer
//
Expand All @@ -134,28 +109,8 @@ class MULTISZ : public BUFFER
//
// Return the string buffer
//
WCHAR * QueryStrA() const { return ( QueryStr()); }
WCHAR * QueryStr() const { return ((WCHAR *) QueryPtr()); }

//
// Makes a clone of the current string in the string pointer passed in.
//
BOOL
Clone( OUT MULTISZ * pstrClone) const
{
return ((pstrClone == NULL) ?
(SetLastError(ERROR_INVALID_PARAMETER), FALSE) :
(pstrClone->Copy( *this))
);
} // MULTISZ::Clone()

//
// Recalculates the length of *this because we've modified the buffers
// directly
//

VOID RecalcLen()
{ m_cchLen = CalcLength( QueryStr(), &m_cStrings ); }

//
// Calculate total character length of a MULTI_SZ, including the
Expand All @@ -165,34 +120,16 @@ class MULTISZ : public BUFFER
static DWORD CalcLength( const WCHAR * str,
LPDWORD pcStrings = NULL );

//
// Determine if the MULTISZ contains a specific string.
//

BOOL FindString( const WCHAR * str ) const;

BOOL FindString( STRU & str )
{ return FindString( str.QueryStr() ); }

//
// Determine if the MULTISZ contains a specific string - case-insensitive
//

BOOL FindStringNoCase( const WCHAR * str ) const;

BOOL FindStringNoCase( STRU & str )
{ return FindStringNoCase( str.QueryStr() ); }

//
// Used for scanning a multisz.
//

const WCHAR * First() const
{ return *QueryStr() == L'\0' ? NULL : QueryStr(); }
{ return *QueryStr() == L'\0' ? nullptr : QueryStr(); }

const WCHAR * Next( const WCHAR * Current ) const
{ Current += wcslen( Current ) + 1;
return *Current == L'\0' ? NULL : Current; }
return *Current == L'\0' ? nullptr : Current; }

BOOL
Equals(
Expand All @@ -209,22 +146,4 @@ class MULTISZ : public BUFFER

};

//
// Quick macro for declaring a MULTISZ that will use stack memory of <size>
// bytes. If the buffer overflows then a heap buffer will be allocated
//

#define STACK_MULTISZ( name, size ) WCHAR __ach##name[size]; \
MULTISZ name( __ach##name, sizeof( __ach##name ))

HRESULT
SplitCommaDelimitedString(
PCWSTR pszList,
BOOL fTrimEntries,
BOOL fRemoveEmptyEntries,
MULTISZ * pmszList
);

#pragma warning( pop )

#endif // !_MULTISZ_HXX_
#endif // !_MULTISZ_H_
Loading
Loading