Skip to contentSkip to conversation

no need for checking it

PATCH Superseded Figo.zhang 2 participants 5 messages Jun 6, 2009 Staging

lore
Share & tools
lore

Figo.zhang

author
#0 lore raw

PATCH 1/1 no need for checking it

vfree() does it's own NULL checking,so no need for check before calling it.

---

 drivers/staging/comedi/drivers.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/comedi/drivers.c
index 6e13e45..ce50e85 100644

drivers/staging/comedi/drivers.c +0 -0
@@ -495,9 +495,9 @@ int comedi_buf_alloc(struct comedi_device *dev,

struct comedi_subdevice *s,
vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE);
}
- if (pages) {
- vfree(pages);
- }
+ vfree(pages);
+ pages = NULL;
+
if (async->prealloc_buf == NULL) {
/* Some allocation failed above. */ if (async->buf_page_list) {

#1 lore raw
Quoted 14 lines · Figo.zhang

vfree() does it's own NULL checking,so no need for check before calling it.

---
 drivers/staging/comedi/drivers.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers.c +0 -0
index 6e13e45..ce50e85 100644

drivers/staging/comedi/drivers.c int comedi_buf_alloc(struct comedi_device *dev, · line 500

Quoted 9 lines
drivers/staging/comedi/drivers.c +2 -3
@@ -495,9 +495,9 @@ int comedi_buf_alloc(struct comedi_device *dev,
 struct comedi_subdevice *s,
                                vmap(pages, n_pages, VM_MAP,
                                PAGE_KERNEL_NOCACHE);
                }
-               if (pages) {
-                       vfree(pages);
-               }
+               vfree(pages);
+               pages = NULL;

Why the assignment to NULL? It looks redundant to me.

Quoted 12 lines
drivers/staging/comedi/drivers.c +1 -0
+
                if (async->prealloc_buf == NULL) {
                        /* Some allocation failed above. */

                       if (async->buf_page_list) {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

author
#2 lore raw
Quoted 18 lines · Pekka Enberg
Quoted 17 lines · Figo.zhang

vfree() does it's own NULL checking,so no need for check before calling it.

---
 drivers/staging/comedi/drivers.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers.c +0 -0
index 6e13e45..ce50e85 100644
@@ -495,9 +495,9 @@ int comedi_buf_alloc(struct comedi_device *dev,
 struct comedi_subdevice *s,
                               vmap(pages, n_pages, VM_MAP,
                               PAGE_KERNEL_NOCACHE);
Quoted 21 lines

drivers/staging/comedi/drivers.c int comedi_buf_alloc(struct comedi_device *dev, · line 500

Quoted 6 lines
drivers/staging/comedi/drivers.c +2 -3
               }
-               if (pages) {
-                       vfree(pages);
-               }
+               vfree(pages);
+               pages = NULL;

Why the assignment to NULL? It looks redundant to me.

Quoted 12 lines
drivers/staging/comedi/drivers.c +1 -0
+
               if (async->prealloc_buf == NULL) {
                       /* Some allocation failed above. */
                       if (async->buf_page_list) {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

yes, 'pages' is local variable argment,it is no need assignment to NULL.

Best Regards,

Figo.zhang

author
#3 lore raw

PATCH v2 1/1 no need for checking it

In reply to Figo.zhang

vfree() does it's own NULL checking,so no need for check before calling it.

'pages' is local variable argment,so in v2, it is no need assignment
to NULL.

---
drivers/staging/comedi/drivers.c | 5 ++---

 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/comedi/drivers.c +2 -3
index 6e13e45..587283a 100644
@@ -495,9 +495,8 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 				vmap(pages, n_pages, VM_MAP,
 				PAGE_KERNEL_NOCACHE);
 		}
-		if (pages) {
-			vfree(pages);
-		}
+		vfree(pages);
+		
 		if (async->prealloc_buf == NULL) {
 			/* Some allocation failed above. */
 			if (async->buf_page_list) {