esp32: return random count
authorAndy Green <andy@warmcat.com>
Fri, 28 Apr 2017 03:53:28 +0000 (11:53 +0800)
committerAndy Green <andy@warmcat.com>
Fri, 28 Apr 2017 03:53:28 +0000 (11:53 +0800)
lib/lws-plat-esp32.c

index c00c933..1f58945 100644 (file)
@@ -39,6 +39,7 @@ LWS_VISIBLE int
 lws_get_random(struct lws_context *context, void *buf, int len)
 {
        uint8_t *pb = buf;
+
        while (len) {
                uint32_t r = esp_random();
                uint8_t *p = (uint8_t *)&r;
@@ -53,7 +54,7 @@ lws_get_random(struct lws_context *context, void *buf, int len)
                        *pb++ = p[b];
        }
 
-       return 0;
+       return pb - (uint8_t *)buf;
 }
 
 LWS_VISIBLE int