Skip to content

checkpatch fixes - #849

Merged
lgirdwood merged 35 commits into
thesofproject:masterfrom
plbossart:fix/checkpatch
Jan 16, 2019
Merged

lgirdwood merged 35 commits into
thesofproject:masterfrom
plbossart:fix/checkpatch

Conversation

@plbossart

Copy link
Copy Markdown
Member

It seems that everyone has dropped the ball on following coding guidelines, or no one cares about cleaning things up.

Before adding silly new rules to checkpatch, maybe we should first enforce its use and make sure the existing code is consistent. Here's a first batch I did during long debug sessions on the Linux side, there's more to come. I started from the master branch, did a reset to the origin and re-added all the files in separate patches, so checkpatch looked at all the history, not just the last contributions.

What I really looked for is:

  • misaligned parameters and conditions
  • multiple assignments
  • macros
  • spaces between casts/operands
  • balanced brackets
  • !pointer instead of pointer == NULL
  • block comments with ending at end of line instead of newline
  • logical statements on previous line rather than newline
  • spelling. dont/cant/postion/her, etc.

Disclaimer: no tests were run, this is just based on checkpatch hints and checks are needed.

remove multi-line quoted strings and use of __func__

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Make checkpatch happy

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Comment thread src/audio/pipeline.c
@@ -564,7 +569,8 @@ static int component_prepare_buffers_upstream(struct comp_dev *start,
}

/* walk the graph downstream from start component in any pipeline and prepare

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, should be

/*
 * xxx
 * xxx
 */
?

@singalsu singalsu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks for fixing my indents!

@lgirdwood

lgirdwood commented Jan 16, 2019 •

Copy link
Copy Markdown
Member

It seems that everyone has dropped the ball on following coding guidelines, or no one cares about cleaning things up.

Checkpatch should be an automatic git hook now (for all users) so most of the fixes should have been for style issues that pre-dated it's introduction. Although some may have slipped through if authors disabled the hook or committed with -n :(

@plbossart you could quickly validate by building all images with and without this patch with debug disabled and comparing binaries (they should be the same)

@mengdonglin can someone validate. thanks

@jajanusz

Copy link
Copy Markdown
Contributor

IMHO formatting shouldn't be human work.
We should have something like:
https://github.com/torvalds/linux/blob/master/.clang-format

Run it on all files to fix existing codebase then make hook for checks (it still can work with checkpatch, it's not meant to be a replacement).

This way everyone would be able to format file with just a key shortcut.

If you really would like to have some weird things like ascii art in comments you can always make it work even with clang-format

@singalsu

Copy link
Copy Markdown
Collaborator

Emacs can be configured to on-the-fly during editing format code in such way that passes the SOF check script. Though I use mainly Netbeans for development editing and there the Linux kernel code style misses some things. So, if I get fail from pre/post commit check I fix the issue with Emacs.

Though our new long traces always violate the the checker. Can the the checker be fixed to handle them?

Comment thread scripts/checkpatch.pl
"break quoted strings at a space character\n" . $hereprev);
}

# check for an embedded function name in a string when the function is known

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu I think @plbossart have done the function name warn for trace here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiuli Great that the annoyance is fixed! Due to that I've unfortunately had most of the time the pre commit script disabled.

@plbossart

plbossart commented Jan 16, 2019 via email

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants