[libsoup] soup-websocket.c: #define The Fixed Digest Length



commit 407985ae9220df2189d529f8d602679e42af6b0b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 28 15:34:46 2015 +0800

    soup-websocket.c: #define The Fixed Digest Length
    
    Some compilers (such as Visual Studio) do not like the notion of a[b],
    where b is a variable (or even a const int), so #define the (fixed) digest
    length for compute_accept_key() to be 20, and use that, so that things will
    build and run in such situations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752952

 libsoup/soup-websocket.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-websocket.c b/libsoup/soup-websocket.c
index 2c39b1a..7c19efd 100644
--- a/libsoup/soup-websocket.c
+++ b/libsoup/soup-websocket.c
@@ -28,6 +28,8 @@
 #include "soup-headers.h"
 #include "soup-message.h"
 
+#define FIXED_DIGEST_LEN 20
+
 /**
  * SECTION:soup-websocket
  * @short_description: The WebSocket Protocol
@@ -177,8 +179,8 @@ validate_key (const char *key)
 static char *
 compute_accept_key (const char *key)
 {
-       gsize digest_len = 20;
-       guchar digest[digest_len];
+       gsize digest_len = FIXED_DIGEST_LEN;
+       guchar digest[FIXED_DIGEST_LEN];
        GChecksum *checksum;
 
        if (!key)
@@ -195,7 +197,7 @@ compute_accept_key (const char *key)
        g_checksum_get_digest (checksum, digest, &digest_len);
        g_checksum_free (checksum);
 
-       g_assert (digest_len == 20);
+       g_assert (digest_len == FIXED_DIGEST_LEN);
 
        return g_base64_encode (digest, digest_len);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]