Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/dist/drm Avoid pointer arithm...



details:   https://anonhg.NetBSD.org/src/rev/709742810703
branches:  riastradh-drm2
changeset: 788052:709742810703
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 02:00:58 2013 +0000

description:
Avoid pointer arithmetic on void * in drm_buffer.c.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_buffer.c |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (31 lines):

diff -r 0c0e1f347bbb -r 709742810703 sys/external/bsd/drm2/dist/drm/drm_buffer.c
--- a/sys/external/bsd/drm2/dist/drm/drm_buffer.c       Wed Jul 24 02:00:44 2013 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_buffer.c       Wed Jul 24 02:00:58 2013 +0000
@@ -115,6 +115,10 @@
        for (idx = 0; idx < nr_pages; ++idx) {
 
                if (DRM_COPY_FROM_USER(buf->data[idx],
+#ifdef __NetBSD__
+                       /* Pointer arithmetic on void * is not kosher...  */
+                       (const char *)
+#endif
                        user_data + idx * PAGE_SIZE,
                        min(PAGE_SIZE, size - idx * PAGE_SIZE))) {
                        DRM_ERROR("Failed to copy user data (%p) to drm buffer"
@@ -171,10 +175,16 @@
        } else {
                /* The object is split which forces copy to temporary object.*/
                int beginsz = PAGE_SIZE - idx;
+
                memcpy(stack_obj, &buf->data[page][idx], beginsz);
 
+#ifdef __NetBSD__
+               memcpy((char *)stack_obj + beginsz, &buf->data[page + 1][0],
+                               objsize - beginsz);
+#else
                memcpy(stack_obj + beginsz, &buf->data[page + 1][0],
                                objsize - beginsz);
+#endif
 
                obj = stack_obj;
        }



Home | Main Index | Thread Index | Old Index