strict-aliasing fix for silc-toolkit-1.1-beta2

Stanislav Brabec <[email protected]>
Newsgroups gmane.network.silc.devel
Organization SuSE CR, s. r. o.
Message-ID <[email protected]>
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: [email protected]
Lihovarská 1060/12                            tel: +420 284 028 966
190 00 Praha 9                                fax: +420 284 028 951
Czech Republic                                http://www.suse.cz/

_______________________________________________________________________
Info:    https://lists.silcnet.org/mailman/listinfo/silc-announce
Archive: https://lists.silcnet.org/pipermail/silc-announce
FAQ:     http://silcnet.org/support/faq/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.