linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] futex.2: Fix a bug in the example
@ 2020-01-08  9:09 Ponnuvel Palaniyappan
  2020-01-10 20:31 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 2+ messages in thread
From: Ponnuvel Palaniyappan @ 2020-01-08  9:09 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

The man page contains a trivial bug that's discussed here:
https://stackoverflow.com/q/59628958

The patch was against latest master (commit:
f7d3e6aac109528e6f22f7c9cc5439a6ceeaa7de) and tested on Ubuntu
4.15.0-72-generic kernel.

-- 
Regards,
Ponnuvel P

[-- Attachment #2: 0001-futex.2-Fix-a-bug-in-the-example.patch --]
[-- Type: text/x-patch, Size: 1194 bytes --]

From 3ab2e9d969c63a4f6cbca415a6a3ac1763449fd3 Mon Sep 17 00:00:00 2001
From: Ponnuvel Palaniyappan <pponnuvel@gmail.com>
Date: Wed, 8 Jan 2020 09:03:07 +0000
Subject: [PATCH] futex.2: Fix a bug in the example

---
 man2/futex.2 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/man2/futex.2 b/man2/futex.2
index 8a003e2be..01b36cac3 100644
--- a/man2/futex.2
+++ b/man2/futex.2
@@ -1797,8 +1797,8 @@ fwait(int *futexp)
     while (1) {
 
         /* Is the futex available? */
-        const int zero = 0;
-        if (atomic_compare_exchange_strong(futexp, &zero, 1))
+        const int one = 1;
+        if (atomic_compare_exchange_strong(futexp, &one, 0))
             break;      /* Yes */
 
         /* Futex is not available; wait */
@@ -1820,8 +1820,8 @@ fpost(int *futexp)
 
     /* atomic_compare_exchange_strong() was described in comments above */
 
-    const int one = 1;
-    if (atomic_compare_exchange_strong(futexp, &one, 0)) {
+    const int zero = 0;
+    if (atomic_compare_exchange_strong(futexp, &zero, 1)) {
         s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);
         if (s  == \-1)
             errExit("futex\-FUTEX_WAKE");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] futex.2: Fix a bug in the example
  2020-01-08  9:09 [patch] futex.2: Fix a bug in the example Ponnuvel Palaniyappan
@ 2020-01-10 20:31 ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-01-10 20:31 UTC (permalink / raw)
  To: Ponnuvel Palaniyappan; +Cc: mtk.manpages, linux-man

Hello Ponnuvel,

On 1/8/20 10:09 AM, Ponnuvel Palaniyappan wrote:
> The man page contains a trivial bug that's discussed here:
> https://stackoverflow.com/q/59628958
> 
> The patch was against latest master (commit:
> f7d3e6aac109528e6f22f7c9cc5439a6ceeaa7de) and tested on Ubuntu
> 4.15.0-72-generic kernel.

(Inline patches arep preferred, rather than attacments.)

Thanks for the patch! Applied.

Cheers,

Michael



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-10 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08  9:09 [patch] futex.2: Fix a bug in the example Ponnuvel Palaniyappan
2020-01-10 20:31 ` Michael Kerrisk (man-pages)

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 NNTP newsgroup(s).