[Mesa-dev] [PATCH 35/48] util/tests: Use define instead of VLA

Dylan Baker dylan at pnwbakers.com
Tue Jun 12 16:41:44 UTC 2018


Quoting Eric Engestrom (2018-06-12 04:01:57)
> On Monday, 2018-06-11 15:56:02 -0700, Dylan Baker wrote:
> > To allow the this test to be built with MSVC, which doesn't support
> > VLAs.
> > ---
> >  src/util/tests/hash_table/clear.c             | 13 +++++++------
> >  src/util/tests/hash_table/delete_management.c | 13 +++++++------
> >  src/util/tests/hash_table/insert_many.c       | 11 ++++++-----
> >  src/util/tests/hash_table/meson.build         |  1 +
> >  src/util/tests/hash_table/random_entry.c      |  7 ++++---
> >  src/util/tests/string_buffer/meson.build      |  1 +
> >  6 files changed, 26 insertions(+), 20 deletions(-)
> > 
> > diff --git a/src/util/tests/hash_table/clear.c b/src/util/tests/hash_table/clear.c
> > index 526700bfb0f..19494844608 100644
> > --- a/src/util/tests/hash_table/clear.c
> > +++ b/src/util/tests/hash_table/clear.c
> > @@ -23,6 +23,8 @@
> >  
> >  #include "hash_table.h"
> >  
> > +#define SIZE 1000
> > +
> >  static void *make_key(uint32_t i)
> >  {
> >        return (void *)(uintptr_t)(1 + i);
> > @@ -54,13 +56,12 @@ int main()
> >  {
> >     struct hash_table *ht;
> >     struct hash_entry *entry;
> > -   const uint32_t size = 1000;
> > -   bool flags[size];
> > +   bool flags[SIZE];
> 
> alternative solution:
>   bool flags[1000];
>   const uint32_t size = ARRAY_SIZE(flags);
> 
> bonus: no need to s/size/SIZE/g all over the place :)

I guess? It just doesn't seem like that big of a deal either way, since I used
sed to generate most of the patch anyway.

Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180612/f7a460e9/attachment.sig>


More information about the mesa-dev mailing list