[Mesa-dev] [PATCH v2 kmscube] cube-tex: Do not declare counter inside 'for' loop
Eric Engestrom
eric.engestrom at imgtec.com
Tue Mar 21 12:01:15 UTC 2017
On Monday, 2017-03-20 09:33:50 -0300, Fabio Estevam wrote:
> Do not declare counter inside 'for' loop to fix the following build errors
> on mips64el:
>
> cube-tex.c: In function 'get_fd_rgba':
> cube-tex.c:230:2: error: 'for' loop initial declarations are only allowed in C99 mode
> for (uint32_t i = 0; i < texh; i++) {
> ^
> cube-tex.c:230:2: note: use option -std=c99 or -std=gnu99 to compile your code
> cube-tex.c: In function 'get_fd_y':
> cube-tex.c:261:2: error: 'for' loop initial declarations are only allowed in C99 mode
> for (uint32_t i = 0; i < texh; i++) {
> ^
> cube-tex.c: In function 'get_fd_uv':
> cube-tex.c:292:2: error: 'for' loop initial declarations are only allowed in C99 mode
> for (uint32_t i = 0; i < texh/2; i++) {
> ^
I think I'd prefer not going backwards. Does your compiler support C99?
If so, I'd suggest using it explicitly by adding -std=c99 to the CFLAGS
in Makefile.am.
C99 is old enough to drink in most countries, I think it's reasonable to
require it by now.
>
> Signed-off-by: Fabio Estevam <festevam at gmail.com>
> ---
> Changes since v1:
> - s/initialize/declare to match the build error
>
> cube-tex.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/cube-tex.c b/cube-tex.c
> index 0caeaea..0eff2ae 100644
> --- a/cube-tex.c
> +++ b/cube-tex.c
> @@ -217,7 +217,7 @@ static int get_fd_rgba(uint32_t *pstride)
> {
> struct gbm_bo *bo;
> void *map_data = NULL;
> - uint32_t stride;
> + uint32_t stride, i;
> extern const uint32_t raw_512x512_rgba[];
> uint8_t *map, *src = (uint8_t *)raw_512x512_rgba;
> int fd;
> @@ -227,7 +227,7 @@ static int get_fd_rgba(uint32_t *pstride)
>
> map = gbm_bo_map(bo, 0, 0, texw, texh, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
>
> - for (uint32_t i = 0; i < texh; i++) {
> + for (i = 0; i < texh; i++) {
> memcpy(&map[stride * i], &src[texw * 4 * i], texw * 4);
> }
>
> @@ -247,7 +247,7 @@ static int get_fd_y(uint32_t *pstride)
> {
> struct gbm_bo *bo;
> void *map_data = NULL;
> - uint32_t stride;
> + uint32_t stride, i;
> extern const uint32_t raw_512x512_nv12[];
> uint8_t *map, *src = (uint8_t *)raw_512x512_nv12;
> int fd;
> @@ -258,7 +258,7 @@ static int get_fd_y(uint32_t *pstride)
>
> map = gbm_bo_map(bo, 0, 0, texw/4, texh, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
>
> - for (uint32_t i = 0; i < texh; i++) {
> + for (i = 0; i < texh; i++) {
> memcpy(&map[stride * i], &src[texw * i], texw);
> }
>
> @@ -278,7 +278,7 @@ static int get_fd_uv(uint32_t *pstride)
> {
> struct gbm_bo *bo;
> void *map_data = NULL;
> - uint32_t stride;
> + uint32_t stride, i;
> extern const uint32_t raw_512x512_nv12[];
> uint8_t *map, *src = &((uint8_t *)raw_512x512_nv12)[texw * texh];
> int fd;
> @@ -289,7 +289,7 @@ static int get_fd_uv(uint32_t *pstride)
>
> map = gbm_bo_map(bo, 0, 0, texw/2/2, texh/2, GBM_BO_TRANSFER_WRITE, &stride, &map_data);
>
> - for (uint32_t i = 0; i < texh/2; i++) {
> + for (i = 0; i < texh/2; i++) {
> memcpy(&map[stride * i], &src[texw * i], texw);
> }
>
> --
> 2.7.4
>
More information about the mesa-dev
mailing list