public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xiaoming Ni <nixiaoming@huawei.com>
To: <triegel@redhat.com>, <carlos@redhat.com>, <davem@davemloft.net>,
	<dvhart@infradead.org>, <libc-alpha@sourceware.org>,
	<1464268895.17104.14.camel@localhost.localdomain>
Subject: Question: Is "maxspin=0" in pthread_cond_wait.c dead code or bug?
Date: Mon, 14 Nov 2022 11:32:10 +0800	[thread overview]
Message-ID: <6cd63ad4-d8d4-8171-781c-a04ea305444f@huawei.com> (raw)

nptl/pthread_cond_common.c:204:  const unsigned int maxspin = 0;
nptl/pthread_cond_common.c:259:      for (unsigned int spin = maxspin; 
((r >> 1) > 0) && (spin > 0); spin--)

"(spin > 0)" is a conditional judgment that is always false.

nptl/pthread_cond_wait.c:382:  const int maxspin = 0;
nptl/pthread_cond_wait.c:448:	  unsigned int spin = maxspin;
nptl/pthread_cond_wait.c:449:	  while (signals == 0 && spin > 0)
nptl/pthread_cond_wait.c:460:	      spin--;

"(spin > 0)" is a conditional judgment that is always false.

It's been six years since 2016,
commit ed19993b5b ("New condvar implementation that provides stronger 
ordering guarantees.")
https://public-inbox.org/libc-alpha/1464268895.17104.14.camel@localhost.localdomain

Is this a logic bug caused by a mistake, or is it just useless 
deleteable code?

Thanks
Xiaoming Ni

             reply	other threads:[~2022-11-14  3:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14  3:32 Xiaoming Ni [this message]
2022-11-17 17:40 ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cd63ad4-d8d4-8171-781c-a04ea305444f@huawei.com \
    --to=nixiaoming@huawei.com \
    --cc=1464268895.17104.14.camel@localhost.localdomain \
    --cc=carlos@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dvhart@infradead.org \
    --cc=libc-alpha@sourceware.org \
    --cc=triegel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).