Skip to content

Commit 8a52837

Browse files
committed
pbio/os: Use standard notation for unused yield variable.
This is the more idiomatic way. The notation if (do_yield_now) {;} stems from Contiki, which can be a bit mysterious in the context of these macros. Its sole purpose to suppress unused variable warnings is not obvious.
1 parent 22f782e commit 8a52837

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • lib/pbio/include/pbio

lib/pbio/include/pbio/os.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ struct _pbio_os_process_t {
136136
* which the protothread runs. All C statements above the ASYNC_BEGIN()
137137
* invocation will be executed each time the protothread is scheduled.
138138
*
139+
* The do_yield_now variable is used only to facilitate the AWAIT_ONCE macro.
140+
* It shouldn't take any space if unused and optimizations are enabled.
141+
*
139142
* @param [in] state Protothread state.
140143
*/
141-
#define ASYNC_BEGIN(state) { char do_yield_now = 0; if (do_yield_now) {;} PB_LC_RESUME(state)
144+
#define ASYNC_BEGIN(state) { char do_yield_now = 0; (void)do_yield_now; PB_LC_RESUME(state)
142145

143146
/**
144147
* Declare the end of a protothread and returns with given code.

0 commit comments

Comments
 (0)