[vlc-devel] [PATCH v2 10/15] rand: simplify

Rémi Denis-Courmont remi at remlab.net
Wed Apr 8 12:30:44 CEST 2020


That __MIN kludge is not namespace-safe. No thanks. And the whole concept is intrinsically broken as a correct min macro would *really* need to be both expansion-safe (__MIN is not) and constant-safe.

Le 8 avril 2020 01:04:26 GMT+03:00, Marvin Scholz <epirat07 at gmail.com> a écrit :
>---
> src/posix/rand.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
>diff --git a/src/posix/rand.c b/src/posix/rand.c
>index 1c258055b7..a1c8ac9602 100644
>--- a/src/posix/rand.c
>+++ b/src/posix/rand.c
>@@ -105,13 +105,11 @@ void vlc_rand_bytes (void *buf, size_t len)
>         vlc_hash_md5_Update (&mdo, mdi_buf, sizeof(mdi_buf));
>         vlc_hash_md5_Finish (&mdo, mdo_buf, sizeof(mdo_buf));
> 
>+        memcpy (buf, mdo_buf, __MIN(len, sizeof(mdo_buf)));
>+
>         if (len < sizeof(mdo_buf))
>-        {
>-            memcpy (buf, mdo_buf, len);
>             break;
>-        }
> 
>-        memcpy (buf, mdo_buf, sizeof(mdo_buf));
>         len -= 16;
>         buf = ((uint8_t *)buf) + 16;
>     }
>-- 
>2.24.1 (Apple Git-126)
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200408/37cf19c2/attachment.html>


More information about the vlc-devel mailing list