Skip to contentSkip to conversation

Staging: slicoss: Use sizeof structure *pointer over sizeof structure in kmalloc()/kzalloc().

PATCH Superseded Sandhya Bankar 2 participants 6 messages Feb 22, 2016 – Feb 23, 2016 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: slicoss: Use sizeof structure *pointer over sizeof structure in kmalloc()/kzalloc().

Use sizeof structure *pointer over sizeof structure in kmalloc()/kzalloc().

---
 drivers/staging/slicoss/slicoss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/slicoss/slicoss.c +3 -3
index a91c60a..ea6b7b5 100644
@@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct adapter *adapter,
 	struct slic_upr *upr;
 	struct slic_upr *uprqueue;
 
-	upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
+	upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
 	if (!upr)
 		return -ENOMEM;
 
@@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct adapter *adapter, char *address)
 	}
 
 	/* Doesn't already exist.  Allocate a structure to hold it */
-	mcaddr = kmalloc(sizeof(struct mcast_address), GFP_ATOMIC);
+	mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
 	if (mcaddr == NULL)
 		return 1;
 
@@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct adapter *adapter)
 	}
 	if (!physcard) {
 		/* no structure allocated for this physical card yet */
-		physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
+		physcard = kzalloc(sizeof(*physcard), GFP_ATOMIC);
 		if (!physcard) {
 			if (card_hostid == SLIC_HOSTID_DEFAULT)
 				kfree(card);
Signature · 1 line
1.8.3.4
#1 lore raw
Quoted 21 lines · Sandhya Bankar

Use sizeof structure *pointer over sizeof structure in kmalloc()/kzalloc().

---
 drivers/staging/slicoss/slicoss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/slicoss/slicoss.c +1 -1
index a91c60a..ea6b7b5 100644
@@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct adapter *adapter,
 	struct slic_upr *upr;
 	struct slic_upr *uprqueue;
 
-	upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
+	upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
 	if (!upr)
 		return -ENOMEM;
 

drivers/staging/slicoss/slicoss.c static int slic_mcast_add_list(struct adapter *adapter, char *address) · line 1810

Quoted 6 lines
drivers/staging/slicoss/slicoss.c +1 -1
@@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct adapter *adapter, char *address)
 	}
 
 	/* Doesn't already exist.  Allocate a structure to hold it */
-	mcaddr = kmalloc(sizeof(struct mcast_address), GFP_ATOMIC);
+	mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
 	if (mcaddr == NULL)

You could make a series and also eliminate this == NULL test.

julia

Quoted 21 lines
drivers/staging/slicoss/slicoss.c +1 -1
 		return 1;
 
@@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct adapter *adapter)
 	}
 	if (!physcard) {
 		/* no structure allocated for this physical card yet */
-		physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
+		physcard = kzalloc(sizeof(*physcard), GFP_ATOMIC);
 		if (!physcard) {
 			if (card_hostid == SLIC_HOSTID_DEFAULT)
 				kfree(card);
Signature · 8 lines
1.8.3.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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160222103651.GA5176%40sandhya.
For more options, visit https://groups.google.com/d/optout.
#2 lore raw

Hello,
I understand the ==NULL changes,but i have not understood the "make a series" concept.

Quoted 67 lines · Julia Lawall
Quoted 1 line · Sandhya Bankar

Use sizeof structure *pointer over sizeof structure in

kmalloc()/kzalloc().

Review

Quoted 7 lines
---
 drivers/staging/slicoss/slicoss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/slicoss/slicoss.c

drivers/staging/slicoss/slicoss.c static int slic_upr_queue_request(struct adapter

Quoted 4 lines

index a91c60a..ea6b7b5 100644

drivers/staging/slicoss/slicoss.c +0 -0
@@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct adapter

*adapter,

drivers/staging/slicoss/slicoss.c static int slic_mcast_add_list(struct adapter

Quoted 9 lines
drivers/staging/slicoss/slicoss.c +1 -1
      struct slic_upr *upr;
      struct slic_upr *uprqueue;
 
-     upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
+     upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
      if (!upr)
              return -ENOMEM;
 
@@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct adapter

*adapter, char *address)

drivers/staging/slicoss/slicoss.c static int slic_mcast_add_list(struct adapter *adapter, char *address) · line 1810

Quoted 6 lines
drivers/staging/slicoss/slicoss.c +1 -1
      }
 
      /* Doesn't already exist.  Allocate a structure to hold it */
-     mcaddr = kmalloc(sizeof(struct mcast_address), GFP_ATOMIC);
+     mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
      if (mcaddr == NULL)

You could make a series and also eliminate this == NULL test.

julia

drivers/staging/slicoss/slicoss.c static u32 slic_card_locate(struct adapter

Quoted 3 lines
drivers/staging/slicoss/slicoss.c +0 -0
              return 1;
 
@@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct adapter

*adapter)

Quoted 11 lines
drivers/staging/slicoss/slicoss.c +1 -2
      }
      if (!physcard) {
              /* no structure allocated for this physical card yet */
-             physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
+             physcard = kzalloc(sizeof(*physcard), GFP_ATOMIC);
              if (!physcard) {
                      if (card_hostid == SLIC_HOSTID_DEFAULT)
                              kfree(card);
--

1.8.3.4

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20160222103651.GA5176%40sandhya
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 3 lines · sandhya bankar

Hello,
I understand the ==NULL changes,but i have not understood the "make a series" concept.

If you look at the patches sent by others, sometimes they say, eg

[PATCH 1/4]

That means that there is a series of four patches, and this one is the first one. Making a series is necessary when you have several different changes to make, and they all touch the same file. By putting 1/4, 2/4, etc in the subject line, the maintainer knows in what order they should be applied. This reduces the chance of patch application errors.

This is described in more detail in the Outreachy kernel tutorial in the section "Submitting a patchset".

http://kernelnewbies.org/Outreachyfirstpatch#head-e0c4dbf8c60d25ca8e3ae133b6b65560f3c84c09

julia

Quoted 86 lines · Julia Lawall

      On Mon, 22 Feb 2016, Sandhya Bankar wrote:

      > Use sizeof structure *pointer over sizeof structure in
      kmalloc()/kzalloc().
      >
      > Signed-off-by: Sandhya Bankar <[email protected]>
      > ---
      >  drivers/staging/slicoss/slicoss.c | 6 +++---
      >  1 file changed, 3 insertions(+), 3 deletions(-)
      >
      > diff --git a/drivers/staging/slicoss/slicoss.c
      b/drivers/staging/slicoss/slicoss.c
      > index a91c60a..ea6b7b5 100644
      > --- a/drivers/staging/slicoss/slicoss.c
      > +++ b/drivers/staging/slicoss/slicoss.c
      > @@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct
      adapter *adapter,
      >       struct slic_upr *upr;
      >       struct slic_upr *uprqueue;
      >
      > -     upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
      > +     upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
      >       if (!upr)
      >               return -ENOMEM;
      >
      > @@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct
      adapter *adapter, char *address)
      >       }
      >
      >       /* Doesn't already exist.  Allocate a structure to hold
      it */
      > -     mcaddr = kmalloc(sizeof(struct mcast_address),
      GFP_ATOMIC);
      > +     mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
      >       if (mcaddr == NULL)

      You could make a series and also eliminate this == NULL test.

      julia

      >               return 1;
      >
      > @@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct
      adapter *adapter)
      >       }
      >       if (!physcard) {
      >               /* no structure allocated for this physical
      card yet */
      > -             physcard = kzalloc(sizeof(struct physcard),
      GFP_ATOMIC);
      > +             physcard = kzalloc(sizeof(*physcard),
      GFP_ATOMIC);
      >               if (!physcard) {
      >                       if (card_hostid == SLIC_HOSTID_DEFAULT)
      >                               kfree(card);
      > --
      > 1.8.3.4
      >
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

Quoted 1 line

To post to this group, send email to

[email protected].

Quoted 1 line

To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20160222103651.GA5176%4

0sandhya.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAA3ASz%3DisFucBfQL0sf6 hqjhWfC2R-ag8a_7s6W8wDnJMnGeHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw

thank you !!

Quoted 116 lines · Julia Lawall
Quoted 3 lines · sandhya bankar

Hello,
I understand the ==NULL changes,but i have not understood the "make a series" concept.

If you look at the patches sent by others, sometimes they say, eg

[PATCH 1/4]

That means that there is a series of four patches, and this one is the first one. Making a series is necessary when you have several different changes to make, and they all touch the same file. By putting 1/4, 2/4, etc in the subject line, the maintainer knows in what order they should be applied. This reduces the chance of patch application errors.

This is described in more detail in the Outreachy kernel tutorial in the section "Submitting a patchset".

http://kernelnewbies.org/Outreachyfirstpatch#head-e0c4dbf8c60d25ca8e3ae133b6b65560f3c84c09

julia

Quoted 2 lines

On Wed, Feb 24, 2016 at 1:09 AM, Julia Lawall <[email protected]>

Quoted 60 lines · wrote:

      On Mon, 22 Feb 2016, Sandhya Bankar wrote:

      > Use sizeof structure *pointer over sizeof structure in
      kmalloc()/kzalloc().
      >
      > Signed-off-by: Sandhya Bankar <[email protected]>
      > ---
      >  drivers/staging/slicoss/slicoss.c | 6 +++---
      >  1 file changed, 3 insertions(+), 3 deletions(-)
      >
      > diff --git a/drivers/staging/slicoss/slicoss.c
      b/drivers/staging/slicoss/slicoss.c
      > index a91c60a..ea6b7b5 100644
      > --- a/drivers/staging/slicoss/slicoss.c
      > +++ b/drivers/staging/slicoss/slicoss.c
      > @@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct
      adapter *adapter,
      >       struct slic_upr *upr;
      >       struct slic_upr *uprqueue;
      >
      > -     upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
      > +     upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
      >       if (!upr)
      >               return -ENOMEM;
      >
      > @@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct
      adapter *adapter, char *address)
      >       }
      >
      >       /* Doesn't already exist.  Allocate a structure to hold
      it */
      > -     mcaddr = kmalloc(sizeof(struct mcast_address),
      GFP_ATOMIC);
      > +     mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
      >       if (mcaddr == NULL)

      You could make a series and also eliminate this == NULL test.

      julia

      >               return 1;
      >
      > @@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct
      adapter *adapter)
      >       }
      >       if (!physcard) {
      >               /* no structure allocated for this physical
      card yet */
      > -             physcard = kzalloc(sizeof(struct physcard),
      GFP_ATOMIC);
      > +             physcard = kzalloc(sizeof(*physcard),
      GFP_ATOMIC);
      >               if (!physcard) {
      >                       if (card_hostid == SLIC_HOSTID_DEFAULT)
      >                               kfree(card);
      > --
      > 1.8.3.4
      >
Quoted 8 lines
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

Quoted 1 line

To post to this group, send email to

[email protected].

Quoted 1 line

To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/20160222103651.GA5176%4

Quoted 5 lines

0sandhya.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

Quoted 7 lines

--
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 [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/CAA3ASz%3DisFucBfQL0sf6

Quoted 4 lines

hqjhWfC2R-ag8a_7s6W8wDnJMnGeHw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

#5 lore raw

hello,
I sent series of patches..but [patch 2/3] cant see in mailing list? should i send it again?

Quoted 125 lines · sandhya bankar

thank you !!

Quoted 118 lines · Julia Lawall
Quoted 3 lines · sandhya bankar

Hello,
I understand the ==NULL changes,but i have not understood the "make a series" concept.

If you look at the patches sent by others, sometimes they say, eg

[PATCH 1/4]

That means that there is a series of four patches, and this one is the first one. Making a series is necessary when you have several different changes to make, and they all touch the same file. By putting 1/4, 2/4, etc in the subject line, the maintainer knows in what order they should be applied. This reduces the chance of patch application errors.

This is described in more detail in the Outreachy kernel tutorial in the section "Submitting a patchset".

http://kernelnewbies.org/Outreachyfirstpatch#head-e0c4dbf8c60d25ca8e3ae133b6b65560f3c84c09

julia

Quoted 2 lines

On Wed, Feb 24, 2016 at 1:09 AM, Julia Lawall <[email protected]>

Quoted 60 lines · wrote:

      On Mon, 22 Feb 2016, Sandhya Bankar wrote:

      > Use sizeof structure *pointer over sizeof structure in
      kmalloc()/kzalloc().
      >
      > Signed-off-by: Sandhya Bankar <[email protected]>
      > ---
      >  drivers/staging/slicoss/slicoss.c | 6 +++---
      >  1 file changed, 3 insertions(+), 3 deletions(-)
      >
      > diff --git a/drivers/staging/slicoss/slicoss.c
      b/drivers/staging/slicoss/slicoss.c
      > index a91c60a..ea6b7b5 100644
      > --- a/drivers/staging/slicoss/slicoss.c
      > +++ b/drivers/staging/slicoss/slicoss.c
      > @@ -880,7 +880,7 @@ static int slic_upr_queue_request(struct
      adapter *adapter,
      >       struct slic_upr *upr;
      >       struct slic_upr *uprqueue;
      >
      > -     upr = kmalloc(sizeof(struct slic_upr), GFP_ATOMIC);
      > +     upr = kmalloc(sizeof(*upr), GFP_ATOMIC);
      >       if (!upr)
      >               return -ENOMEM;
      >
      > @@ -1806,7 +1806,7 @@ static int slic_mcast_add_list(struct
      adapter *adapter, char *address)
      >       }
      >
      >       /* Doesn't already exist.  Allocate a structure to hold
      it */
      > -     mcaddr = kmalloc(sizeof(struct mcast_address),
      GFP_ATOMIC);
      > +     mcaddr = kmalloc(sizeof(*mcaddr), GFP_ATOMIC);
      >       if (mcaddr == NULL)

      You could make a series and also eliminate this == NULL test.

      julia

      >               return 1;
      >
      > @@ -3049,7 +3049,7 @@ static u32 slic_card_locate(struct
      adapter *adapter)
      >       }
      >       if (!physcard) {
      >               /* no structure allocated for this physical
      card yet */
      > -             physcard = kzalloc(sizeof(struct physcard),
      GFP_ATOMIC);
      > +             physcard = kzalloc(sizeof(*physcard),
      GFP_ATOMIC);
      >               if (!physcard) {
      >                       if (card_hostid == SLIC_HOSTID_DEFAULT)
      >                               kfree(card);
      > --
      > 1.8.3.4
      >
Quoted 8 lines
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

Quoted 1 line

To post to this group, send email to

[email protected].

Quoted 1 line

To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/20160222103651.GA5176%4

Quoted 7 lines

0sandhya.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google

Groups

Quoted 2 lines

"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send

an

Quoted 3 lines

email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/CAA3ASz%3DisFucBfQL0sf6

Quoted 4 lines

hqjhWfC2R-ag8a_7s6W8wDnJMnGeHw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.