strict-aliasing fix for silc-toolkit-1.1-beta2
Stanislav Brabec
sbrabec at suse.cz
Tue May 15 12:42:30 CEST 2007
Hallo.
Here is a trivial fix for strict-aliasing warnings of the latest gcc,
which removes unneeded type-punning of dereferenced pointers.
I: Program is likely to break with new gcc. Try -fno-strict-aliasing.
W: strict-aliasing-punning silcasn1_encode.c: 354, 365
W: strict-aliasing-punning silchttpserver.c: 197
silcasn1_encode.c: In function 'silc_asn1_encoder':
silcasn1_encode.c:354: warning: dereferencing type-punned pointer will break strict-aliasing rules
silcasn1_encode.c:365: warning: dereferencing type-punned pointer will break strict-aliasing rules
silchttpserver.c: In function 'silc_http_server_parse':
silchttpserver.c:197: warning: dereferencing type-punned pointer will break strict-aliasing rules
================================================================================
--- lib/silcasn1/silcasn1_encode.c
+++ lib/silcasn1/silcasn1_encode.c
@@ -351,7 +351,7 @@
/* Get OID words from the string */
cp = strchr(oidstr, '.');
while (cp) {
- if (sscanf(oidstr, "%lu", (unsigned long *)&oid) != 1) {
+ if (sscanf(oidstr, "%lu", &oid) != 1) {
SILC_LOG_DEBUG(("Malformed OID string"));
goto fail;
}
@@ -362,7 +362,7 @@
cp = strchr(oidstr, '.');
if (!cp) {
- if (sscanf(oidstr, "%lu", (unsigned long *)&oid) != 1) {
+ if (sscanf(oidstr, "%lu", &oid) != 1) {
SILC_LOG_DEBUG(("Malformed OID string"));
goto fail;
}
--- lib/silchttp/silchttpserver.c
+++ lib/silchttp/silchttpserver.c
@@ -194,7 +194,7 @@
/* Check we have received all data */
cl = silc_mime_get_field(conn->curheaders, "Content-Length");
- if (cl && sscanf(cl, "%lu", (unsigned long *)&cll) == 1) {
+ if (cl && sscanf(cl, "%lu", &cll) == 1) {
if (data_len < cll) {
/* More data to come */
silc_mime_free(conn->curheaders);
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec at suse.cz
Lihovarská 1060/12 tel: +420 284 028 966
190 00 Praha 9 fax: +420 284 028 951
Czech Republic http://www.suse.cz/
More information about the silc-devel
mailing list