Skip to contentSkip to conversation

Fixed to codestyle

PATCH NAK Ozgur Karatas 3 participants 11 messages Dec 12, 2016 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixed to codestyle

Hello,

I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". I tested it.

Regards,

---

fs/xfs/uuid.c +3 -3
index b83f76b..cd8bc8e 100644
@@ -33,7 +33,7 @@ typedef struct {
  * it just something that's needed for user-level file handles.
  */
 void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
+uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])
 {
 	xfs_uu_t *uup = (xfs_uu_t *)uuid;
 
@@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)
 	if (uuid == NULL)
 		return 0;
 	/* implied check of version number here... */
-	for (i = 0; i < sizeof *uuid; i++)
-		if (*cp++) return 0;	/* not nil */
+	for (i = 0; i < sizeof (*uuid); i++) 
+	if (*cp++) return 0;	/* not nil */
 	return 1;	/* is nil */
 }
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 9 lines · Ozgur Karatas

Hello,

I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". I tested it.

Regards,

NAK

This doesn't fix code style at all; there is no need and no precedence for i.e. (*uuid) in function arguments in the xfs code, and you have broken indentation in the loop within the function.

Thanks,
-Eric

Quoted 25 lines

---

fs/xfs/uuid.c +3 -3
index b83f76b..cd8bc8e 100644
@@ -33,7 +33,7 @@ typedef struct {
  * it just something that's needed for user-level file handles.
  */
 void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
+uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])
 {
 	xfs_uu_t *uup = (xfs_uu_t *)uuid;
 
@@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)
 	if (uuid == NULL)
 		return 0;
 	/* implied check of version number here... */
-	for (i = 0; i < sizeof *uuid; i++)
-		if (*cp++) return 0;	/* not nil */
+	for (i = 0; i < sizeof (*uuid); i++) 
+	if (*cp++) return 0;	/* not nil */
 	return 1;	/* is nil */
 }
 
#2 lore raw
Quoted 9 lines · Eric Sandeen
Quoted 8 lines · Ozgur Karatas

Hello,

I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". I tested it.

Regards,

Quoted 7 lines
Quoted 1 line

NAK

This doesn't fix code style at all; there is no need and no precedence for i.e. (*uuid) in function arguments in the xfs code, and you have broken indentation in the loop within the function.

Perhaps better would be to convert the xfs uuid_t typedef to the include/uapi/linux/uuid.h appropriate struct and maybe use a comparison to NULL_UUID_<type>

Quoted 1 line

fs/xfs/uuid.c

Quoted 1 line
fs/xfs/uuid.c +0 -0

[]

Quoted 6 lines

fs/xfs/uuid.c typedef struct { · line 36

Quoted 6 lines
fs/xfs/uuid.c +1 -1
@@ -33,7 +33,7 @@ typedef struct {
  * it just something that's needed for user-level file handles.
  */
 void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
+uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])

And to amplify Eric's comment:

that bit is confusing as it makes uuid look
like a function pointer.

Quoted 11 lines

fs/xfs/uuid.c uuid_is_nil(uuid_t *uuid) · line 55

Quoted 11 lines
fs/xfs/uuid.c +2 -2
 {
 	xfs_uu_t *uup = (xfs_uu_t *)uuid;
 
@@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)
 	if (uuid == NULL)
 		return 0;
 	/* implied check of version number here... */
-	for (i = 0; i < sizeof *uuid; i++)
-		if (*cp++) return 0;	/* not nil */
+	for (i = 0; i < sizeof (*uuid); i++) 
+	if (*cp++) return 0;	/* not nil */

There shouldn't be a space after sizeof.

Quoted 3 lines
Quoted 3 lines
fs/xfs/uuid.c +0 -0
 	return 1;	/* is nil */
 }
 
#3 lore raw
Quoted 39 lines · Joe Perches
Quoted 9 lines · Eric Sandeen
Quoted 8 lines · Ozgur Karatas

Hello,

I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". I tested it.

Regards,

Quoted 7 lines
Quoted 1 line

NAK

This doesn't fix code style at all; there is no need and no precedence for i.e. (*uuid) in function arguments in the xfs code, and you have broken indentation in the loop within the function.

Perhaps better would be to convert the xfs uuid_t typedef to the include/uapi/linux/uuid.h appropriate struct and maybe use a comparison to NULL_UUID_<type>

Quoted 1 line

fs/xfs/uuid.c

Quoted 1 line
fs/xfs/uuid.c +0 -0

[]

Quoted 6 lines

fs/xfs/uuid.c typedef struct { · line 36

Quoted 6 lines
fs/xfs/uuid.c +1 -1
@@ -33,7 +33,7 @@ typedef struct {
  * it just something that's needed for user-level file handles.
  */
 void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
+uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])

And to amplify Eric's comment:

that bit is confusing as it makes uuid look
like a function pointer.

Quoted 3 lines
Quoted 3 lines
fs/xfs/uuid.c +0 -0
 {
 	xfs_uu_t *uup = (xfs_uu_t *)uuid;
 
Quoted 10 lines
Quoted 8 lines

fs/xfs/uuid.c uuid_is_nil(uuid_t *uuid) · line 55

Quoted 8 lines
fs/xfs/uuid.c +2 -2
@@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)
 	if (uuid == NULL)
 		return 0;
 	/* implied check of version number here... */
-	for (i = 0; i < sizeof *uuid; i++)
-		if (*cp++) return 0;	/* not nil */
+	for (i = 0; i < sizeof (*uuid); i++) 
+	if (*cp++) return 0;	/* not nil */

There shouldn't be a space after sizeof.

and the "if" /should/ be indented under the for loop, because it is within the loop...

I suppose simply:

- for (i = 0; i < sizeof *uuid; i++)
+ for (i = 0; i < sizeof(*uuid); i++)

would be fine on its own, though, because that is a bit unusual/inconsistent. I'll admit that I didn't spot that change as I scanned over the unnecessary & incorrect parts of the first patch. :)

thanks,
-Eric

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
fs/xfs/uuid.c +0 -0
 	return 1;	/* is nil */
 }
 
#4 lore raw

12.12.2016, 20:35, "Eric Sandeen" <[email protected]>:

Quoted 58 lines · Joe Perches
Quoted 47 lines · Eric Sandeen
Quoted 8 lines · Ozgur Karatas
Quoted 7 lines

 Hello,

 I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". I tested it.

 Regards,

Quoted 7 lines
Quoted 1 line

 NAK

 This doesn't fix code style at all; there is no need and no precedence for i.e. (*uuid) in function arguments in the xfs code, and you have broken indentation in the loop within the function.

 Perhaps better would be to convert the xfs uuid_t typedef to the include/uapi/linux/uuid.h appropriate struct and maybe use a comparison to NULL_UUID_<type>

Quoted 1 line
Quoted 1 line

 diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c

 []

Quoted 6 lines
Quoted 6 lines

 @@ -33,7 +33,7 @@ typedef struct {
   * it just something that's needed for user-level file handles. */
  void
 -uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) +uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])

 And to amplify Eric's comment:

 that bit is confusing as it makes uuid look
 like a function pointer.

Quoted 11 lines
Quoted 11 lines

  {
          xfs_uu_t *uup = (xfs_uu_t *)uuid;

 @@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid) if (uuid == NULL)
                  return 0;
          /* implied check of version number here... */
 - for (i = 0; i < sizeof *uuid; i++)
 - if (*cp++) return 0; /* not nil */
 + for (i = 0; i < sizeof (*uuid); i++)
 + if (*cp++) return 0; /* not nil */

Quoted 1 line

 There shouldn't be a space after sizeof.

and the "if" /should/ be indented under the for loop, because it is within the loop...

I suppose simply:

- for (i = 0; i < sizeof *uuid; i++)
+ for (i = 0; i < sizeof(*uuid); i++)

Quoted 7 lines

would be fine on its own, though, because that is a bit unusual/inconsistent. I'll admit that I didn't spot that change as I scanned over the unnecessary & incorrect parts of the first patch. :)

thanks,
-Eric

Dear Eric;

Can you tell me the true code style? should use to (* uuid)? I'm learn to new and I'm newbies :)

Sorry,

Regards

Ozgur

#5 lore raw
Quoted 2 lines · Ozgur Karatas

12.12.2016, 20:35, "Eric Sandeen" <[email protected]>:

Quoted 1 line · Joe Perches

...

Quoted 27 lines
Quoted 27 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
  {
          xfs_uu_t *uup = (xfs_uu_t *)uuid;

@@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)

          if (uuid == NULL)
                  return 0;
          /* implied check of version number here... */

- for (i = 0; i < sizeof *uuid; i++)
- if (*cp++) return 0; /* not nil */
+ for (i = 0; i < sizeof (*uuid); i++)
+ if (*cp++) return 0; /* not nil */

Quoted 1 line

There shouldn't be a space after sizeof.

and the "if" /should/ be indented under the for loop, because it is within the loop...

I suppose simply:

- for (i = 0; i < sizeof *uuid; i++)
+ for (i = 0; i < sizeof(*uuid); i++)

would be fine on its own, though, because that is a bit unusual/inconsistent. I'll admit that I didn't spot that change as I scanned over the unnecessary & incorrect parts of the first patch. :)

Quoted 7 lines
Quoted 2 lines

thanks,
-Eric

Dear Eric;

Can you tell me the true code style? should use to (* uuid)? I'm learn to new and I'm newbies :)

Well, rule #1 for newbies is "code style patches aren't very useful, and usually are not welcomed by the project."

Making style changes just because checkpatch told you to is not particularly helpful. If it were important, it would have been done by now. If it hasn't been done by now, odds are it's not important. :)

If you are writing /new/ code, then sure, conform to the kernel style, /aided/ by checkpatch.pl, and using your discretion as well.

If you are just now looking at xfs/* code, best not to start with "style" cleanups. You'll find this to be true in general across the kernel, maintainers are usually not thrilled to have this kind of patch.

If you want to start with a new project, learn about the code, learn what it /does/, learn how to use it. use it. Find things that don't work as expected, or could work better. Look into bug reports and if you understand them, and the code involved, try to write and test a fix. But don't go looking for whitespace nitpicks.

Quoted 1 line

Sorry,

No need to be sorry, this is how we learn. ;) But really, making purely cosmetic changes for their own sake is not helpful in general.

-Eric

Quoted 8 lines

Regards

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

#6 lore raw

12.12.2016, 22:41, "Eric Sandeen" <[email protected]>:

Quoted 8 lines

Well, rule #1 for newbies is "code style patches aren't very useful, and usually are not welcomed by the project."

Making style changes just because checkpatch told you to is not particularly helpful. If it were important, it would have been done by now. If it hasn't been done by now, odds are it's not important. :)

Quoted 8 lines

If you are writing /new/ code, then sure, conform to the kernel style, /aided/ by checkpatch.pl, and using your discretion as well.

If you are just now looking at xfs/* code, best not to start with "style" cleanups. You'll find this to be true in general across the kernel, maintainers are usually not thrilled to have this kind of patch.

Dear Eric;
this information was very good and thank you, I will try for the better :)

Quoted 6 lines

If you want to start with a new project, learn about the code, learn what it /does/, learn how to use it. use it. Find things that don't work as expected, or could work better. Look into bug reports and if you understand them, and the code involved, try to write and test a fix. But don't go looking for whitespace nitpicks.

I get it now, I understand but I think the error was only uuid functions. Now, me more careful.

Quoted 8 lines
Quoted 1 line

 Sorry,

No need to be sorry, this is how we learn. ;) But really, making purely cosmetic changes for their own sake is not helpful in general.

-Eric

I have mentioned above, thank you for all the information. You are helping me and your mentoring in some way.

Regards

Ozgur Karatas

#7 lore raw
In reply to Eric Sandeen
Quoted 1 line · Eric Sandeen

On 12/12/16 2:34 PM, Ozgur Karatas wrote:

[]

Quoted 5 lines
Quoted 2 lines

Can you tell me the true code style? should use to (* uuid)? I'm learn to new and I'm newbies :)

Well, rule #1 for newbies is "code style patches aren't very useful, and usually are not welcomed by the project."

I'd amend that to

"newbies should only use checkpatch on files in drivers/staging/"

and are generally welcome to do exactly that in order to learn how to submit patches appropriately before finding something actually useful to change in other areas of the kernel.

#8 lore raw

12.12.2016, 22:50, "Joe Perches" <[email protected]>:

Quoted 10 lines · Eric Sandeen
Quoted 1 line · Ozgur Karatas

[]

Quoted 5 lines

 > Can you tell me the true code style? should use to (* uuid)? > I'm learn to new and I'm newbies :)

 Well, rule #1 for newbies is "code style patches aren't very useful, and usually are not welcomed by the project."

Quoted 7 lines

I'd amend that to

"newbies should only use checkpatch on files in drivers/staging/"

and are generally welcome to do exactly that in order to learn how to submit patches appropriately before finding something actually useful to change in other areas of the kernel.

Dear Joe;
I understand, thank you very much but I use XFS and I'm trying to learn how to code to XFS filesystems. Maybe, I can try for XFS and I need to very learn more :)

Regards,

Ozgur Karatas

#9 lore raw
In reply to Joe Perches
Quoted 9 lines · Joe Perches
Quoted 1 line · Eric Sandeen

On 12/12/16 2:34 PM, Ozgur Karatas wrote:

[]

Quoted 5 lines
Quoted 2 lines

Can you tell me the true code style? should use to (* uuid)? I'm learn to new and I'm newbies :)

Well, rule #1 for newbies is "code style patches aren't very useful, and usually are not welcomed by the project."

Quoted 7 lines

I'd amend that to

"newbies should only use checkpatch on files in drivers/staging/"

and are generally welcome to do exactly that in order to learn how to submit patches appropriately before finding something actually useful to change in other areas of the kernel.

Ok, that's a fair amendment. :)

-Eric

#10 lore raw
In reply to Joe Perches

12.12.2016, 20:14, "Joe Perches" <[email protected]>:

Quoted 14 lines · Eric Sandeen
Quoted 13 lines · Ozgur Karatas

 >
 > Hello,
 >
 > I have error to use uuid and I think the functions should be used when -i'm eye-catching- "(* uuid)". > I tested it.
 >
 > Regards,
 >
 > Signed-off-by: Ozgur Karatas <[email protected]>

 NAK

Quoted 7 lines
Quoted 3 lines

 This doesn't fix code style at all; there is no need and no precedence for i.e. (*uuid) in function arguments in the xfs code, and you have broken indentation in the loop within the function.

Perhaps better would be to convert the xfs uuid_t typedef to the include/uapi/linux/uuid.h appropriate struct and maybe use a comparison to NULL_UUID_<type>

Dear Joe;
Firstly, I have studied and so I thought it was correct to use it as (* uuid) in this regard Mr. Eric corrected me and he is explanatory to me.

fs/xfs/uuid.c:21: WARNING: do not add new typedefs fs/xfs/uuid.c:36: ERROR: space prohibited before open square bracket '[' fs/xfs/uuid.c:54: WARNING: sizeof *uuid should be sizeof(*uuid) fs/xfs/uuid.c:55: ERROR: trailing statements should be on next line
total: 2 errors, 2 warnings, 63 lines checked

Quoted 27 lines
Quoted 9 lines

 > diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c

 > @@ -33,7 +33,7 @@ typedef struct {
 > * it just something that's needed for user-level file handles. > */
 > void
 > -uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
 > +uuid_getnodeuniq(uuid_t (*uuid), int fsid [2])

And to amplify Eric's comment:

that bit is confusing as it makes uuid look
like a function pointer.

Quoted 11 lines

 > {
 > xfs_uu_t *uup = (xfs_uu_t *)uuid;
 >
 > @@ -51,8 +51,8 @@ uuid_is_nil(uuid_t *uuid)
 > if (uuid == NULL)
 > return 0;
 > /* implied check of version number here... */
 > - for (i = 0; i < sizeof *uuid; i++)
 > - if (*cp++) return 0; /* not nil */
 > + for (i = 0; i < sizeof (*uuid); i++)
 > + if (*cp++) return 0; /* not nil */

Quoted 1 line

There shouldn't be a space after sizeof.

You can see below:
fs/xfs/uuid.c:54: WARNING: sizeof *uuid should be sizeof(*uuid) Regards,

Ozgur

Quoted 3 lines
Quoted 3 lines

 > return 1; /* is nil */
 > }
 >