Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639856 > unrolled thread

[PATCH 0/4] VMBus: Adjustments for some function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-05-11 18:20 +0200
Last post2017-05-11 18:40 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] VMBus: Adjustments for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-11 18:20 +0200
    [PATCH 1/4] vmbus: Improve a size determination in  vmbus_device_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-11 18:20 +0200
      Re: [PATCH 1/4] vmbus: Improve a size determination in  vmbus_device_create() Stephen Hemminger <stephen@networkplumber.org> - 2017-05-11 18:40 +0200
        Re: [PATCH 1/4] vmbus: Improve a size determination in  vmbus_device_create() Greg KH <greg@kroah.com> - 2017-05-11 19:50 +0200
    [PATCH 4/4] vmbus: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-11 18:30 +0200
      Re: [PATCH 4/4] vmbus: Adjust five checks for null pointers Stephen Hemminger <stephen@networkplumber.org> - 2017-05-11 18:40 +0200

#1639856 — [PATCH 0/4] VMBus: Adjustments for some function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-11 18:20 +0200
Subject[PATCH 0/4] VMBus: Adjustments for some function implementations
Message-ID<tFYYN-ax-9@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 11 May 2017 18:00:18 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
  Improve a size determination in vmbus_device_create()
  Delete an error message for a failed memory allocation in vmbus_device_create()
  Fix a typo in a comment line
  Adjust five checks for null pointers

 drivers/hv/vmbus_drv.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

-- 
2.12.3

[toc] | [next] | [standalone]


#1639858 — [PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-11 18:20 +0200
Subject[PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()
Message-ID<tFYYO-ax-27@gated-at.bofh.it>
In reply to#1639856
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 11 May 2017 17:30:10 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0087b49095eb..6802d74f162c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1145,5 +1145,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
 {
 	struct hv_device *child_device_obj;
 
-	child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
+	child_device_obj = kzalloc(sizeof(*child_device_obj), GFP_KERNEL);
 	if (!child_device_obj) {
-- 
2.12.3

[toc] | [prev] | [next] | [standalone]


#1639883 — Re: [PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()

FromStephen Hemminger <stephen@networkplumber.org>
Date2017-05-11 18:40 +0200
SubjectRe: [PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()
Message-ID<tFZi9-ha-7@gated-at.bofh.it>
In reply to#1639858
On Thu, 11 May 2017 18:15:46 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 11 May 2017 17:30:10 +0200
> 
> Replace the specification of a data structure by a pointer dereference
> as the parameter for the operator "sizeof" to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/hv/vmbus_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 0087b49095eb..6802d74f162c 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1145,5 +1145,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
>  {
>  	struct hv_device *child_device_obj;
>  
> -	child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
> +	child_device_obj = kzalloc(sizeof(*child_device_obj), GFP_KERNEL);
>  	if (!child_device_obj) {

This looks fine.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

[toc] | [prev] | [next] | [standalone]


#1639927 — Re: [PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()

FromGreg KH <greg@kroah.com>
Date2017-05-11 19:50 +0200
SubjectRe: [PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()
Message-ID<tG0nU-Yx-7@gated-at.bofh.it>
In reply to#1639883
On Thu, May 11, 2017 at 09:30:56AM -0700, Stephen Hemminger wrote:
> On Thu, 11 May 2017 18:15:46 +0200
> SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 11 May 2017 17:30:10 +0200
> > 
> > Replace the specification of a data structure by a pointer dereference
> > as the parameter for the operator "sizeof" to make the corresponding size
> > determination a bit safer according to the Linux coding style convention.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  drivers/hv/vmbus_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> > index 0087b49095eb..6802d74f162c 100644
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -1145,5 +1145,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
> >  {
> >  	struct hv_device *child_device_obj;
> >  
> > -	child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
> > +	child_device_obj = kzalloc(sizeof(*child_device_obj), GFP_KERNEL);
> >  	if (!child_device_obj) {
> 
> This looks fine.
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Note, I have a blacklist filter for this person for a reason, I, and
many other maintainers, just ignore them for good reason...

greg k-h

[toc] | [prev] | [next] | [standalone]


#1639874 — [PATCH 4/4] vmbus: Adjust five checks for null pointers

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-11 18:30 +0200
Subject[PATCH 4/4] vmbus: Adjust five checks for null pointers
Message-ID<tFZ8v-dN-39@gated-at.bofh.it>
In reply to#1639856
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 11 May 2017 17:52:38 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hv/vmbus_drv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ff94b111ed8d..b55b979ecf8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -93,7 +93,7 @@ static DEFINE_SEMAPHORE(hyperv_mmio_lock);
 
 static int vmbus_exists(void)
 {
-	if (hv_acpi_dev == NULL)
+	if (!hv_acpi_dev)
 		return -ENODEV;
 
 	return 0;
@@ -568,7 +568,7 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
 		return id;
 
 	id = drv->id_table;
-	if (id == NULL)
+	if (!id)
 		return NULL; /* empty device table */
 
 	for (; !is_null_guid(&id->guid); id++)
@@ -871,7 +871,7 @@ void vmbus_on_msg_dpc(unsigned long data)
 	entry = &channel_message_table[hdr->msgtype];
 	if (entry->handler_type	== VMHT_BLOCKING) {
 		ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
-		if (ctx == NULL)
+		if (!ctx)
 			return;
 
 		INIT_WORK(&ctx->work, vmbus_onmessage_work);
@@ -894,7 +894,7 @@ static void vmbus_channel_isr(struct vmbus_channel *channel)
 	void (*callback_fn)(void *);
 
 	callback_fn = READ_ONCE(channel->onchannel_callback);
-	if (likely(callback_fn != NULL))
+	if (likely(callback_fn))
 		(*callback_fn)(channel->channel_callback_context);
 }
 
@@ -970,7 +970,7 @@ static void vmbus_isr(void)
 	union hv_synic_event_flags *event;
 	bool handled = false;
 
-	if (unlikely(page_addr == NULL))
+	if (unlikely(!page_addr))
 		return;
 
 	event = (union hv_synic_event_flags *)page_addr +
-- 
2.12.3

[toc] | [prev] | [next] | [standalone]


#1639880 — Re: [PATCH 4/4] vmbus: Adjust five checks for null pointers

FromStephen Hemminger <stephen@networkplumber.org>
Date2017-05-11 18:40 +0200
SubjectRe: [PATCH 4/4] vmbus: Adjust five checks for null pointers
Message-ID<tFZi9-ha-1@gated-at.bofh.it>
In reply to#1639874
On Thu, 11 May 2017 18:19:21 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 11 May 2017 17:52:38 +0200
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script “checkpatch.pl” pointed information out like the following.
> 
> Comparison to NULL could be written …
> 
> Thus fix the affected source code places.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Please don't do these kind of checkpatch "fix ups" on existing code.
The comparison with NULL is fine, doing this is just useless churn.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web