Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coccinelle: final pass standardizing integer timeout parameters #19650

Merged
merged 6 commits into from
Oct 9, 2019

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Oct 7, 2019

(At least I think this is final, but I've thought that before.)

This PR like the others is best reviewed at the commit level, as there are a lot of rote changes. Only the changes to the .cocci script are by hand.

Three features in this:

  • Fixed a few errors in the existing regular expression intended to detect API calls that passed a timeout in the last parameter. No errors resulted in incorrect conversion in previous PRs, and only one missed function resulted in a new conversion.

  • Convert k_sleep to take timeouts. There's been some discussion of whether this should remain milliseconds, but the consensus was that being able to use explicit duration macros like K_MSEC and K_SECONDS was highly desired. The scale tipped to "timeout" for me when I discovered that k_sleep() specifically relies on the thread timeout infrastructure (it's a no-op if threads are disabled). If the consensus switches again, those commits can be dropped.

    I have a proposal in Generalizing duration representation in clock-agnostic way #19656 that would preserve use those API macros for time-defined timeouts even when New timeout API #17155 revisions are done so unifying it now seems to make sense. If that proposal doesn't fly we'd still want to replace these.

  • Convert static and runtime thread start delays to timeouts. Most static definitions did this already, but it took me a while to figure out how to make Coccinelle convert the missing ones.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 7, 2019

All checks are passing now.

checkpatch (informational only, not a failure)

-:3065: WARNING:LONG_LINE_COMMENT: line over 80 characters
#3065: FILE: tests/kernel/mutex/sys_mutex/src/main.c:348:
+	k_sleep(K_MSEC(1));     /* Give thread_12 a chance to block on the mutex */

- total: 0 errors, 1 warnings, 3079 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

Copy link
Collaborator

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

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

looks good in my areas

.shippable.yml Outdated
@@ -6,13 +6,28 @@ env:
global:
Copy link
Member

Choose a reason for hiding this comment

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

please remove this change, we will need to override CI in this case..

@@ -419,7 +419,8 @@ static void tmbox_get(struct k_mbox *pmbox)
NULL);
Copy link
Member

Choose a reason for hiding this comment

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

Please put this with other code change and separate it from the coccinelle script change.

Sort the functions within the regular expression so they can be
checked more easily.

Remove k_thread_deadline_set as it takes an argument in cycles.  (The
one in-tree call to this function was not affected by this error.)

Add missed k_mbox_data_block_get.

Fix an overly ambitious multi-match disjunct that covered some
non-existent functions.

Signed-off-by: Peter Bigot <[email protected]>
Re-run with updated script to convert integer literal delay arguments to
k_mbox_data_block_get to use the standard timeout macros.

Signed-off-by: Peter Bigot <[email protected]>
k_sleep uses the same underlying thread infrastructure as the other
functions that take timeouts, so the delay should be specified as a
timeout rather than milliseconds.

Signed-off-by: Peter Bigot <[email protected]>
Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.

Signed-off-by: Peter Bigot <[email protected]>
…tion

k_thread_create and K_THREAD_DEFINE both take a delay as the final
parameter.  Most uses of K_THREAD_DEFINE pass either `K_NO_WAIT` or
`K_FOREVER`.  Ensure that all uses of K_THREAD_DEFINE follow that
practice, and that the runtime k_thread_create calls do so as well.

Signed-off-by: Peter Bigot <[email protected]>
…eouts

Re-run with updated script to convert integer literal delay arguments
to k_thread_create and K_THREAD_DEFINE to use the standard timeout
macros.

Signed-off-by: Peter Bigot <[email protected]>
@pabigot
Copy link
Collaborator Author

pabigot commented Oct 8, 2019

@nashif shippable patch removed, API change separated, rebased on current master (no new changes were required).

Copy link
Member

@vanwinkeljan vanwinkeljan left a comment

Choose a reason for hiding this comment

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

display related changes LGTM

Copy link
Member

@aescolar aescolar left a comment

Choose a reason for hiding this comment

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

No complaints for the few files I own.

@nashif nashif merged commit e28f330 into zephyrproject-rtos:master Oct 9, 2019
@pabigot pabigot deleted the cocci/20191006 branch October 15, 2019 10:06
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.

8 participants