[前][次][番号順一覧][スレッド一覧]

ruby-changes:27981

From: nobu <ko1@a...>
Date: Mon, 1 Apr 2013 18:39:28 +0900 (JST)
Subject: [ruby-changes:27981] nobu:r40033 (trunk): sha2.c: suppress warnings

nobu	2013-04-01 18:39:19 +0900 (Mon, 01 Apr 2013)

  New Revision: 40033

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40033

  Log:
    sha2.c: suppress warnings
    
    * ext/digest/sha2/sha2.c (SHA256_Final, SHA512_Last): suppress
      strict-aliasing warnings on gcc 4.8.

  Modified files:
    trunk/ext/digest/sha2/sha2.c

Index: ext/digest/sha2/sha2.c
===================================================================
--- ext/digest/sha2/sha2.c	(revision 40032)
+++ ext/digest/sha2/sha2.c	(revision 40033)
@@ -613,7 +613,8 @@ void SHA256_Final(sha2_byte digest[], SH https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/sha2.c#L613
 			*context->buffer = 0x80;
 		}
 		/* Set the bit count: */
-		*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+		MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], &context->bitcount,
+			     sizeof(sha2_word64));
 
 		/* Final transform: */
 		SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -930,8 +931,10 @@ void SHA512_Last(SHA512_CTX* context) { https://github.com/ruby/ruby/blob/trunk/ext/digest/sha2/sha2.c#L931
 		*context->buffer = 0x80;
 	}
 	/* Store the length of input data (in bits): */
-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
+	MEMCPY_BCOPY(&context->buffer[SHA512_SHORT_BLOCK_LENGTH], &context->bitcount[1],
+		     sizeof(sha2_word64));
+	MEMCPY_BCOPY(&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8], &context->bitcount[0],
+		     sizeof(sha2_word64));
 
 	/* Final transform: */
 	SHA512_Transform(context, (sha2_word64*)context->buffer);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]