lkml.org 
[lkml]   [2020]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] taging: speakup: remove volatile
From
Date
On Fri, 2020-05-22 at 13:34 +0300, Dan Carpenter wrote:
> On Fri, May 22, 2020 at 02:46:28PM +0530, MugilRaj wrote:
> > fix checkpatch.pl warning, which is Use of volatile is usually wrong: see
> > Documentation/process/volatile-considered-harmful.rst
> > Signed-off-by: MugilRaj <dmugil2000@gmail.com>
>
> Please put a blank before the Signed-off-by line.
>
> Probably there should be a space between your first and last name. It's
> supposed to your legal name like for signing a legal document so use
> whatever is appropriate legal documents in your country.
>
> Also the Documentation/process/volatile-considered-harmful.rst explains
> that people often use "volatile" when they should be using locking for
> synchronization. That seems to be the case here. So the correct fix is
> to add locking. That's a little bit complicated to do and requires
> testing.
>
> If we apply this patch, then we have silenced the warning so now someone
> will have to look for the bug. But if we leave it as-is, then everyone
> will know that the code is buggy. So let's leave it as-is until we are
> able to fix the bug.
>
> It's always better to have easy to find bugs, than hidden bugs.

And better still to comment known opportunities to
improve the code so the next time someone tries to
remove this volatile, there's a comment right there
showing what's necessary instead.

Something like:
---
drivers/staging/speakup/speakup_decext.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c
index 7408eb29cf38..e68e6046bb51 100644
--- a/drivers/staging/speakup/speakup_decext.c
+++ b/drivers/staging/speakup/speakup_decext.c
@@ -21,6 +21,7 @@
#define SYNTH_CLEAR 0x03
#define PROCSPEECH 0x0b

+/* TODO: Remove volatile, maybe add locks to read_buff_add and synth_full() ? */
static volatile unsigned char last_char;

static void read_buff_add(u_char ch)

\
 
 \ /
  Last update: 2020-05-22 18:36    [W:0.152 / U:8.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site