include/pthread : initialize wait_count in PTHREAD_COND_INITIALIZER#19109
Open
nicolasWDC wants to merge 1 commit into
Open
include/pthread : initialize wait_count in PTHREAD_COND_INITIALIZER#19109nicolasWDC wants to merge 1 commit into
nicolasWDC wants to merge 1 commit into
Conversation
Contributor
Author
|
Fixes #19108 |
struct pthread_cond_s contains three fields: sem, clockid, and wait_count. However, PTHREAD_COND_INITIALIZER only initialized the first two fields, which triggers -Wmissing-field-initializers when a condition variable is statically initialized. Initialize wait_count explicitly to zero so the macro matches the structure definition and remains warning-free with strict compiler flags. Validated with a minimal compile test using: pthread_cond_t cond = PTHREAD_COND_INITIALIZER; Signed-off-by: nicolasWDC <nicolasWDC@users.noreply.github.com>
xiaoxiang781216
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Fix
PTHREAD_COND_INITIALIZERmissingwait_countinitializerSummary
This PR patches NuttX 12.13.0 to fully initialize
pthread_cond_sinPTHREAD_COND_INITIALIZER.The patch updates:
to:
Motivation
During the NuttX 12.13.0 migration, strict builds emitted:
The warning is caused by the mismatch between the structure definition and the static initializer.
pthread_cond_sis defined with three fields:but the initializer only covered
semandclockid.Fix
Initialize the third field explicitly:
This makes
PTHREAD_COND_INITIALIZERconsistent withstruct pthread_cond_s.Patch
File:
Change:
Validation
Validated with a minimal compile test:
The test now builds without the
pthread_cond_s::wait_countmissing-initializer warning.Closes #19108