Discussion:
[libdvdcss-devel] [PATCH] Win32: kill warnings about strict-aliasing rules in ioctl.c
Jean-Baptiste Kempf
2013-03-12 12:28:31 UTC
Permalink
warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
---
src/ioctl.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/ioctl.c b/src/ioctl.c
index 61a924e..7e3568e 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -927,7 +927,8 @@ int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
key->KeyType = DvdAsf;
key->KeyFlags = 0;

- ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
+ PDVD_ASF keyData = (PDVD_ASF)key->KeyData;
+ keyData->SuccessFlag = *pi_asf;

i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
@@ -937,7 +938,8 @@ int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
return i_ret;
}

- *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
+ keyData = (PDVD_ASF)key->KeyData;
+ *pi_asf = keyData->SuccessFlag;
}
else
{
@@ -1580,9 +1582,10 @@ int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
return i_ret;
}

- *p_type = ((PDVD_RPC_KEY)key->KeyData)->TypeCode;
- *p_mask = ((PDVD_RPC_KEY)key->KeyData)->RegionMask;
- *p_scheme = ((PDVD_RPC_KEY)key->KeyData)->RpcScheme;
+ PDVD_RPC_KEY keyData = (PDVD_RPC_KEY)key->KeyData;
+ *p_type = keyData->TypeCode;
+ *p_mask = keyData->RegionMask;
+ *p_scheme = keyData->RpcScheme;
}
else
{
--
1.8.1.5
Jean-Baptiste Kempf
2013-03-12 12:41:39 UTC
Permalink
libdvdcss | branch: master | Jean-Baptiste Kempf <***@videolan.org> | Tue Mar 12 13:27:36 2013 +0100| [dc2155d210c80aee6a197af0dbb50a7f00adf3b3] | committer: Jean-Baptiste Kempf

Win32: kill warnings about strict-aliasing rules in ioctl.c

warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=dc2155d210c80aee6a197af0dbb50a7f00adf3b3
---

src/ioctl.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/ioctl.c b/src/ioctl.c
index 61a924e..7e3568e 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -927,7 +927,8 @@ int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
key->KeyType = DvdAsf;
key->KeyFlags = 0;

- ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
+ PDVD_ASF keyData = (PDVD_ASF)key->KeyData;
+ keyData->SuccessFlag = *pi_asf;

i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
@@ -937,7 +938,8 @@ int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
return i_ret;
}

- *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
+ keyData = (PDVD_ASF)key->KeyData;
+ *pi_asf = keyData->SuccessFlag;
}
else
{
@@ -1580,9 +1582,10 @@ int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
return i_ret;
}

- *p_type = ((PDVD_RPC_KEY)key->KeyData)->TypeCode;
- *p_mask = ((PDVD_RPC_KEY)key->KeyData)->RegionMask;
- *p_scheme = ((PDVD_RPC_KEY)key->KeyData)->RpcScheme;
+ PDVD_RPC_KEY keyData = (PDVD_RPC_KEY)key->KeyData;
+ *p_type = keyData->TypeCode;
+ *p_mask = keyData->RegionMask;
+ *p_scheme = keyData->RpcScheme;
}
else
{
Reimar Döffinger
2013-03-12 13:21:44 UTC
Permalink
Post by Jean-Baptiste Kempf
Tue Mar 12 13:27:36 2013 +0100|
[dc2155d210c80aee6a197af0dbb50a7f00adf3b3] | committer: Jean-Baptiste
Kempf
Win32: kill warnings about strict-aliasing rules in ioctl.c
warning: dereferencing type-punned pointer will break strict-aliasing
rules [-Wstrict-aliasing]
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=dc2155d210c80aee6a197af0dbb50a7f00adf3b3
---
src/ioctl.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/ioctl.c b/src/ioctl.c
index 61a924e..7e3568e 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -927,7 +927,8 @@ int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf )
key->KeyType = DvdAsf;
key->KeyFlags = 0;
- ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
+ PDVD_ASF keyData = (PDVD_ASF)key->KeyData;
+ keyData->SuccessFlag = *pi_asf;
Isn't this still an aliasing violation, just that the compiler is too stupid to see it now?
If so I am not so sure hiding the warning is a great solution.
Jean-Baptiste Kempf
2013-03-12 16:06:56 UTC
Permalink
Post by Reimar Döffinger
Isn't this still an aliasing violation, just that the compiler is too stupid to see it now?
I don't think it still is.

Best regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Loading...