From: Derek Foreman Date: Wed, 15 Jul 2015 22:09:15 +0000 (-0400) Subject: screenshooting: Avoid void pointer arithmetic X-Git-Tag: upstream/0.20.0~561 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41cb2fa161f4d5dc154717dd8b8c2b325329777c;p=platform%2Fupstream%2Fenlightenment.git screenshooting: Avoid void pointer arithmetic Summary: If we use unsigned char pointers instead of void pointers we actually conform to the C standard. This patch removes a reliance on a gcc extension and, as an added bonus, also quiets a warning in the default build. Reviewers: zmike Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2820 --- diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c index 1ab6c48..96ed891 100644 --- a/src/modules/shot/e_mod_main.c +++ b/src/modules/shot/e_mod_main.c @@ -932,7 +932,7 @@ _wl_shot_now(E_Zone *zone, E_Client *ec, const char *params) struct wl_shm *shm; int x, y, sw, sh, i; int ostride, bstride; - void *dst, *d, *s; + unsigned char *dst, *d, *s; if ((win) || (url_up)) return; if ((!zone) && (!ec)) return; @@ -998,7 +998,8 @@ _wl_shot_now(E_Zone *zone, E_Client *ec, const char *params) d = dst; for (i = y; i < (y + sh); i++) { - s = output->data + (i * ostride) + (x * sizeof(int)); + s = output->data; + s += (i * ostride) + (x * sizeof(int)); memcpy(d, s, bstride); d += bstride; } diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index 7314b07..468f674 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -623,7 +623,7 @@ _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels) Ecore_Drm_Fb *fb; const Eina_List *drm_devs, *l; int i = 0, bstride; - void *s; + unsigned char *s, *d = pixels; drm_devs = ecore_drm_devices_get(); EINA_LIST_FOREACH(drm_devs, l, dev) @@ -636,13 +636,13 @@ _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels) if (!fb) return; bstride = output->w * sizeof(int); - s = fb->mmap; for (i = output->y; i < output->y + output->h; i++) { - s = fb->mmap + (fb->stride * i) + (output->x * sizeof(int)); - memcpy(pixels, s, (output->w * sizeof(int))); - pixels += bstride; + s = fb->mmap; + s += (fb->stride * i) + (output->x * sizeof(int)); + memcpy(d, s, (output->w * sizeof(int))); + d += bstride; } }