public inbox for speakup@linux-speakup.org
 help / color / mirror / Atom feed
From: William Hubbs <w.d.hubbs@gmail.com>
To: speakup@linux-speakup.org
Subject: Fwd: Re: speakup issues
Date: Thu, 9 May 2013 18:50:12 -0500	[thread overview]
Message-ID: <20130509235012.GC2123@linux1> (raw)

----- Forwarded message from Dan Carpenter <dan.carpenter@oracle.com> -----

> Date: Fri, 10 May 2013 01:49:12 +0300
> From: Dan Carpenter <dan.carpenter@oracle.com>
> To: William Hubbs <w.d.hubbs@gmail.com>
> Cc: devel@driverdev.osuosl.org
> Subject: Re: speakup issues
> 
> Btw, this code isn't horrible.  It uses small functions and it's
> readable.  It's just needs small cleanups throughout...
> 
> Get rid of the global variable called "synth".  That's a bad name
> for a global and it's shadowed by local variables named "synth" so
> it creates confusion.
> 
> Don't do "pr_warn("synth probe\n");" on the success path.
> 
> As much as possible get rid of forward declarations.
> 
> Some of the 80 character line breaks were done in a funny way.
> 
> What is this code?
> #if defined(__powerpc__) || defined(__alpha__)
> 	cval >>= 8;
> #else /* !__powerpc__ && !__alpha__ */
> 	cval >>= 4;
> #endif /* !__powerpc__ && !__alpha__ */
> 
> Delete commented out code.
> 
> The file scoped variable "timeouts" is only used in one function.
> It could be declared as a static variable locally in that function.
> 
> /*
>  * this is cut&paste from 8250.h. Get rid of the structure, the definitions
>  * and this whole broken driver.
>  */
> 
> We go to a lot of effort to print out this message which just tells
> you that adds no information:
> 
> 	if (failed) {
> 		pr_info("%s: not found\n", synth->long_name);
> 		return -ENODEV;
> 	}
> 
> synth_add() has a memory corrupting off-by-one bug.
> 
> The code returns -1 (which means "permission denied") instead of
> returning standard error codes.
> 
> The author of this code doesn't like break statements and uses
> compound conditions to avoid them.
> 
>    426          for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
>    427                  /* synth_remove() is responsible for rotating the array down */
>    428                  if (in_synth == synths[i]) {
>    429                          mutex_unlock(&spk_mutex);
>    430                          return 0;
>    431                  }
>    432          if (i == MAXSYNTHS) {
>    433                  pr_warn("Error: attempting to add a synth past end of array\n");
>    434                  mutex_unlock(&spk_mutex);
>    435                  return -1;
>    436          }
> 
> Unless there is a special reason then for loops should be written
> in the canonical format.  Use curly braces for readability when
> there is a multi-line loop even if they are not needed
> syntactically.
> 
> 	for (i = 0; i < ARRAY_SIZE(synths); i++) {
> 		/* synth_remove() is responsible for rotating the array down */
> 		if (synths[i] == in_synth) {
> 			mutex_unlock(&spk_mutex);
> 			return 0;
> 		}
> 		if (synths[i] == NULL)
> 			break;
> 	}
> 	if (i == ARRAY_SIZE(synths)) {
> 		pr_warn("Error: attempting to add a synth past end of array\n");
> 		mutex_unlock(&spk_mutex);
> 		return -ENOMEM;
> 	}
> 
> Pretty much where ever you look there is something to clean up.
> Fortunately, it's mostly small things.
> 
> Sparse has a few things it complains about.
> 
> regards,
> dan carpenter

----- End forwarded message -----

             reply	other threads:[~ UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
 William Hubbs [this message]
  -- strict thread matches above, loose matches on Subject: below --
 William Hubbs
 ` covici
   ` Jason White
 William Hubbs

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=20130509235012.GC2123@linux1 \
    --to=w.d.hubbs@gmail.com \
    --cc=speakup@linux-speakup.org \
    /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).