Hello All,

 Sorry for the delay in sending the updated patch.I appreciate your time to
review and comment on the same.

Fixed the conditional operator and its logic for checking the allocation of
memory , white space between the pointers and cleaned up few warnings.

 Signed-off-by : Nagaraj SK <[EMAIL PROTECTED]>
---

--- linux-2.6.26/drivers/char/drm/drm_memory.c    2008-07-26
02:00:56.000000000 +0530
+++ linux-staging/drivers/char/drm/drm_memory.c    2008-07-26
01:55:50.000000000 +0530
@@ -69,7 +69,8 @@ void *drm_realloc(void *oldpt, size_t ol
 {
     void *pt;

-    if (!(pt = kmalloc(size, GFP_KERNEL)))
+    pt = kmalloc(size, GFP_KERNEL);
+    if (!pt)
         return NULL;
     if (oldpt && oldsize) {
         memcpy(pt, oldpt, oldsize);
@@ -80,7 +81,7 @@ void *drm_realloc(void *oldpt, size_t ol

 #if __OS_HAS_AGP
 static void *agp_remap(unsigned long offset, unsigned long size,
-               struct drm_device * dev)
+               struct drm_device *dev)
 {
     unsigned long *phys_addr_map, i, num_pages =
         PAGE_ALIGN(size) / PAGE_SIZE;
@@ -103,9 +104,10 @@ static void *agp_remap(unsigned long off
         return NULL;

     /*
-     * OK, we're mapping AGP space on a chipset/platform on which memory
accesses by
-     * the CPU do not get remapped by the GART.  We fix this by using the
kernel's
-     * page-table instead (that's probably faster anyhow...).
+     * OK, we're mapping AGP space on a chipset/platform on which memory
+     * accesses by the CPU do not get remapped by the GART. We fix this
+     * by using the kernel's page-table instead (that's probably
+     * faster anyhow...).
      */
     /* note: use vmalloc() because num_pages could be large... */
     page_map = vmalloc(num_pages * sizeof(struct page *));
@@ -123,32 +125,32 @@ static void *agp_remap(unsigned long off
 }

 /** Wrapper around agp_allocate_memory() */
-DRM_AGP_MEM *drm_alloc_agp(struct drm_device * dev, int pages, u32 type)
+DRM_AGP_MEM *drm_alloc_agp(struct drm_device *dev, int pages, u32 type)
 {
     return drm_agp_allocate_memory(dev->agp->bridge, pages, type);
 }

 /** Wrapper around agp_free_memory() */
-int drm_free_agp(DRM_AGP_MEM * handle, int pages)
+int drm_free_agp(DRM_AGP_MEM *handle, int pages)
 {
     return drm_agp_free_memory(handle) ? 0 : -EINVAL;
 }

 /** Wrapper around agp_bind_memory() */
-int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start)
+int drm_bind_agp(DRM_AGP_MEM *handle, unsigned int start)
 {
     return drm_agp_bind_memory(handle, start);
 }

 /** Wrapper around agp_unbind_memory() */
-int drm_unbind_agp(DRM_AGP_MEM * handle)
+int drm_unbind_agp(DRM_AGP_MEM *handle)
 {
     return drm_agp_unbind_memory(handle);
 }

 #else  /*  __OS_HAS_AGP  */
 static inline void *agp_remap(unsigned long offset, unsigned long size,
-                  struct drm_device * dev)
+                  struct drm_device *dev)
 {
     return NULL;
 }


Thanks
Nagaraj


On Mon, Jul 21, 2008 at 7:24 AM, nagaraj s k <[EMAIL PROTECTED]> wrote:

> Hi Daniel,
>
> Thanks for correcting me, i will work on this and try sending the patch
> soon with the mentioned changes.
>
> On Sun, Jul 20, 2008 at 12:05 AM, Daniel Stone <[EMAIL PROTECTED]>
> wrote:
>
>> On Sat, Jul 19, 2008 at 11:16:58PM +0530, nagaraj s k wrote:
>> > @@ -69,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t ol
>> >  {
>> >      void *pt;
>> >
>> > -    if (!(pt = kmalloc(size, GFP_KERNEL)))
>> > +    if (!(pt == kmalloc(size, GFP_KERNEL)))
>> >          return NULL;
>> >      if (oldpt && oldsize) {
>> >          memcpy(pt, oldpt, oldsize);
>>
>> Er, this is absolutely not an error.  You'll note that pt is
>> uninitialised, and the odds of a specific piece of uninitialised memory
>> pointing to exactly the location kmalloc returns are ... rather low.
>>
>> It could be rewritten for clarity as:
>> pt = kmalloc(size, GFP_KERNEL);
>> if (!pt)
>>        return NULL;
>>
>> But your patch means the function can practically never actually work.
>>
>> Cheers,
>> Daniel
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (GNU/Linux)
>>
>> iEYEARECAAYFAkiCM9UACgkQUVYB1rKAgJROuwCeLTSHMG6JQsPYPM+uYHEuGv1L
>> 8rMAn21162gICH7wp60D07yYo3PBVM3p
>> =ZRpc
>> -----END PGP SIGNATURE-----
>>
>>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to