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

Alexandre Janniaux ajanni at videolabs.io
Wed Apr 8 12:49:09 CEST 2020


Hi,

On Wed, Apr 08, 2020 at 01:30:44PM +0300, Rémi Denis-Courmont wrote:
> 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.

TBH, it feels like excessive requirement on a location that
doesn't require it. Even if __MIN is redefined, it would
warn and in any case it's really likely to be the same
minimum operation.

Regards,
--
Alexandre Janniaux
Videolabs

>
> 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é.

> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list