toolsoftrade: Fix code listing 4.22 in Chapter 4
PATCH 1/1 toolsoftrade: Fix code listing 4.22 in Chapter 4
Code listing 4.22 is broken since the READ_ONCE() macro takes a rvalue and the expression parenthesis are unbalanced. This patch fixes it.
--- toolsoftrade/toolsoftrade.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
toolsoftrade/toolsoftrade.tex +1 -1
@@ -2111,7 +2111,7 @@ Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. \begin{listing}[tbp] \begin{linelabel}[ln:toolsoftrade:Preventing Load Fusing] \begin{VerbatimL}[commandchars=\\\{\}] -while (!READ_ONCE((!need_to_stop)) +while (!READ_ONCE(need_to_stop)) do_something_quickly(); \end{VerbatimL} \end{linelabel}
Signature · 1 line
2.19.1
Quoted 13 lines · On Tue, 19 Mar 2019 16:59:27 +0200 Slavomir Kaslev <[email protected]> wrote:
Code listing 4.22 is broken since the
READ_ONCE()macro takes a rvalue and the expression parenthesis are unbalanced. This patch fixes it.Signed-off-by Slavomir Kaslev <[email protected]>--- toolsoftrade/toolsoftrade.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)toolsoftrade/toolsoftrade.tex +0
-0
toolsoftrade/toolsoftrade.tex Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. · line 2114
Quoted 5 lines
toolsoftrade/toolsoftrade.tex +1
-1@@ -2111,7 +2111,7 @@ Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. \begin{listing}[tbp] \begin{linelabel}[ln:toolsoftrade:Preventing Load Fusing] \begin{VerbatimL}[commandchars=\\\{\}] -while (!READ_ONCE((!need_to_stop)) +while (!READ_ONCE(need_to_stop))
But doesn't this change the logic?
I'm guessing that the double "!" was wrong too.
-- Steve
Quoted 3 lines
toolsoftrade/toolsoftrade.tex +0
-0do_something_quickly(); \end{VerbatimL} \end{linelabel}
Quoted 11 lines · Steven Rostedt
Quoted 8 lines · On Tue, 19 Mar 2019 16:59:27 +0200 Slavomir Kaslev <[email protected]> wrote:
Code listing 4.22 is broken since the
READ_ONCE()macro takes a rvalue and the expression parenthesis are unbalanced. This patch fixes it.Signed-off-by Slavomir Kaslev <[email protected]>--- toolsoftrade/toolsoftrade.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
toolsoftrade/toolsoftrade.tex Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. · line 2114
Quoted 10 lines
toolsoftrade/toolsoftrade.tex +1
-1@@ -2111,7 +2111,7 @@ Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. \begin{listing}[tbp] \begin{linelabel}[ln:toolsoftrade:Preventing Load Fusing] \begin{VerbatimL}[commandchars=\\\{\}] -while (!READ_ONCE((!need_to_stop)) +while (!READ_ONCE(need_to_stop))But doesn't this change the logic?
It does.
Quoted 1 line
I'm guessing that the double "!" was wrong too.
And it was. In converting Listing 4.16 to 4.24 (your listing numbers may vary), I added the READ_ONCE(), but missed removing the extra "!". Or I added the READ_ONCE() in the wrong place, your choice. ;-)
Thanx, Paul
Quoted 7 lines
-- Steve
Quoted 3 lines
toolsoftrade/toolsoftrade.tex +0
-0do_something_quickly(); \end{VerbatimL} \end{linelabel}
Quoted 4 lines · Slavomir Kaslev
Code listing 4.22 is broken since the
READ_ONCE()macro takes a rvalue and the expression parenthesis are unbalanced. This patch fixes it.Signed-off-by Slavomir Kaslev <[email protected]>
Good eyes, thank you! Queued and pushed.
Thanx, Paul
Quoted 20 lines
--- toolsoftrade/toolsoftrade.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)toolsoftrade/toolsoftrade.tex +1
-1@@ -2111,7 +2111,7 @@ Listing~\ref{lst:toolsoftrade:Avoiding Danger, 2018 Style}. \begin{listing}[tbp] \begin{linelabel}[ln:toolsoftrade:Preventing Load Fusing] \begin{VerbatimL}[commandchars=\\\{\}] -while (!READ_ONCE((!need_to_stop)) +while (!READ_ONCE(need_to_stop)) do_something_quickly(); \end{VerbatimL} \end{linelabel}Signature · 1 line
2.19.1