screenshooting: Avoid void pointer arithmetic
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 15 Jul 2015 22:09:15 +0000 (18:09 -0400)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Wed, 15 Jul 2015 22:09:15 +0000 (18:09 -0400)
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

src/modules/shot/e_mod_main.c
src/modules/wl_drm/e_mod_main.c

index 1ab6c48..96ed891 100644 (file)
@@ -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;
                }
index 7314b07..468f674 100644 (file)
@@ -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;
      }
 }