Skip to content

Commit

Permalink
Merge pull request xbmc#20313 from Paxxi/no_permissive
Browse files Browse the repository at this point in the history
[Windows] Enable /permissive- compiler option
  • Loading branch information
Paxxi authored Oct 16, 2021
2 parents d7ddfea + fd3a280 commit 2b1626d
Show file tree
Hide file tree
Showing 29 changed files with 595 additions and 524 deletions.
2 changes: 1 addition & 1 deletion cmake/scripts/windows/ArchSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ list(APPEND SYSTEM_DEFINES -DHAS_WIN32_NETWORK -DHAS_FILESYSTEM_SMB)

# Make sure /FS is set for Visual Studio in order to prevent simultaneous access to pdb files.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMAKE_CXX_FLAGS "/MP /FS ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "/permissive- /MP /FS ${CMAKE_CXX_FLAGS}")
endif()

# Google Test needs to use shared version of runtime libraries
Expand Down
2 changes: 1 addition & 1 deletion cmake/scripts/windowsstore/ArchSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ set(SYSTEM_DEFINES -DWIN32_LEAN_AND_MEAN -DNOMINMAX -DHAS_DX -D__STDC_CONSTANT_M
list(APPEND SYSTEM_DEFINES -DHAS_WIN10_NETWORK)

# The /MP option enables /FS by default.
set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS} /EHsc /await")
set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS} /EHsc /await /permissive-")
set(CMAKE_CXX_STANDARD 17)
# Google Test needs to use shared version of runtime libraries
set(gtest_force_shared_crt ON CACHE STRING "" FORCE)
Expand Down
9 changes: 5 additions & 4 deletions lib/libUPnP/Neptune/Source/System/Bsd/NptBsdSockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,10 @@ static int
socketpair(int, int, int, SOCKET sockets[2]) // we ignore the first two params: we only use this for a strictly limited case
{
int result = 0;
socklen_t name_length = 0;
int reuse = 1;

// initialize with default values
// initialize with default values
sockets[0] = INVALID_SOCKET;
sockets[1] = INVALID_SOCKET;

Expand All @@ -578,15 +580,14 @@ socketpair(int, int, int, SOCKET sockets[2]) // we ignore the first two params:
memset(&inet_address, 0, sizeof(inet_address));
inet_address.sin_family = AF_INET;
inet_address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
int reuse = 1;
setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse));
result = bind(listener, (const sockaddr*)&inet_address, sizeof(inet_address));
if (result != 0) goto fail;
listen(listener, 1);

// read the port that was assigned to the listener socket
socklen_t name_length = sizeof(inet_address);
result = getsockname(listener, (struct sockaddr*)&inet_address, &name_length);
name_length = sizeof(inet_address);
result = getsockname(listener, (struct sockaddr*)&inet_address, &name_length);
if (result != 0) goto fail;

// create the first socket
Expand Down
19 changes: 10 additions & 9 deletions lib/libUPnP/Platinum/Source/Core/PltCtrlPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,9 @@ PLT_CtrlPoint::ProcessEventNotification(PLT_EventSubscriberReference subscriber,
var = service->FindStateVariable(property->GetTag());
if (var == NULL) continue;

if (NPT_FAILED(var->SetValue(property->GetText()?*property->GetText():""))) {
NPT_CHECK_LABEL_WARNING(NPT_FAILURE, failure);
if (NPT_FAILED(var->SetValue(property->GetText() ? property->GetText()->GetChars() : "")))
{
NPT_CHECK_LABEL_WARNING(NPT_FAILURE, failure);
}

vars.Add(var);
Expand Down Expand Up @@ -1662,12 +1663,11 @@ PLT_CtrlPoint::ProcessSubscribeResponse(NPT_Result res,
goto remove_sub;

failure:
NPT_LOG_SEVERE_4("%subscription failed of sub \"%s\" for service \"%s\" of device \"%s\"",
(const char*)subscription?"S":"Uns",
(const char*)(sid?*sid:"Unknown"),
(const char*)service->GetServiceID(),
(const char*)service->GetDevice()->GetFriendlyName());
res = NPT_FAILED(res)?res:NPT_FAILURE;
NPT_LOG_SEVERE_4(
"%subscription failed of sub \"%s\" for service \"%s\" of device \"%s\"",
(const char*)subscription ? "S" : "Uns", (const char*)(sid ? sid->GetChars() : "Unknown"),
(const char*)service->GetServiceID(), (const char*)service->GetDevice()->GetFriendlyName());
res = NPT_FAILED(res) ? res : NPT_FAILURE;

remove_sub:
// in case it was a renewal look for the subscriber with that service and remove it from the list
Expand Down Expand Up @@ -1814,7 +1814,8 @@ PLT_CtrlPoint::ProcessActionResponse(NPT_Result res,
NPT_XmlElementNode* child = (*args)->AsElementNode();
if (!child) continue;

action->SetArgumentValue(child->GetTag(), child->GetText()?*child->GetText():"");
action->SetArgumentValue(child->GetTag(),
child->GetText() ? child->GetText()->GetChars() : "");
if (NPT_FAILED(res)) goto failure;
}

Expand Down
22 changes: 11 additions & 11 deletions lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ PLT_DeviceHost::Announce(PLT_DeviceData* device,
break;
}
PLT_UPnPMessageHelper::SetNTS(req, nts);

NPT_LOG_FINER_3("Sending SSDP NOTIFY (%s) Request to %s (%s)",
nts.GetChars(),

NPT_LOG_FINER_3("Sending SSDP NOTIFY (%s) Request to %s (%s)", nts.GetChars(),
(const char*)req.GetUrl().ToString(),
(const char*)(PLT_UPnPMessageHelper::GetLocation(req)?*PLT_UPnPMessageHelper::GetLocation(req):""));
(const char*)(PLT_UPnPMessageHelper::GetLocation(req)
? PLT_UPnPMessageHelper::GetLocation(req)->GetChars()
: ""));

// upnp:rootdevice
if (device->m_ParentUUID.IsEmpty()) {
Expand Down Expand Up @@ -585,14 +586,13 @@ PLT_DeviceHost::ProcessHttpPostRequest(NPT_HttpRequest& request,
name = "ObjectID";
}

res = action->SetArgumentValue(
name,
child->GetText()?*child->GetText():"");
res = action->SetArgumentValue(name, child->GetText() ? child->GetText()->GetChars() : "");

// test if value was correct
if (res == NPT_ERROR_INVALID_PARAMETERS) {
action->SetError(701, "Invalid Name");
goto error;
// test if value was correct
if (res == NPT_ERROR_INVALID_PARAMETERS)
{
action->SetError(701, "Invalid Name");
goto error;
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/libUPnP/Platinum/Source/Core/PltUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ class PLT_XmlHelper

const NPT_String* text = child->GetText();
// DLNA 7.3.17
value = text?text->SubString(0, max_size):"";
if (text)
text->SubString(0, max_size);
return NPT_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ PLT_MediaServer::ParseTagList(const NPT_String& updates, NPT_Map<NPT_String,NPT_
NPT_XmlElementNode* child = (*children)->AsElementNode();
if (!child) continue;
const NPT_String *txt = child->GetText();
tags[child->GetTag()] = txt ? *txt : "";
tags[child->GetTag()] = txt ? txt->GetChars() : "";
}

return NPT_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ PLT_SyncMediaBrowser::OnMSStateVariablesChanged(PLT_Service* se
if (value.GetLength()) {
index = value.Find(',');
update_id = (index<0)?value:value.Left(index);
value = (index<0)?"":value.SubString(index+1);
value = (index < 0) ? "" : value.SubString(index + 1).GetChars();

// clear cache for that device
if (m_UseCache) m_Cache.Clear(device->GetUUID(), item_id);
Expand Down
8 changes: 5 additions & 3 deletions lib/win32/Effects11/Binary/SOParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class CSOParser
HRESULT Parse( _In_ uint32_t Stream, _In_z_ LPCSTR pString )
{
HRESULT hr = S_OK;
LPSTR pSemantic = nullptr;

m_pError[0] = 0;

Expand All @@ -122,7 +123,7 @@ class CSOParser
VN( m_SemanticString[Stream] = new char[len + 1] );
strcpy_s( m_SemanticString[Stream], len + 1, pString );

LPSTR pSemantic = m_SemanticString[Stream];
pSemantic = m_SemanticString[Stream];

while( true )
{
Expand Down Expand Up @@ -245,7 +246,8 @@ class CSOParser
_Analysis_assume_( ppSemantic && *ppSemantic );

HRESULT hr = S_OK;
LPSTR pColon = strchr( *ppSemantic, ':' );
LPSTR pColon = strchr( *ppSemantic, ':' );
int outputSlot = 0;

if( pColon == nullptr )
return S_OK;
Expand All @@ -258,7 +260,7 @@ class CSOParser
}

*pColon = '\0';
int outputSlot = atoi( *ppSemantic );
outputSlot = atoi(*ppSemantic);
if( outputSlot < 0 || outputSlot > 255 )
{
strcpy_s( m_pError, MAX_ERROR_SIZE,
Expand Down
3 changes: 3 additions & 0 deletions lib/win32/Effects11/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include "EffectBinaryFormat.h"
#include "IUnknownImp.h"
#include "d3dxGlobal.h"

#include <cassert>

#ifdef _DEBUG
extern void __cdecl D3DXDebugPrintf(UINT lvl, _In_z_ _Printf_format_string_ LPCSTR szFormat, ...);
Expand Down
19 changes: 13 additions & 6 deletions lib/win32/Effects11/EffectAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ HRESULT WINAPI D3DX11CreateEffectFromFile( LPCWSTR pFileName, UINT FXFlags, ID3D

std::unique_ptr<uint8_t[]> fileData;
uint32_t size;
int result = 0;
CHAR* pstrName = nullptr;
HRESULT hr = LoadBinaryFromFile( pFileName, fileData, size );
if ( FAILED(hr) )
return hr;
Expand All @@ -140,15 +142,16 @@ HRESULT WINAPI D3DX11CreateEffectFromFile( LPCWSTR pFileName, UINT FXFlags, ID3D

// Create debug object name from input filename
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte( CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH, nullptr, FALSE );
result = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH,
nullptr, FALSE);
if ( !result )
{
DPF(0, "Failed to load effect file due to WC to MB conversion failure: %ls", pFileName);
hr = E_FAIL;
goto lExit;
}

const CHAR* pstrName = strrchr( strFileA, '\\' );
pstrName = strrchr(strFileA, '\\');
if (!pstrName)
{
pstrName = strFileA;
Expand Down Expand Up @@ -226,6 +229,8 @@ HRESULT D3DX11CompileEffectFromFile( LPCWSTR pFileName,
}

ID3DBlob *blob = nullptr;
CHAR* pstrName = nullptr;
int result = 0;

#if (D3D_COMPILER_VERSION >= 46) && ( !defined(WINAPI_FAMILY) || ( (WINAPI_FAMILY != WINAPI_FAMILY_APP) && (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) ) )

Expand All @@ -249,14 +254,15 @@ HRESULT D3DX11CompileEffectFromFile( LPCWSTR pFileName,

// Create debug object name from input filename
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte( CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH, nullptr, FALSE );
result = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH,
nullptr, FALSE);
if ( !result )
{
DPF(0, "Failed to load effect file due to WC to MB conversion failure: %ls", pFileName);
return E_FAIL;
}

const CHAR* pstrName = strrchr( strFileA, '\\' );
pstrName = strrchr(strFileA, '\\');
if (!pstrName)
{
pstrName = strFileA;
Expand Down Expand Up @@ -290,15 +296,16 @@ HRESULT D3DX11CompileEffectFromFile( LPCWSTR pFileName,
#if (D3D_COMPILER_VERSION >= 46) && ( !defined(WINAPI_FAMILY) || ( (WINAPI_FAMILY != WINAPI_FAMILY_APP) && (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) ) )
// Create debug object name from input filename
CHAR strFileA[MAX_PATH];
int result = WideCharToMultiByte( CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH, nullptr, FALSE );
result = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, pFileName, -1, strFileA, MAX_PATH,
nullptr, FALSE);
if ( !result )
{
DPF(0, "Failed to load effect file due to WC to MB conversion failure: %ls", pFileName);
hr = E_FAIL;
goto lExit;
}

const CHAR* pstrName = strrchr( strFileA, '\\' );
pstrName = strrchr(strFileA, '\\');
if (!pstrName)
{
pstrName = strFileA;
Expand Down
15 changes: 9 additions & 6 deletions lib/win32/Effects11/EffectLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ HRESULT CEffectLoader::LoadEffect(CEffect *pEffect, const void *pEffectBuffer, u
HRESULT hr = S_OK;
uint32_t i, varSize, cMemberDataBlocks;
CCheckedDword chkVariables = 0;
uint32_t oStructured = 0;

// Used for cloning
m_pvOldMemberInterfaces = nullptr;
Expand Down Expand Up @@ -875,7 +876,7 @@ HRESULT CEffectLoader::LoadEffect(CEffect *pEffect, const void *pEffectBuffer, u
VN( m_pEffect->m_pRenderTargetViews = PRIVATENEW SRenderTargetView[m_pHeader->cRenderTargetViews] );
VN( m_pEffect->m_pDepthStencilViews = PRIVATENEW SDepthStencilView[m_pHeader->cDepthStencilViews] );

uint32_t oStructured = m_pHeader->cbUnstructured + sizeof(SBinaryHeader5);
oStructured = m_pHeader->cbUnstructured + sizeof(SBinaryHeader5);
VHD( m_msStructured.Seek(oStructured), "Invalid pEffectBuffer: Missing structured data block." );
VH( m_msUnstructured.SetData(m_pData + sizeof(SBinaryHeader5), oStructured - sizeof(SBinaryHeader5)) );

Expand Down Expand Up @@ -994,7 +995,8 @@ HRESULT CEffectLoader::LoadTypeAndAddToPool(SType **ppType, uint32_t dwOffset)
uint8_t *pHashBuffer;
uint32_t hash;
SVariable *pTempMembers = nullptr;

uint32_t cElements = 0;

m_HashBuffer.Empty();

VHD( m_msUnstructured.ReadAtOffset(dwOffset, sizeof(SBinaryType), (void**) &psType), "Invalid pEffectBuffer: cannot read type." );
Expand All @@ -1006,7 +1008,7 @@ HRESULT CEffectLoader::LoadTypeAndAddToPool(SType **ppType, uint32_t dwOffset)
temporaryType.PackedSize = psType->PackedSize;

// sanity check elements, size, stride, etc.
uint32_t cElements = std::max<uint32_t>(1, temporaryType.Elements);
cElements = std::max<uint32_t>(1, temporaryType.Elements);
VBD( cElements * temporaryType.Stride == AlignToPowerOf2(temporaryType.TotalSize, SType::c_RegisterSize), "Invalid pEffectBuffer: invalid type size." );
VBD( temporaryType.Stride % SType::c_RegisterSize == 0, "Invalid pEffectBuffer: invalid type stride." );
VBD( temporaryType.PackedSize <= temporaryType.TotalSize && temporaryType.PackedSize % cElements == 0, "Invalid pEffectBuffer: invalid type packed size." );
Expand Down Expand Up @@ -2554,7 +2556,9 @@ HRESULT CEffectLoader::GrabShaderData(SShaderBlock *pShaderBlock)

SRange *pRange = nullptr;
CEffectVector<SConstantBuffer*> vTBuffers;

uint32_t NumInterfaces = 0;
uint32_t CurInterfaceParameter = 0;

//////////////////////////////////////////////////////////////////////////
// Step 1: iterate through the resource binding structures and build
// an "optimized" list of all of the dependencies
Expand Down Expand Up @@ -2793,8 +2797,7 @@ HRESULT CEffectLoader::GrabShaderData(SShaderBlock *pShaderBlock)
// Step 2: iterate through the interfaces and build
// an "optimized" list of all of the dependencies

uint32_t NumInterfaces = pShaderBlock->pReflectionData->pReflection->GetNumInterfaceSlots();
uint32_t CurInterfaceParameter = 0;
NumInterfaces = pShaderBlock->pReflectionData->pReflection->GetNumInterfaceSlots();
if( NumInterfaces > 0 )
{
assert( ShaderDesc.ConstantBuffers > 0 );
Expand Down
Loading

0 comments on commit 2b1626d

Please sign in to comment.