[Mesa-dev] [PATCH 2/3] mesa: Add initializer macros to fix missing initializer warnings

Ian Romanick idr at freedesktop.org
Wed Jan 21 12:34:36 PST 2015


On 01/21/2015 10:33 AM, Jan Vesely wrote:
> NFC.

NFC?  I'm assuming this doesn't mean Near Field Communications or "no
'fine' clue."

> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>  src/mesa/main/texcompress_bptc.c | 40 ++++++++++++++++++++++------------------
>  1 file changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/src/mesa/main/texcompress_bptc.c b/src/mesa/main/texcompress_bptc.c
> index c944ac2..56ca320 100644
> --- a/src/mesa/main/texcompress_bptc.c
> +++ b/src/mesa/main/texcompress_bptc.c
> @@ -59,6 +59,8 @@ struct bptc_float_bitfield {
>     bool reverse;
>  };
>  
> +#define BPTC_FLOAT_BITFIELD_END { -1, 0, 0, 0, false }
> +
>  struct bptc_float_mode {
>     bool reserved;
>     bool transformed_endpoints;
> @@ -69,6 +71,8 @@ struct bptc_float_mode {
>     struct bptc_float_bitfield bitfields[24];
>  };
>  
> +#define BPTC_FLOAT_MODE_RESERVED { true, false, 0, 0, 0, {}, {}}
> +
>  struct bit_writer {
>     uint8_t buf;
>     int pos;
> @@ -98,7 +102,7 @@ bptc_float_modes[] = {
>         { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
>         { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
>         { 3, 2, 3, 1, false },
> -       { -1 } }

I think just adding a , after the -1 will have the same effect.  C
explicitly states that missing members are initialized to 0.

> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 01 */
>     { false, true, 5, 7, 3, { 6, 6, 6 },
> @@ -111,7 +115,7 @@ bptc_float_modes[] = {
>         { 3, 1, 0, 4, false }, { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false },
>         { 2, 0, 0, 6, false },
>         { 3, 0, 0, 6, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 00010 */
>     { false, true, 5, 11, 3, { 5, 4, 4 },
> @@ -121,13 +125,13 @@ bptc_float_modes[] = {
>         { 3, 1, 0, 4, false }, { 1, 2, 0, 4, false }, { 0, 2, 10, 1, false },
>         { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
>         { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 00011 */
>     { false, false, 0, 10, 4, { 10, 10, 10 },
>       { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
>         { 1, 0, 0, 10, false }, { 1, 1, 0, 10, false }, { 1, 2, 0, 10, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 00110 */
>     { false, true, 5, 11, 3, { 4, 5, 4 },
> @@ -138,14 +142,14 @@ bptc_float_modes[] = {
>         { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
>         { 3, 2, 0, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
>         { 2, 1, 4, 1, false }, { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 00111 */
>     { false, true, 0, 11, 4, { 9, 9, 9 },
>       { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
>         { 1, 0, 0, 9, false }, { 0, 0, 10, 1, false }, { 1, 1, 0, 9, false },
>         { 0, 1, 10, 1, false }, { 1, 2, 0, 9, false }, { 0, 2, 10, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 01010 */
>     { false, true, 5, 11, 3, { 4, 4, 5 },
> @@ -156,14 +160,14 @@ bptc_float_modes[] = {
>         { 0, 2, 10, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
>         { 3, 2, 1, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
>         { 3, 2, 4, 1, false }, { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 01011 */
>     { false, true, 0, 12, 4, { 8, 8, 8 },
>       { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
>         { 1, 0, 0, 8, false }, { 0, 0, 10, 2, true }, { 1, 1, 0, 8, false },
>         { 0, 1, 10, 2, true }, { 1, 2, 0, 8, false }, { 0, 2, 10, 2, true },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 01110 */
>     { false, true, 5, 9, 3, { 5, 5, 5 },
> @@ -174,14 +178,14 @@ bptc_float_modes[] = {
>         { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
>         { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
>         { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 01111 */
>     { false, true, 0, 16, 4, { 4, 4, 4 },
>       { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
>         { 1, 0, 0, 4, false }, { 0, 0, 10, 6, true }, { 1, 1, 0, 4, false },
>         { 0, 1, 10, 6, true }, { 1, 2, 0, 4, false }, { 0, 2, 10, 6, true },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 10010 */
>     { false, true, 5, 8, 3, { 6, 5, 5 },
> @@ -192,10 +196,10 @@ bptc_float_modes[] = {
>         { 3, 2, 0, 1, false }, { 3, 1, 0, 4, false }, { 1, 2, 0, 5, false },
>         { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 6, false },
>         { 3, 0, 0, 6, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 10011 */
> -   { true /* reserved */ },
> +   BPTC_FLOAT_MODE_RESERVED,
>     /* 10110 */
>     { false, true, 5, 8, 3, { 5, 6, 5 },
>       { { 0, 0, 0, 8, false }, { 3, 2, 0, 1, false }, { 2, 2, 4, 1, false },
> @@ -205,10 +209,10 @@ bptc_float_modes[] = {
>         { 1, 1, 0, 6, false }, { 3, 1, 0, 4, false }, { 1, 2, 0, 5, false },
>         { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
>         { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 10111 */
> -   { true /* reserved */ },
> +   BPTC_FLOAT_MODE_RESERVED,
>     /* 11010 */
>     { false, true, 5, 8, 3, { 5, 5, 6 },
>       { { 0, 0, 0, 8, false }, { 3, 2, 1, 1, false }, { 2, 2, 4, 1, false },
> @@ -218,10 +222,10 @@ bptc_float_modes[] = {
>         { 1, 1, 0, 5, false }, { 3, 2, 0, 1, false }, { 3, 1, 0, 4, false },
>         { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
>         { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 11011 */
> -   { true /* reserved */ },
> +   BPTC_FLOAT_MODE_RESERVED,
>     /* 11110 */
>     { false, false, 5, 6, 3, { 6, 6, 6 },
>       { { 0, 0, 0, 6, false }, { 3, 1, 4, 1, false }, { 3, 2, 0, 1, false },
> @@ -232,10 +236,10 @@ bptc_float_modes[] = {
>         { 1, 0, 0, 6, false }, { 2, 1, 0, 4, false }, { 1, 1, 0, 6, false },
>         { 3, 1, 0, 4, false }, { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false },
>         { 2, 0, 0, 6, false }, { 3, 0, 0, 6, false },
> -       { -1 } }
> +       BPTC_FLOAT_BITFIELD_END }
>     },
>     /* 11111 */
> -   { true /* reserved */ },
> +   BPTC_FLOAT_MODE_RESERVED,
>  };
>  
>  /* This partition table is used when the mode has two subsets. Each
> 



More information about the mesa-dev mailing list