Skip to content

include/pthread: add wait_count to PTHREAD_COND_INITIALIZER#19147

Closed
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/pthread-cond-init
Closed

include/pthread: add wait_count to PTHREAD_COND_INITIALIZER#19147
Zepp-Hanzj wants to merge 1 commit into
apache:masterfrom
Zepp-Hanzj:fix/pthread-cond-init

Conversation

@Zepp-Hanzj

Copy link
Copy Markdown
Contributor

Summary

PTHREAD_COND_INITIALIZER was missing the initialization of the wait_count field in struct pthread_cond_s, causing a -Wmissing-field-initializers warning when statically initializing condition variables.

Before

struct pthread_cond_s
{
  sem_t sem;
  clockid_t clockid;
  int wait_count;       // ← not initialized
};

#define PTHREAD_COND_INITIALIZER {SEM_INITIALIZER(0), CLOCK_REALTIME }

After

#define PTHREAD_COND_INITIALIZER {SEM_INITIALIZER(0), CLOCK_REALTIME, 0 }

Fixes #19108

Impact

Eliminates -Wmissing-field-initializers warning for PTHREAD_COND_INITIALIZER. No functional change since C guarantees zero-initialization for missing fields in partial initializers, but the explicit initialization is cleaner and silences the warning.

Testing

Verified with grep that all fields of struct pthread_cond_s are now covered by the initializer.

PTHREAD_COND_INITIALIZER was missing the initialization of the
wait_count field in struct pthread_cond_s, causing a
-Wmissing-field-initializers warning when statically initializing
condition variables.

Fixes apache#19108

Signed-off-by: hanzhijian <hanzhijian@zepp.com>
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@Zepp-Hanzj already fixed here: #19109

@github-actions github-actions Bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Jun 16, 2026
@Zepp-Hanzj

Copy link
Copy Markdown
Contributor Author

Got it, thanks for pointing that out! I see that #19109 already addressed this. Closing this PR as duplicate.

@Zepp-Hanzj Zepp-Hanzj closed this Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] PTHREAD_COND_INITIALIZER misses wait_count initialization

2 participants