mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Slightly safer and neater fix for strict aliasing bug 351231 r+sr=dbaron
This commit is contained in:
parent
84b4bbf9fe
commit
417d5864d4
@ -92,64 +92,64 @@ nsCOMPtr_base::assign_with_AddRef( nsISupports* rawPtr )
|
||||
void
|
||||
nsCOMPtr_base::assign_from_qi( const nsQueryInterface qi, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports *mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( qi(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( qi(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_qi_with_error( const nsQueryInterfaceWithError& qi, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( qi(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( qi(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_gs_cid( const nsGetServiceByCID gs, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_gs_cid_with_error( const nsGetServiceByCIDWithError& gs, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_gs_contractid( const nsGetServiceByContractID gs, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_gs_contractid_with_error( const nsGetServiceByContractIDWithError& gs, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void
|
||||
nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid )
|
||||
{
|
||||
union { nsISupports* mSupports; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( helper(iid, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mSupports = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mSupports);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( helper(iid, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(nsISupports*, newRawPtr));
|
||||
}
|
||||
|
||||
void**
|
||||
|
@ -1240,70 +1240,70 @@ template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_qi( const nsQueryInterface qi, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( qi(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( qi(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_qi_with_error( const nsQueryInterfaceWithError& qi, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( qi(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( qi(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_gs_cid( const nsGetServiceByCID gs, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_gs_cid_with_error( const nsGetServiceByCIDWithError& gs, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_gs_contractid( const nsGetServiceByContractID gs, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_gs_contractid_with_error( const nsGetServiceByContractIDWithError& gs, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void
|
||||
nsCOMPtr<T>::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& aIID )
|
||||
{
|
||||
union { T* mT; void *mVoid; } newRawPtr;
|
||||
if ( NS_FAILED( helper(aIID, &newRawPtr.mVoid) ) )
|
||||
newRawPtr.mT = 0;
|
||||
assign_assuming_AddRef(newRawPtr.mT);
|
||||
void* newRawPtr;
|
||||
if ( NS_FAILED( helper(aIID, &newRawPtr) ) )
|
||||
newRawPtr = 0;
|
||||
assign_assuming_AddRef(NS_STATIC_CAST(T*, newRawPtr));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
Loading…
Reference in New Issue
Block a user