* [PATCH v2 3/3] drm: Remove assignment in if condition
@ 2017-09-13 16:15 ` Meghana Madhyastha
0 siblings, 0 replies; 6+ messages in thread
From: Meghana Madhyastha @ 2017-09-13 16:15 UTC (permalink / raw)
To: outreachy-kernel, Jani Nikula, dri-devel
Move the assignment so that it happens before the if
condition. This results in syntax which is easier to read.
Found by checkpath.pl
Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
---
drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 993e486..737f028 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
return -ENODEV;
if (dev->agp->acquired)
return -EBUSY;
- if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
+ dev->agp->bridge = agp_backend_acquire(dev->pdev);
+ if (!dev->agp->bridge)
return -ENODEV;
dev->agp->acquired = 1;
return 0;
@@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
+ entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ if (!entry)
return -ENOMEM;
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request->type;
- if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
+ memory = agp_allocate_memory(dev->agp->bridge, pages, type);
+ if (!memory) {
kfree(entry);
return -ENOMEM;
}
@@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
- return -EINVAL;
- if (!entry->bound)
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry || !entry->bound)
return -EINVAL;
ret = drm_unbind_agp(entry->memory);
if (ret == 0)
@@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
- return -EINVAL;
- if (entry->bound)
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry || entry->bound)
return -EINVAL;
page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
- if ((retcode = drm_bind_agp(entry->memory, page)))
+ retcode = drm_bind_agp(entry->memory, page);
+ if (retcode)
return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT);
DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
@@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry)
return -EINVAL;
if (entry->bound)
drm_unbind_agp(entry->memory);
@@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
{
struct drm_agp_head *head = NULL;
- if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
+ head = kzalloc(sizeof(*head), GFP_KERNEL);
+ if (!head)
return NULL;
head->bridge = agp_find_bridge(dev->pdev);
if (!head->bridge) {
- if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
+ head->bridge = agp_backend_acquire(dev->pdev);
+ if (!head->bridge) {
kfree(head);
return NULL;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v2 3/3] drm: Remove assignment in if condition
@ 2017-09-13 16:15 ` Meghana Madhyastha
0 siblings, 0 replies; 6+ messages in thread
From: Meghana Madhyastha @ 2017-09-13 16:15 UTC (permalink / raw)
To: outreachy-kernel, Jani Nikula, dri-devel
Move the assignment so that it happens before the if
condition. This results in syntax which is easier to read.
Found by checkpath.pl
Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
---
drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 993e486..737f028 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
return -ENODEV;
if (dev->agp->acquired)
return -EBUSY;
- if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
+ dev->agp->bridge = agp_backend_acquire(dev->pdev);
+ if (!dev->agp->bridge)
return -ENODEV;
dev->agp->acquired = 1;
return 0;
@@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
+ entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ if (!entry)
return -ENOMEM;
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request->type;
- if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
+ memory = agp_allocate_memory(dev->agp->bridge, pages, type);
+ if (!memory) {
kfree(entry);
return -ENOMEM;
}
@@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
- return -EINVAL;
- if (!entry->bound)
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry || !entry->bound)
return -EINVAL;
ret = drm_unbind_agp(entry->memory);
if (ret == 0)
@@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
- return -EINVAL;
- if (entry->bound)
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry || entry->bound)
return -EINVAL;
page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
- if ((retcode = drm_bind_agp(entry->memory, page)))
+ retcode = drm_bind_agp(entry->memory, page);
+ if (retcode)
return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT);
DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
@@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired)
return -EINVAL;
- if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
+ entry = drm_agp_lookup_entry(dev, request->handle);
+ if (!entry)
return -EINVAL;
if (entry->bound)
drm_unbind_agp(entry->memory);
@@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
{
struct drm_agp_head *head = NULL;
- if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
+ head = kzalloc(sizeof(*head), GFP_KERNEL);
+ if (!head)
return NULL;
head->bridge = agp_find_bridge(dev->pdev);
if (!head->bridge) {
- if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
+ head->bridge = agp_backend_acquire(dev->pdev);
+ if (!head->bridge) {
kfree(head);
return NULL;
}
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Outreachy kernel] [PATCH v2 3/3] drm: Remove assignment in if condition
2017-09-13 16:15 ` Meghana Madhyastha
@ 2017-09-13 20:22 ` Julia Lawall
-1 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2017-09-13 20:22 UTC (permalink / raw)
To: Meghana Madhyastha; +Cc: outreachy-kernel, Jani Nikula, dri-devel
On Wed, 13 Sep 2017, Meghana Madhyastha wrote:
> Move the assignment so that it happens before the if
> condition. This results in syntax which is easier to read.
It would be nice to mention the merged conditionals in the log message.
julia
> Found by checkpath.pl
>
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
> ---
> drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> index 993e486..737f028 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
> return -ENODEV;
> if (dev->agp->acquired)
> return -EBUSY;
> - if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
> + dev->agp->bridge = agp_backend_acquire(dev->pdev);
> + if (!dev->agp->bridge)
> return -ENODEV;
> dev->agp->acquired = 1;
> return 0;
> @@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
> + if (!entry)
> return -ENOMEM;
>
> pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
> type = (u32) request->type;
> - if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
> + memory = agp_allocate_memory(dev->agp->bridge, pages, type);
> + if (!memory) {
> kfree(entry);
> return -ENOMEM;
> }
> @@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> - return -EINVAL;
> - if (!entry->bound)
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry || !entry->bound)
> return -EINVAL;
> ret = drm_unbind_agp(entry->memory);
> if (ret == 0)
> @@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> - return -EINVAL;
> - if (entry->bound)
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry || entry->bound)
> return -EINVAL;
> page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
> - if ((retcode = drm_bind_agp(entry->memory, page)))
> + retcode = drm_bind_agp(entry->memory, page);
> + if (retcode)
> return retcode;
> entry->bound = dev->agp->base + (page << PAGE_SHIFT);
> DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
> @@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry)
> return -EINVAL;
> if (entry->bound)
> drm_unbind_agp(entry->memory);
> @@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
> {
> struct drm_agp_head *head = NULL;
>
> - if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
> + head = kzalloc(sizeof(*head), GFP_KERNEL);
> + if (!head)
> return NULL;
> head->bridge = agp_find_bridge(dev->pdev);
> if (!head->bridge) {
> - if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
> + head->bridge = agp_backend_acquire(dev->pdev);
> + if (!head->bridge) {
> kfree(head);
> return NULL;
> }
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913161531.GA3239%40meghana-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Outreachy kernel] [PATCH v2 3/3] drm: Remove assignment in if condition
@ 2017-09-13 20:22 ` Julia Lawall
0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2017-09-13 20:22 UTC (permalink / raw)
To: Meghana Madhyastha; +Cc: outreachy-kernel, dri-devel
On Wed, 13 Sep 2017, Meghana Madhyastha wrote:
> Move the assignment so that it happens before the if
> condition. This results in syntax which is easier to read.
It would be nice to mention the merged conditionals in the log message.
julia
> Found by checkpath.pl
>
> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
> ---
> drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
> index 993e486..737f028 100644
> --- a/drivers/gpu/drm/drm_agpsupport.c
> +++ b/drivers/gpu/drm/drm_agpsupport.c
> @@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
> return -ENODEV;
> if (dev->agp->acquired)
> return -EBUSY;
> - if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
> + dev->agp->bridge = agp_backend_acquire(dev->pdev);
> + if (!dev->agp->bridge)
> return -ENODEV;
> dev->agp->acquired = 1;
> return 0;
> @@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
> + if (!entry)
> return -ENOMEM;
>
> pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
> type = (u32) request->type;
> - if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
> + memory = agp_allocate_memory(dev->agp->bridge, pages, type);
> + if (!memory) {
> kfree(entry);
> return -ENOMEM;
> }
> @@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> - return -EINVAL;
> - if (!entry->bound)
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry || !entry->bound)
> return -EINVAL;
> ret = drm_unbind_agp(entry->memory);
> if (ret == 0)
> @@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> - return -EINVAL;
> - if (entry->bound)
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry || entry->bound)
> return -EINVAL;
> page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
> - if ((retcode = drm_bind_agp(entry->memory, page)))
> + retcode = drm_bind_agp(entry->memory, page);
> + if (retcode)
> return retcode;
> entry->bound = dev->agp->base + (page << PAGE_SHIFT);
> DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
> @@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>
> if (!dev->agp || !dev->agp->acquired)
> return -EINVAL;
> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
> + entry = drm_agp_lookup_entry(dev, request->handle);
> + if (!entry)
> return -EINVAL;
> if (entry->bound)
> drm_unbind_agp(entry->memory);
> @@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
> {
> struct drm_agp_head *head = NULL;
>
> - if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
> + head = kzalloc(sizeof(*head), GFP_KERNEL);
> + if (!head)
> return NULL;
> head->bridge = agp_find_bridge(dev->pdev);
> if (!head->bridge) {
> - if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
> + head->bridge = agp_backend_acquire(dev->pdev);
> + if (!head->bridge) {
> kfree(head);
> return NULL;
> }
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913161531.GA3239%40meghana-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Outreachy kernel] [PATCH v2 3/3] drm: Remove assignment in if condition
2017-09-13 20:22 ` Julia Lawall
@ 2017-09-14 6:13 ` Jani Nikula
-1 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2017-09-14 6:13 UTC (permalink / raw)
To: Julia Lawall, Meghana Madhyastha; +Cc: outreachy-kernel, dri-devel
On Wed, 13 Sep 2017, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Wed, 13 Sep 2017, Meghana Madhyastha wrote:
>
>> Move the assignment so that it happens before the if
>> condition. This results in syntax which is easier to read.
>
> It would be nice to mention the merged conditionals in the log message.
Either way,
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> julia
>
>> Found by checkpath.pl
>>
>> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
>> ---
>> drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
>> 1 file changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
>> index 993e486..737f028 100644
>> --- a/drivers/gpu/drm/drm_agpsupport.c
>> +++ b/drivers/gpu/drm/drm_agpsupport.c
>> @@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
>> return -ENODEV;
>> if (dev->agp->acquired)
>> return -EBUSY;
>> - if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
>> + dev->agp->bridge = agp_backend_acquire(dev->pdev);
>> + if (!dev->agp->bridge)
>> return -ENODEV;
>> dev->agp->acquired = 1;
>> return 0;
>> @@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
>> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>> + if (!entry)
>> return -ENOMEM;
>>
>> pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
>> type = (u32) request->type;
>> - if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
>> + memory = agp_allocate_memory(dev->agp->bridge, pages, type);
>> + if (!memory) {
>> kfree(entry);
>> return -ENOMEM;
>> }
>> @@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> - return -EINVAL;
>> - if (!entry->bound)
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry || !entry->bound)
>> return -EINVAL;
>> ret = drm_unbind_agp(entry->memory);
>> if (ret == 0)
>> @@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> - return -EINVAL;
>> - if (entry->bound)
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry || entry->bound)
>> return -EINVAL;
>> page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
>> - if ((retcode = drm_bind_agp(entry->memory, page)))
>> + retcode = drm_bind_agp(entry->memory, page);
>> + if (retcode)
>> return retcode;
>> entry->bound = dev->agp->base + (page << PAGE_SHIFT);
>> DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
>> @@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry)
>> return -EINVAL;
>> if (entry->bound)
>> drm_unbind_agp(entry->memory);
>> @@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>> {
>> struct drm_agp_head *head = NULL;
>>
>> - if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
>> + head = kzalloc(sizeof(*head), GFP_KERNEL);
>> + if (!head)
>> return NULL;
>> head->bridge = agp_find_bridge(dev->pdev);
>> if (!head->bridge) {
>> - if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
>> + head->bridge = agp_backend_acquire(dev->pdev);
>> + if (!head->bridge) {
>> kfree(head);
>> return NULL;
>> }
>> --
>> 2.7.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913161531.GA3239%40meghana-HP-Pavilion-Notebook.
>> For more options, visit https://groups.google.com/d/optout.
>>
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Outreachy kernel] [PATCH v2 3/3] drm: Remove assignment in if condition
@ 2017-09-14 6:13 ` Jani Nikula
0 siblings, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2017-09-14 6:13 UTC (permalink / raw)
To: Julia Lawall, Meghana Madhyastha; +Cc: outreachy-kernel, dri-devel
On Wed, 13 Sep 2017, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Wed, 13 Sep 2017, Meghana Madhyastha wrote:
>
>> Move the assignment so that it happens before the if
>> condition. This results in syntax which is easier to read.
>
> It would be nice to mention the merged conditionals in the log message.
Either way,
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> julia
>
>> Found by checkpath.pl
>>
>> Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
>> ---
>> drivers/gpu/drm/drm_agpsupport.c | 31 ++++++++++++++++++-------------
>> 1 file changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
>> index 993e486..737f028 100644
>> --- a/drivers/gpu/drm/drm_agpsupport.c
>> +++ b/drivers/gpu/drm/drm_agpsupport.c
>> @@ -100,7 +100,8 @@ int drm_agp_acquire(struct drm_device *dev)
>> return -ENODEV;
>> if (dev->agp->acquired)
>> return -EBUSY;
>> - if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev)))
>> + dev->agp->bridge = agp_backend_acquire(dev->pdev);
>> + if (!dev->agp->bridge)
>> return -ENODEV;
>> dev->agp->acquired = 1;
>> return 0;
>> @@ -200,12 +201,14 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = kzalloc(sizeof(*entry), GFP_KERNEL)))
>> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>> + if (!entry)
>> return -ENOMEM;
>>
>> pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
>> type = (u32) request->type;
>> - if (!(memory = agp_allocate_memory(dev->agp->bridge, pages, type))) {
>> + memory = agp_allocate_memory(dev->agp->bridge, pages, type);
>> + if (!memory) {
>> kfree(entry);
>> return -ENOMEM;
>> }
>> @@ -272,9 +275,8 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> - return -EINVAL;
>> - if (!entry->bound)
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry || !entry->bound)
>> return -EINVAL;
>> ret = drm_unbind_agp(entry->memory);
>> if (ret == 0)
>> @@ -313,12 +315,12 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> - return -EINVAL;
>> - if (entry->bound)
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry || entry->bound)
>> return -EINVAL;
>> page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE;
>> - if ((retcode = drm_bind_agp(entry->memory, page)))
>> + retcode = drm_bind_agp(entry->memory, page);
>> + if (retcode)
>> return retcode;
>> entry->bound = dev->agp->base + (page << PAGE_SHIFT);
>> DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
>> @@ -356,7 +358,8 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
>>
>> if (!dev->agp || !dev->agp->acquired)
>> return -EINVAL;
>> - if (!(entry = drm_agp_lookup_entry(dev, request->handle)))
>> + entry = drm_agp_lookup_entry(dev, request->handle);
>> + if (!entry)
>> return -EINVAL;
>> if (entry->bound)
>> drm_unbind_agp(entry->memory);
>> @@ -394,11 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
>> {
>> struct drm_agp_head *head = NULL;
>>
>> - if (!(head = kzalloc(sizeof(*head), GFP_KERNEL)))
>> + head = kzalloc(sizeof(*head), GFP_KERNEL);
>> + if (!head)
>> return NULL;
>> head->bridge = agp_find_bridge(dev->pdev);
>> if (!head->bridge) {
>> - if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
>> + head->bridge = agp_backend_acquire(dev->pdev);
>> + if (!head->bridge) {
>> kfree(head);
>> return NULL;
>> }
>> --
>> 2.7.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170913161531.GA3239%40meghana-HP-Pavilion-Notebook.
>> For more options, visit https://groups.google.com/d/optout.
>>
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-14 6:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 16:15 [PATCH v2 3/3] drm: Remove assignment in if condition Meghana Madhyastha
2017-09-13 16:15 ` Meghana Madhyastha
2017-09-13 20:22 ` [Outreachy kernel] " Julia Lawall
2017-09-13 20:22 ` Julia Lawall
2017-09-14 6:13 ` Jani Nikula
2017-09-14 6:13 ` Jani Nikula
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.